- {resp?.config?.filter_options && Object.entries(resp.config.filter_options).map(([key, options]) => {
- if (!options || options.length === 0) return null;
-
- // Find the field in config to get its proper label
- const fieldDef = resp.config.fields.find(f => f.field_key === key);
- const label = fieldDef?.output_label || key;
-
- const opts = options.map(o => ({ value: o, label: o }));
- return (
-
@@ -206,7 +257,7 @@ export function RecordView({
>
{fields.map((f) => (
- {formatValue(row[f.field_key])}
+ {formatValue(row[f.field_key], f.field_key)}
|
))}
{rowActions && (
diff --git a/src/lib/format.ts b/src/lib/format.ts
index c70a53b..132ddc9 100644
--- a/src/lib/format.ts
+++ b/src/lib/format.ts
@@ -13,10 +13,37 @@ function isObject(v: unknown): v is Record {
}
/** Best-effort single-line display string for a field value. */
-export function formatValue(value: unknown): string {
+export function formatValue(value: unknown, fieldKey?: string): string {
if (value == null || value === '') return '—';
if (typeof value === 'boolean') return value ? 'Yes' : 'No';
- if (typeof value === 'number' || typeof value === 'string') return String(value);
+ if (typeof value === 'number') return String(value);
+ if (typeof value === 'string') {
+ const isoDateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
+ if (isoDateRegex.test(value)) {
+ const date = new Date(value);
+ if (!isNaN(date.getTime())) {
+ const lowerKey = fieldKey?.toLowerCase() || '';
+ const isTimeOnly = lowerKey.includes('time');
+ const isDateOnly = lowerKey.includes('date');
+
+ if (isTimeOnly && !isDateOnly) {
+ return date.toLocaleTimeString('en-IN', { hour: 'numeric', minute: '2-digit', hour12: true });
+ } else if (isDateOnly && !isTimeOnly) {
+ return date.toLocaleDateString('en-IN', { day: 'numeric', month: 'short', year: 'numeric' });
+ } else {
+ return date.toLocaleString('en-IN', {
+ day: 'numeric',
+ month: 'short',
+ year: 'numeric',
+ hour: 'numeric',
+ minute: '2-digit',
+ hour12: true
+ });
+ }
+ }
+ }
+ return value;
+ }
if (Array.isArray(value)) {
if (value.length === 0) return '—';
diff --git a/vite.config.ts b/vite.config.ts
index 5d81a0c..d4880cf 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -2,7 +2,7 @@ import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
-const base = process.env.VITE_BASE_URL ?? '/'
+const base = process.env.VITE_BASE_URL ?? '/krishna_sales'
export default defineConfig(() => ({
base,