diff --git a/src/api/config.ts b/src/api/config.ts index eaf6229..364065f 100644 --- a/src/api/config.ts +++ b/src/api/config.ts @@ -55,8 +55,7 @@ export const ORDER_BOOKING = { }, recordViews: { ORDERS: '1e424561-9a27-44f5-9b68-64d63296d837', - CALLS: '56b21b46-6d2c-4e10-b5a3-c63d058d0afa', - ANALYTICS_ORDERS: '63714ac2-c9fb-40e2-abba-d4081a70b768', + CALLS: 'b4d7a710-24e7-416d-885a-31fd1e727aab', ANALYTICS: '56b21b46-6d2c-4e10-b5a3-c63d058d0afa' }, detailViews: { diff --git a/src/components/cards/CallCard.tsx b/src/components/cards/CallCard.tsx index 47d2c20..625554c 100644 --- a/src/components/cards/CallCard.tsx +++ b/src/components/cards/CallCard.tsx @@ -15,9 +15,14 @@ export function CallCard({ row, isDetailView = false }: { row: Record k.includes('user_id')); + const userObj = userKey ? row[userKey] : null; + // Store Details - const storeName = formatValue(row.store || row.store_name || row.customer_name || 'Unknown Store'); - const storeCode = formatValue(row.store_code || '—'); + const storeName = formatValue(storeObj?.business_name || storeObj?.distributor_name || row.store_name || row.customer_name || (typeof row.store === 'string' ? row.store : 'Unknown Store')); + const storeCode = formatValue(storeObj?.store_code || row.store_code || '—'); // Grid Details const totalWeight = formatValue(row.total_kgs || row.total_weight || row.weight || 0); @@ -25,37 +30,39 @@ export function CallCard({ row, isDetailView = false }: { row: Record, index: number) => void; @@ -16,45 +13,19 @@ export interface WiredRecordViewProps { /** Orders record view (Order Booking workflow). */ export function OrdersView({ onRowClick, pageSize, headerActions, rowActions, refreshKey }: WiredRecordViewProps) { - const [analyticsTiles, setAnalyticsTiles] = useState([]); - - useEffect(() => { - let live = true; - - // Defer the fetch so it doesn't compete with the main list fetch - const timer = setTimeout(async () => { - try { - const res = await orderBookingClient.recordView(ORDER_BOOKING.recordViews.ANALYTICS_ORDERS, { limit: 0 }); - if (live && res.tile_values) { - const filteredTiles = (res.tile_values as TileItem[]).filter( - (t) => t.key !== 'total_orders' && t.key !== 'total_orders_count' - ); - setAnalyticsTiles(filteredTiles); - } - } catch (e) { - console.error("Failed to load analytics tiles for orders", e); - } - }, 100); - - return () => { live = false; clearTimeout(timer); }; - }, [refreshKey]); - return ( -
- {analyticsTiles.length > 0 && } - } - /> -
+ } + /> ); }