diff --git a/src/api/config.ts b/src/api/config.ts index ea5cadd..c7d21e1 100644 --- a/src/api/config.ts +++ b/src/api/config.ts @@ -54,8 +54,8 @@ export const ORDER_BOOKING = { }, }, recordViews: { - ORDERS: '1e424561-9a27-44f5-9b68-64d63296d837', - CALLS: 'b4d7a710-24e7-416d-885a-31fd1e727aab', + ORDERS: '63714ac2-c9fb-40e2-abba-d4081a70b768', + CALLS: '56b21b46-6d2c-4e10-b5a3-c63d058d0afa', }, detailViews: { ORDERS: '0804c6c3-6cf9-4050-94bb-fa48dd5de87d', diff --git a/src/components/dv/DetailView.tsx b/src/components/dv/DetailView.tsx index baf69a3..69a0563 100644 --- a/src/components/dv/DetailView.tsx +++ b/src/components/dv/DetailView.tsx @@ -146,7 +146,7 @@ export function DetailView({ client, instanceId, title, columns = 2 }: DetailVie {headers.map(h => ( - {formatValue(row[h])} + {formatValue(row[h], h)} ))} @@ -164,7 +164,7 @@ export function DetailView({ client, instanceId, title, columns = 2 }: DetailVie {key.replace(/_/g, ' ')}
- {formatValue(value)} + {formatValue(value, key)}
); diff --git a/src/components/rv/CallsView.tsx b/src/components/rv/CallsView.tsx index e6f1c34..91c9535 100644 --- a/src/components/rv/CallsView.tsx +++ b/src/components/rv/CallsView.tsx @@ -15,6 +15,9 @@ export function CallsView({ onRowClick, pageSize, headerActions, rowActions, ref headerActions={headerActions} rowActions={rowActions} refreshKey={refreshKey} + sortBy="instance_id" + sortDir="desc" + omitColumns={['instance_id']} /> ); } diff --git a/src/components/rv/OrdersView.tsx b/src/components/rv/OrdersView.tsx index b8f061e..8e08dc9 100644 --- a/src/components/rv/OrdersView.tsx +++ b/src/components/rv/OrdersView.tsx @@ -22,6 +22,9 @@ export function OrdersView({ onRowClick, pageSize, headerActions, rowActions, re headerActions={headerActions} rowActions={rowActions} refreshKey={refreshKey} + sortBy="created_at" + sortDir="desc" + omitColumns={['created_at', 'instance_id']} /> ); } diff --git a/src/components/rv/RecordView.tsx b/src/components/rv/RecordView.tsx index 48681dd..ee9e76c 100644 --- a/src/components/rv/RecordView.tsx +++ b/src/components/rv/RecordView.tsx @@ -21,6 +21,8 @@ export interface RecordViewProps { title?: string; /** Restrict/order visible columns by field_key. Defaults to all fields. */ columns?: string[]; + /** Columns to hide. */ + omitColumns?: string[]; /** Rows per page. @default 25 */ pageSize?: number; /** Click handler — receives the raw row + index. */ @@ -33,6 +35,10 @@ export interface RecordViewProps { rowActions?: (row: Record) => React.ReactNode; /** Pass a new value to trigger a refresh. */ refreshKey?: number; + /** Field to sort by */ + sortBy?: string; + /** Sort direction */ + sortDir?: 'asc' | 'desc'; } /** @@ -51,6 +57,9 @@ export function RecordView({ headerActions, rowActions, refreshKey, + sortBy, + sortDir, + omitColumns, }: RecordViewProps) { const [page, setPage] = useState(1); const [search, setSearch] = useState(''); @@ -89,7 +98,14 @@ export function RecordView({ setLoading(true); setError(null); try { - const r = await client.recordView(rvUid, { page, limit: pageSize, search: debounced, filters: filtersParam }); + const r = await client.recordView(rvUid, { + page, + limit: pageSize, + search: debounced, + filters: filtersParam, + sortBy, + sortDir + }); console.log("RECORD VIEW RESP:", r); if (live) setResp(r); } catch (e) { @@ -102,16 +118,23 @@ export function RecordView({ return () => { live = false; }; - }, [client, rvUid, page, pageSize, debounced, filtersParam, refreshKey]); + }, [client, rvUid, page, pageSize, debounced, filtersParam, refreshKey, sortBy, sortDir]); const fields: RecordViewField[] = useMemo(() => { const all = resp?.config.fields ?? []; - if (!columns) return all; - const byKey = new Map(all.map((f) => [f.field_key, f])); - return columns - .map((k) => byKey.get(k) ?? ({ field_key: k, output_label: k, data_type: 'string', is_filter: false, is_search: false } as RecordViewField)) - .filter(Boolean); - }, [resp, columns]); + let result = all; + if (columns) { + const byKey = new Map(all.map((f) => [f.field_key, f])); + result = columns + .map((k) => byKey.get(k) ?? ({ field_key: k, output_label: k, data_type: 'string', is_filter: false, is_search: false } as RecordViewField)) + .filter(Boolean); + } + if (omitColumns) { + const omitSet = new Set(omitColumns); + result = result.filter((f) => !omitSet.has(f.field_key)); + } + return result; + }, [resp, columns, omitColumns]); const rows = resp?.data ?? []; const total = resp?.pagination?.total_count ?? rows.length; @@ -133,27 +156,55 @@ export function RecordView({ >
- {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 ( - { + setActiveFilters(prev => ({ ...prev, [key]: e.target.value })); + setPage(1); + }} + className="w-36 sm:w-40 h-9 rounded-md border border-border-default bg-card px-3 font-sans text-sm text-strong outline-none focus-ring shrink-0" + /> + ); + } + + const options = resp.config.filter_options?.[key]; + if (!options || options.length === 0) return null; + + const opts = options.map(o => ({ value: o, label: o })); + return ( +