# Mock-Data β†’ Live-API Gap Analysis Goal: remove every hardcoded / mock value in `src/` and back it with a live API before staging. Each row is classified: - **WIRE** β€” a live endpoint already exists (βœ… or 🟑 in `01_ENDPOINT_CATALOG.md`); just connect it / remove the mock fallback. - **DERIVE** β€” no dedicated endpoint, but the value is computable client-side from data we already fetch (e.g. period-over-period deltas by querying two date ranges). No backend work needed. - **NEW API** β€” no endpoint exists and the value cannot be derived; backend must build it. Spec'd in `03_REQUIRED_BACKEND_APIS.md` under the referenced **[Rxx]** id. Central mock source file to delete once empty: **`src/data.ts`**. --- ## 1. DashboardView.tsx *(mostly live already)* | UI element | Current source | Class | Target | |---|---|---|---| | Active Outlets / Total / % | live `useTenantLocations` + `useOrderSummary` | OK | β€” | | Region fulfilment %, delivered/total | live `useOrderSummary` | OK | β€” | | Monthly Revenue, Monthly Profit | live `useInvoiceInsight` | OK | β€” | | Per-location orders / dispatched / fulfilled % | live `useFiestaLocationSummary` | OK | β€” | | KPI card icons / gradients / static subtext labels | hardcoded | keep | cosmetic, not data | | Banner title "Executive Command Center", "Live Core" | hardcoded | keep | cosmetic | **Dashboard is ~clean.** Only cosmetic strings remain. --- ## 2. ReportsView.tsx *(heaviest mock load)* | UI element | Current source | Class | Target | |---|---|---|---| | Orders KPI value / delivered / cancelled | live `useFiestaOrderSummary` | OK | β€” | | KPI trend deltas `+12.5%`, `+14.8%`, `-1.2%`, `+8.4%` | hardcoded | **DERIVE** | query current + previous period summary, compute % change | | Revenue value `= delivered Γ— 355` | hardcoded multiplier | **NEW API** | **[R1] revenue summary** (real money, not a guess) | | Active SKU count | live stock length | OK | β€” | | `CHART_DATA_YTD` (12-mo orders/revenue/cancelled/skus) | hardcoded | **NEW API** | **[R2] order+revenue time-series** (orders partly via `getOrderInsight`; revenue & skus need [R1]/[R2]) | | `getDynamicChartData` month/12M/all-time series | hardcoded | **NEW API** | **[R2]** with `granularity=day|month|year` | | Region scaling multipliers (0.42 / 0.60 / 0.75…) | hardcoded fudge | **NEW API** | **[R2]** filtered by region/location β€” remove multipliers | | Monthly order heatmap β€” Coimbatore rows | live `useFiestaOrderInsight` | OK | β€” | | Monthly order heatmap β€” Chennai/Bangalore stub rows | hardcoded | **WIRE** | `getOrderInsight` returns all tenant locations; remove stubs | | `MONTH_LABELS`, `MONTH_KEYS` | hardcoded | keep | static axis labels | | Top-nodes leaderboard names / order counts | live (location summary) | OK | β€” | | Leaderboard **revenue** column | derived from order count | **NEW API** | **[R1]** revenue-per-location | | Product matrix rows | live `useFiestaStockStatement`β†’`stockRowToProduct` | OK | β€” | | `unitsSold`/`revenue` per product (mapper uses `debit`Γ—`retailprice`) | approximated | **NEW API** | **[R3] product sales analytics** (true units sold + revenue) | | Expanded-row stock units (142/42/6), bar widths, hub split 60/40 | hardcoded | **WIRE/NEW** | per-outlet via `productlocations` 🟑; hub split = real `productstocks` | | Warehouse Bin `BIN-C…`, "Last Audited" date, barcode bars | hardcoded | **NEW API** | **[R3]** product meta (bin, last-audit) β€” or drop if not tracked | | Export progress modal | simulated | keep | client UX only | --- ## 3. InventoryView.tsx | UI element | Current source | Class | Target | |---|---|---|---| | Banner active-outlets count | live `useFiestaTenantLocations` | OK | β€” | | Banner total on-hand volume | live `useFiestaStoresStock` | OK | β€” | | Global catalog grid | live stock β†’ `stockRowToProduct` | OK | β€” | | Optimal/Low/Critical hub counts | derived from live stock + thresholds | OK | thresholds are business rules, keep | | Per-store SKU lists, capacity bars | live `useFiestaStoresStock` | OK | β€” but prefer real capacity ([R3]) | | `initialImportLogs` (Live Sync Audit Stream) | mock `data.ts` | **NEW API** | **[R4] import/sync audit log** | | CSV import default template string | hardcoded | keep | UX template | | Nilgiris Dairy / Coimbatore Heritage presets | hardcoded | **WIRE** | catalog presets β†’ `getAllTenants`/master catalog 🟑, or **NEW [R5]** | | Brand Design Studio (theme, colors, bag label, eco-seal) | hardcoded local state | **NEW API** | **[R6] merchant branding config** (GET+PUT) | | Add-Product modal category list | hardcoded | **WIRE** | `getProductCategories` / `getProductSubcategories` | | Add-Product modal default price/stock | hardcoded | keep | form defaults | --- ## 4. OperationsView.tsx | UI element | Current source | Class | Target | |---|---|---|---| | Inventory value, low-stock count, SKU count | live `useFiestaStockStatement` | OK | β€” | | Fulfillment Health `98.4%` | hardcoded | **DERIVE** | from order/delivery summary | | Forecast Efficiency `92%`, Cost savings `β‚Ή1.9L/week` | hardcoded | **NEW API** | **[R7] forecasting/insights** (or remove until modelled) | | Catalogue table rows | live `stockRowToProduct` | OK | β€” | | "Global Inventory Count 4,200 nodes" | hardcoded | **WIRE** | `getProductsCount` | | Catalogue verification toggle | local state only | **NEW API** | product update PUT πŸ”΄ (REVIEW_REQUIRED) | | Import logs table | mock `data.ts` | **NEW API** | **[R4]** (same as Inventory) | | Schema-validator messages ("14 duplicate SKUs") | hardcoded | **NEW API** | **[R4]** import validation result | | Add-SKU / Transfer-Stock modals | local state mutation | **NEW API** | stock entry POST πŸ”΄ + **[R8] stock transfer** | --- ## 5. OrdersDeliveriesView.tsx | UI element | Current source | Class | Target | |---|---|---|---| | KPI tiles (deliveries in range, pending, completed, fleet) | live `useFiestaDeliveries` | OK | β€” | | Date presets / range | client state | OK | β€” | | Order list rows | live `deliveryRowToOrder` | OK | β€” | | **Order line items** (`items: []` always empty) | empty / itemCount only | **WIRE** | **`orderdetails?orderheaderid=`** 🟑 (exists!) | | "Create Simulated Order" + MOCK_NAMES/STREETS/ITEMS | hardcoded generator | **NEW API** | replace with real Create-Order POST πŸ”΄, or remove button | | Rider cards | live `useFiestaRiders` | OK | β€” | | Rider `rating 4.7` | hardcoded in mapper | **NEW API** | **[R9] rider telemetry/rating** | | Rider avatars | rotated stock photos | **WIRE** | user photo field if present, else keep placeholder | | GPS route SVG, "9 MINS", "1.2 km left", "GPS ACTIVE" | hardcoded | **NEW API** | **[R9]** live rider GPS/ETA | | Status-progression buttons (pack/dispatch/deliver) | local state | **NEW API** | order/delivery status PUT πŸ”΄ (REVIEW_REQUIRED) | | Assign-rider action | local state | **NEW API** | assign-rider POST πŸ”΄ (REVIEW_REQUIRED) | --- ## 6. StoreDetailView.tsx | UI element | Current source | Class | Target | |---|---|---|---| | Inventory tab list | live `useFiestaStockStatement` + mock fallback | **WIRE** | remove hardcoded fallback array | | Customers tab list | live `useFiestaTenantCustomers` + mock fallback | **WIRE** | remove hardcoded fallback array | | `intervalSlots` dispatch pipeline (morning rush %, etc.) | computed from `store.deliveries`Γ—% | **NEW API** | **[R10] intraday dispatch buckets** | | `pastDaysLog` 7-day ledger | computed Γ—multipliers | **NEW API** | **[R2]** daily series per location | | KPI cards (OTIF 98.2%, est revenue, dispatches, active fleet) | hardcoded/derived | **WIRE/NEW** | OTIF & revenue need [R1]; fleet via `getRiders` | | `activeRiders` (battery, lastPing) | hardcoded | **NEW API** | **[R9]** rider telemetry | | Customer CRM order history (3 orders) | hardcoded | **WIRE** | `orders?customerid=` 🟑 | | Customer CRM metrics (CSAT 5.0) | hardcoded | **NEW API** | **[R11] customer analytics** (CSAT/AOV/retention) | | Customer search metrics (retention 88.4%, AOV β‚Ή1,580, CSAT 4.9) | hardcoded | **NEW API** | **[R11]** | | `GLOBAL_CATALOGUE_ITEMS` modal | hardcoded | **WIRE** | master catalog listings 🟑 | | `resolveMetadata` price/image keyword map | hardcoded | **NEW API** | **[R3]** product image/price from catalog | | Store cover images | hardcoded array | keep | cosmetic asset set | | `operationalAlerts` (filtered by store) | mock `data.ts` | **NEW API** | **[R12] operational alerts** | | CSV import simulation, Global-catalogue add | local mutation | **NEW API** | stock entry POST πŸ”΄ | --- ## 7. SettingsView.tsx | UI element | Current source | Class | Target | |---|---|---|---| | Merchant ID card / registration info | live `useFiestaAllTenants` | OK | β€” | | Outlets tab cards | live `useFiestaTenantLocations` | OK | β€” | | `LOCAL_OUTLETS_DATA` fallback | hardcoded | **WIRE** | remove fallback once locations confirmed live | | `DEFAULTS` settings (min order, delivery charge, prep mins, tax, COD…) | hardcoded + localStorage | **NEW API** | **[R6] merchant settings** GET+PUT (some fields exist on tenant: minorder, paymenttype) | | Role dropdown options | hardcoded `[1,2,3,4,6]` | **WIRE** | `getAppRoles` | --- ## 8. UsersPanel.tsx | UI element | Current source | Class | Target | |---|---|---|---| | User directory | live `useFiestaUsers` | OK | β€” | | Create user | live `useFiestaCreateUser` | OK | β€” | | `USER_AVATARS` rotation | hardcoded | keep/WIRE | use user photo field if API has one | | `ROLE_THEMES` styling | hardcoded | keep | cosmetic | | Add-user modal role list | hardcoded | **WIRE** | `getAppRoles` | --- ## 9. App.tsx / Header / Sidebar / UserPage | UI element | Current source | Class | Target | |---|---|---|---| | Store registry cards | live `useFiestaTenantLocations` + `useFiestaLocationSummary` | OK | β€” | | `STORE_COVERS` images | hardcoded (hash-picked) | keep | cosmetic | | Add-store modal | local; needs onboard POST | **NEW API** | tenant/location onboard πŸ”΄ (REVIEW_REQUIRED) | | Scheduled-reports calendar (3 events) | hardcoded | **NEW API** | **[R13] scheduled reports** (or drop feature) | | Header/UserPage profile | live `authUser` | OK | β€” | | Sidebar nav items | hardcoded | keep | static nav config | --- ## Summary of backend work required | Id | New API | Blocks | |---|---|---| | **[R1]** | Revenue summary (tenant + per-location, period) | Reports revenue KPI, leaderboard revenue, OTIF revenue, Dashboard cross-check | | **[R2]** | Orders/revenue time-series (day/month/year, by region) | Reports main chart, 7-day ledger | | **[R3]** | Product sales analytics + product meta (units sold, revenue, bin, image) | Product matrix, catalogue metadata | | **[R4]** | Import / sync audit log + validation | Inventory & Operations import tabs | | **[R5]** | Catalog presets (optional) | Inventory presets | | **[R6]** | Merchant settings + branding config (GET/PUT) | Settings, Brand Studio | | **[R7]** | Forecast / efficiency insights (optional) | Operations forecast panel | | **[R8]** | Stock transfer (POST) | Operations transfer modal | | **[R9]** | Rider telemetry (rating, battery, GPS, ETA) | Orders fleet, GPS tracker, StoreDetail riders | | **[R10]** | Intraday dispatch buckets | StoreDetail dispatch pipeline | | **[R11]** | Customer analytics (CSAT/AOV/retention) | StoreDetail CRM metrics | | **[R12]** | Operational alerts feed | StoreDetail / dashboard alerts | | **[R13]** | Scheduled reports (optional) | Reports calendar | Plus mutation routes already in the sheet but marked πŸ”΄ REVIEW_REQUIRED (order create/status, delivery assign/status, product create/update, tenant onboard, stock entry) β€” backend must confirm request/response before wiring.