@burdenoff/microfe-kadaikodi 2026.704.2 → 2026.704.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,13 +20,14 @@ function E() {
20
20
  ordersToday: N.filter((e) => new Date(e.orderDate).getTime() >= i.getTime()).length,
21
21
  avgOrderValue: D && D.totalOrders > 0 ? D.totalRevenue / D.totalOrders : 0
22
22
  };
23
- }, [N, D]), B = l(() => j.filter((e) => !e.isOpen).length, [j]), V = l(() => {
24
- let e = k?.revenueByCategory ?? [], t = e.reduce((e, t) => e + t.revenue, 0);
25
- return e.map((e) => ({
26
- ...e,
27
- percentage: t > 0 ? e.revenue / t * 100 : 0
28
- }));
29
- }, [k]), H = k?.topProviders ?? [], U = k?.customerGrowth ?? [], W = k?.categoryDistribution ?? [], G = (e, t) => t > 0 ? e / t * 100 : 0, K = (e) => e < 3 ? /* @__PURE__ */ x(d, { className: "h-5 w-5 text-status-warning-text" }) : /* @__PURE__ */ x(f, { className: "h-5 w-5 text-text-secondary" });
23
+ }, [N, D]), B = l(() => j.filter((e) => !e.isOpen).length, [j]), V = k?.topProviders ?? [], H = k?.customerGrowth?.customers ?? 0, U = l(() => {
24
+ let e = Object.entries(k?.categoryDistribution ?? {}), t = e.reduce((e, [, t]) => e + t, 0);
25
+ return e.map(([e, n]) => ({
26
+ category: e,
27
+ count: n,
28
+ percentage: t > 0 ? n / t * 100 : 0
29
+ })).sort((e, t) => t.count - e.count);
30
+ }, [k]), W = (e) => e.replace(/_/g, " ").toLowerCase(), G = (e, t) => t > 0 ? e / t * 100 : 0, K = (e) => e < 3 ? /* @__PURE__ */ x(d, { className: "h-5 w-5 text-status-warning-text" }) : /* @__PURE__ */ x(f, { className: "h-5 w-5 text-text-secondary" });
30
31
  if (L || !D) return /* @__PURE__ */ x(n, {
31
32
  title: "Platform Analytics",
32
33
  description: "Loading analytics...",
@@ -116,17 +117,17 @@ function E() {
116
117
  }),
117
118
  /* @__PURE__ */ x(r, {
118
119
  icon: /* @__PURE__ */ x(h, { className: "h-5 w-5" }),
119
- value: D.totalOrders.toLocaleString("en-IN"),
120
+ value: (D.totalOrders ?? 0).toLocaleString("en-IN"),
120
121
  label: "Total Orders"
121
122
  }),
122
123
  /* @__PURE__ */ x(r, {
123
124
  icon: /* @__PURE__ */ x(y, { className: "h-5 w-5" }),
124
- value: D.activeCustomers.toLocaleString("en-IN"),
125
+ value: (D.activeCustomers ?? 0).toLocaleString("en-IN"),
125
126
  label: "Active Customers"
126
127
  }),
127
128
  /* @__PURE__ */ x(r, {
128
129
  icon: /* @__PURE__ */ x(_, { className: "h-5 w-5" }),
129
- value: D.activeProviders.toLocaleString("en-IN"),
130
+ value: (D.activeProviders ?? 0).toLocaleString("en-IN"),
130
131
  label: "Active Carts",
131
132
  trendValue: `${B} pending`
132
133
  })
@@ -221,7 +222,7 @@ function E() {
221
222
  })] }), /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("h3", {
222
223
  className: "text-lg font-semibold text-text-primary mb-4",
223
224
  children: "Top Performing Carts"
224
- }), H.length > 0 ? /* @__PURE__ */ x("div", {
225
+ }), V.length > 0 ? /* @__PURE__ */ x("div", {
225
226
  className: "rounded-lg border border-border-subtle overflow-hidden",
226
227
  children: /* @__PURE__ */ S("table", {
227
228
  className: "w-full",
@@ -233,12 +234,8 @@ function E() {
233
234
  children: "Cart Name"
234
235
  }),
235
236
  /* @__PURE__ */ x("th", {
236
- className: "px-4 py-3 text-right text-xs font-medium text-text-secondary uppercase",
237
- children: "Revenue"
238
- }),
239
- /* @__PURE__ */ x("th", {
240
- className: "px-4 py-3 text-right text-xs font-medium text-text-secondary uppercase",
241
- children: "Orders"
237
+ className: "px-4 py-3 text-left text-xs font-medium text-text-secondary uppercase",
238
+ children: "Category"
242
239
  }),
243
240
  /* @__PURE__ */ x("th", {
244
241
  className: "px-4 py-3 text-right text-xs font-medium text-text-secondary uppercase",
@@ -247,7 +244,7 @@ function E() {
247
244
  ]
248
245
  }) }), /* @__PURE__ */ x("tbody", {
249
246
  className: "divide-y divide-border",
250
- children: H.map((e, t) => /* @__PURE__ */ S("tr", {
247
+ children: V.map((e, t) => /* @__PURE__ */ S("tr", {
251
248
  className: "hover:bg-accent/50 transition-colors",
252
249
  children: [
253
250
  /* @__PURE__ */ x("td", {
@@ -261,18 +258,14 @@ function E() {
261
258
  })
262
259
  }),
263
260
  /* @__PURE__ */ x("td", {
264
- className: "px-4 py-3 text-sm text-right font-medium text-text-primary",
265
- children: R(e.revenue)
266
- }),
267
- /* @__PURE__ */ x("td", {
268
- className: "px-4 py-3 text-sm text-right text-text-primary",
269
- children: e.orders.toLocaleString("en-IN")
261
+ className: "px-4 py-3 text-sm text-left text-text-secondary capitalize",
262
+ children: W(e.category)
270
263
  }),
271
264
  /* @__PURE__ */ x("td", {
272
265
  className: "px-4 py-3 text-sm text-right text-text-primary",
273
266
  children: /* @__PURE__ */ S("span", {
274
267
  className: "flex items-center justify-end gap-1",
275
- children: [/* @__PURE__ */ x(g, { className: "h-3.5 w-3.5 fill-status-warning-text text-status-warning-text" }), e.rating.toFixed(1)]
268
+ children: [/* @__PURE__ */ x(g, { className: "h-3.5 w-3.5 fill-status-warning-text text-status-warning-text" }), (e.rating ?? 0).toFixed(1)]
276
269
  })
277
270
  })
278
271
  ]
@@ -306,7 +299,7 @@ function E() {
306
299
  children: "Total Orders"
307
300
  }), /* @__PURE__ */ x("p", {
308
301
  className: "text-2xl font-bold text-text-primary",
309
- children: D.totalOrders.toLocaleString("en-IN")
302
+ children: (D.totalOrders ?? 0).toLocaleString("en-IN")
310
303
  })]
311
304
  }),
312
305
  /* @__PURE__ */ S("div", {
@@ -320,37 +313,10 @@ function E() {
320
313
  })]
321
314
  })
322
315
  ]
323
- }), /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("h3", {
324
- className: "text-lg font-semibold text-text-primary mb-4",
325
- children: "Revenue by Category"
326
- }), V.length > 0 ? /* @__PURE__ */ x("div", {
327
- className: "space-y-3",
328
- children: V.map((e, t) => /* @__PURE__ */ S("div", {
329
- className: "flex items-center justify-between p-4 rounded-lg border border-border-subtle bg-bg-sunken/30",
330
- children: [/* @__PURE__ */ S("div", {
331
- className: "flex items-center gap-3",
332
- children: [K(t), /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("p", {
333
- className: "font-medium text-text-primary capitalize",
334
- children: e.category
335
- }), /* @__PURE__ */ S("p", {
336
- className: "text-sm text-text-secondary",
337
- children: [e.orders.toLocaleString("en-IN"), " orders"]
338
- })] })]
339
- }), /* @__PURE__ */ S("div", {
340
- className: "text-right",
341
- children: [/* @__PURE__ */ x("p", {
342
- className: "font-bold text-text-primary",
343
- children: R(e.revenue)
344
- }), /* @__PURE__ */ S("p", {
345
- className: "text-sm text-text-secondary",
346
- children: [e.percentage.toFixed(1), "%"]
347
- })]
348
- })]
349
- }, e.category))
350
- }) : /* @__PURE__ */ x("p", {
316
+ }), /* @__PURE__ */ x("p", {
351
317
  className: "text-sm text-text-secondary",
352
- children: "Category revenue will appear here once orders are recorded."
353
- })] })]
318
+ children: "Revenue is not broken down by category by the platform backend. See the Users tab for how carts are distributed across categories."
319
+ })]
354
320
  }),
355
321
  F === "users" && /* @__PURE__ */ S("div", {
356
322
  className: "space-y-8",
@@ -367,7 +333,7 @@ function E() {
367
333
  })]
368
334
  }), /* @__PURE__ */ x("p", {
369
335
  className: "text-3xl font-bold text-text-primary",
370
- children: D.activeCustomers.toLocaleString("en-IN")
336
+ children: (D.activeCustomers ?? 0).toLocaleString("en-IN")
371
337
  })]
372
338
  }), /* @__PURE__ */ S("div", {
373
339
  className: "rounded-lg border border-border-subtle bg-bg-sunken/30 p-6",
@@ -379,74 +345,46 @@ function E() {
379
345
  })]
380
346
  }), /* @__PURE__ */ x("p", {
381
347
  className: "text-3xl font-bold text-text-primary",
382
- children: D.activeProviders.toLocaleString("en-IN")
348
+ children: (D.activeProviders ?? 0).toLocaleString("en-IN")
383
349
  })]
384
350
  })]
385
351
  }),
386
352
  /* @__PURE__ */ S("div", {
387
353
  className: "rounded-lg border border-border-subtle bg-bg-sunken/20 p-6",
388
- children: [/* @__PURE__ */ x("h3", {
389
- className: "text-lg font-semibold text-text-primary mb-4",
390
- children: "Customer Growth"
391
- }), U.length > 0 ? /* @__PURE__ */ x("div", {
392
- className: "overflow-x-auto",
393
- children: /* @__PURE__ */ S("table", {
394
- className: "w-full",
395
- children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", {
396
- className: "border-b border-border-subtle",
397
- children: [
398
- /* @__PURE__ */ x("th", {
399
- className: "px-4 py-2 text-left text-xs font-medium text-text-secondary uppercase",
400
- children: "Month"
401
- }),
402
- /* @__PURE__ */ x("th", {
403
- className: "px-4 py-2 text-right text-xs font-medium text-text-secondary uppercase",
404
- children: "New Customers"
405
- }),
406
- /* @__PURE__ */ x("th", {
407
- className: "px-4 py-2 text-right text-xs font-medium text-text-secondary uppercase",
408
- children: "Total Customers"
409
- })
410
- ]
411
- }) }), /* @__PURE__ */ x("tbody", {
412
- className: "divide-y divide-border",
413
- children: U.map((e) => /* @__PURE__ */ S("tr", { children: [
414
- /* @__PURE__ */ x("td", {
415
- className: "px-4 py-2 text-sm font-medium text-text-primary",
416
- children: e.month
417
- }),
418
- /* @__PURE__ */ S("td", {
419
- className: "px-4 py-2 text-sm text-right text-text-primary",
420
- children: ["+", e.newCustomers.toLocaleString("en-IN")]
421
- }),
422
- /* @__PURE__ */ x("td", {
423
- className: "px-4 py-2 text-sm text-right text-text-primary",
424
- children: e.totalCustomers.toLocaleString("en-IN")
425
- })
426
- ] }, e.month))
354
+ children: [
355
+ /* @__PURE__ */ S("div", {
356
+ className: "flex items-center gap-2 mb-2",
357
+ children: [/* @__PURE__ */ x(y, { className: "h-5 w-5 text-text-secondary" }), /* @__PURE__ */ x("h3", {
358
+ className: "text-sm font-medium text-text-secondary",
359
+ children: "Total Customers"
427
360
  })]
361
+ }),
362
+ /* @__PURE__ */ x("p", {
363
+ className: "text-3xl font-bold text-text-primary",
364
+ children: H.toLocaleString("en-IN")
365
+ }),
366
+ /* @__PURE__ */ x("p", {
367
+ className: "mt-1 text-sm text-text-secondary",
368
+ children: "Customers on the platform to date."
428
369
  })
429
- }) : /* @__PURE__ */ x("p", {
430
- className: "text-sm text-text-secondary",
431
- children: "Customer growth trends will appear here as your customer base builds up."
432
- })]
370
+ ]
433
371
  }),
434
- W.length > 0 && /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("h3", {
372
+ U.length > 0 && /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("h3", {
435
373
  className: "text-lg font-semibold text-text-primary mb-4",
436
374
  children: "Cart Category Distribution"
437
375
  }), /* @__PURE__ */ x("div", {
438
376
  className: "space-y-3",
439
- children: W.map((e) => /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ S("div", {
377
+ children: U.map((e) => /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ S("div", {
440
378
  className: "flex items-center justify-between mb-1",
441
379
  children: [/* @__PURE__ */ x("span", {
442
380
  className: "text-sm font-medium text-text-primary capitalize",
443
- children: e.category
381
+ children: W(e.category)
444
382
  }), /* @__PURE__ */ S("span", {
445
383
  className: "text-sm text-text-secondary",
446
384
  children: [
447
- e.count.toLocaleString("en-IN"),
385
+ (e.count ?? 0).toLocaleString("en-IN"),
448
386
  " (",
449
- e.percentage.toFixed(1),
387
+ (e.percentage ?? 0).toFixed(1),
450
388
  "%)"
451
389
  ]
452
390
  })]
@@ -544,7 +482,7 @@ function E() {
544
482
  children: "Pending Orders"
545
483
  }), /* @__PURE__ */ x("p", {
546
484
  className: "text-3xl font-bold text-status-warning-text",
547
- children: D.pendingOrders.toLocaleString("en-IN")
485
+ children: (D.pendingOrders ?? 0).toLocaleString("en-IN")
548
486
  })] })]
549
487
  })]
550
488
  })]
@@ -1 +1 @@
1
- {"version":3,"file":"AdminAnalyticsPage.js","names":[],"sources":["../../../../src/kadaikodi/pages/admin/AdminAnalyticsPage.tsx"],"sourcesContent":["/**\n * Admin Analytics Page\n * @module kadaikodi/pages/admin\n *\n * Platform analytics wired to the live backend (useDashboardStats +\n * useAdminAnalytics + useProviders + useOrders). Every figure is real or\n * derived from real records — order-status distribution is counted from\n * loaded orders, category/growth breakdowns come from the analytics hook.\n * Metrics with no honest source (operating costs, delivery time, etc.) are\n * omitted rather than fabricated.\n */\n\nimport { useMemo, useState } from 'react';\nimport {\n Users,\n ShoppingBag,\n IndianRupee,\n BarChart3,\n Zap,\n Loader2,\n Star,\n Award,\n Store,\n TrendingUp,\n} from 'lucide-react';\nimport { EmphasisPanel, PagePurpose, NextSteps } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components/PageLayout';\nimport { MetricsCard } from '../../components/MetricsCard';\nimport { useKadaikodi } from '../../context/KadaikodiContext';\nimport {\n useDashboardStats,\n useAdminAnalytics,\n useProviders,\n useOrders,\n} from '../../hooks/useKadaikodiApi';\nimport { cn } from '../../utils/cn';\nimport { formatCurrency } from '../../utils/formatters';\n\n/* ------------------------------------------------------------------ */\n/* Types */\n/* ------------------------------------------------------------------ */\n\ntype TabKey = 'overview' | 'revenue' | 'users' | 'performance';\n\n/* ------------------------------------------------------------------ */\n/* Component */\n/* ------------------------------------------------------------------ */\n\nexport function AdminAnalyticsPage() {\n const { navigateTo } = useKadaikodi();\n\n const { data: stats, isLoading: statsLoading } = useDashboardStats();\n const { data: analytics, isLoading: analyticsLoading } = useAdminAnalytics();\n const { data: providers = [], isLoading: providersLoading } = useProviders();\n const { data: orders = [], isLoading: ordersLoading } = useOrders({});\n\n const [activeTab, setActiveTab] = useState<TabKey>('overview');\n\n const loading = statsLoading || analyticsLoading || providersLoading || ordersLoading;\n\n const fmtCur = (amount: number) => {\n if (amount >= 10000000) return `₹${(amount / 10000000).toFixed(1)}Cr`;\n if (amount >= 100000) return `₹${(amount / 100000).toFixed(1)}L`;\n return formatCurrency(amount, { minimumFractionDigits: 0 });\n };\n\n // Order status distribution — counted from real loaded orders.\n const orderStats = useMemo(() => {\n const total = orders.length;\n const completed = orders.filter((o) => o.status === 'delivered').length;\n const cancelled = orders.filter((o) => o.status === 'cancelled').length;\n const pending = orders.filter(\n (o) => o.status === 'pending' || o.status === 'confirmed'\n ).length;\n const startOfToday = new Date();\n startOfToday.setHours(0, 0, 0, 0);\n const ordersToday = orders.filter(\n (o) => new Date(o.orderDate).getTime() >= startOfToday.getTime()\n ).length;\n const avgOrderValue = stats && stats.totalOrders > 0 ? stats.totalRevenue / stats.totalOrders : 0;\n return { total, completed, cancelled, pending, ordersToday, avgOrderValue };\n }, [orders, stats]);\n\n const pendingCarts = useMemo(() => providers.filter((p) => !p.isOpen).length, [providers]);\n\n const categoryRows = useMemo(() => {\n const rows = analytics?.revenueByCategory ?? [];\n const total = rows.reduce((sum, r) => sum + r.revenue, 0);\n return rows.map((r) => ({ ...r, percentage: total > 0 ? (r.revenue / total) * 100 : 0 }));\n }, [analytics]);\n\n const topCarts = analytics?.topProviders ?? [];\n const customerGrowth = analytics?.customerGrowth ?? [];\n const categoryDistribution = analytics?.categoryDistribution ?? [];\n\n const pct = (part: number, whole: number) => (whole > 0 ? (part / whole) * 100 : 0);\n\n const medalIcon = (index: number) => {\n if (index < 3) return <Award className=\"h-5 w-5 text-status-warning-text\" />;\n return <BarChart3 className=\"h-5 w-5 text-text-secondary\" />;\n };\n\n if (loading || !stats) {\n return (\n <PageLayout title=\"Platform Analytics\" description=\"Loading analytics...\">\n <div className=\"flex flex-col items-center justify-center py-20\">\n <Loader2 className=\"h-10 w-10 animate-spin text-text-secondary mb-4\" />\n <p className=\"text-text-secondary\">Loading analytics...</p>\n </div>\n </PageLayout>\n );\n }\n\n const tabs: Array<{ key: TabKey; label: string; icon: typeof BarChart3 }> = [\n { key: 'overview', label: 'Overview', icon: BarChart3 },\n { key: 'revenue', label: 'Revenue', icon: IndianRupee },\n { key: 'users', label: 'Users', icon: Users },\n { key: 'performance', label: 'Performance', icon: Zap },\n ];\n\n return (\n <PageLayout title=\"Platform Analytics\" description=\"Comprehensive platform metrics and trends\">\n <PagePurpose className=\"mb-6\">\n Your bird&apos;s-eye view of how Kadaikodi is performing. Spot revenue and order trends, see\n which carts and categories drive the most business, and understand where customers are\n growing — so you can decide where to invest and which carts to promote. Switch tabs to drill\n into revenue, users, and operational performance.\n </PagePurpose>\n\n <NextSteps\n storageKey=\"kadaikodi-admin-analytics\"\n className=\"mb-6\"\n steps={[\n {\n id: 'review-carts',\n label: 'Review top-performing carts',\n description: 'See which carts drive the most revenue and orders.',\n onClick: () => setActiveTab('overview'),\n },\n {\n id: 'check-revenue',\n label: 'Break down revenue by category',\n description: 'Find your strongest categories in the Revenue tab.',\n onClick: () => setActiveTab('revenue'),\n },\n {\n id: 'manage-carts',\n label: 'Approve pending carts',\n description: 'Onboard the carts waiting for review.',\n onClick: () => navigateTo('/admin/carts'),\n done: pendingCarts === 0,\n },\n ]}\n />\n\n <div className=\"flex justify-end mb-6\">\n <span className=\"text-sm text-text-secondary\">\n Last updated: {new Date().toLocaleString('en-IN')}\n </span>\n </div>\n\n {/* Key Metrics — the one emphasis zone for this page */}\n <EmphasisPanel className=\"mb-8\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">Key Metrics</h2>\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4\">\n <MetricsCard\n featured\n icon={<IndianRupee className=\"h-5 w-5\" />}\n value={fmtCur(stats.totalRevenue)}\n label=\"Total Revenue\"\n />\n <MetricsCard\n icon={<ShoppingBag className=\"h-5 w-5\" />}\n value={stats.totalOrders.toLocaleString('en-IN')}\n label=\"Total Orders\"\n />\n <MetricsCard\n icon={<Users className=\"h-5 w-5\" />}\n value={stats.activeCustomers.toLocaleString('en-IN')}\n label=\"Active Customers\"\n />\n <MetricsCard\n icon={<Store className=\"h-5 w-5\" />}\n value={stats.activeProviders.toLocaleString('en-IN')}\n label=\"Active Carts\"\n trendValue={`${pendingCarts} pending`}\n />\n </div>\n </EmphasisPanel>\n\n {/* Tabs */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface mb-8\">\n <div className=\"border-b border-border-subtle\">\n <nav className=\"flex -mb-px overflow-x-auto\">\n {tabs.map((tab) => {\n const TabIcon = tab.icon;\n return (\n <button\n key={tab.key}\n type=\"button\"\n onClick={() => setActiveTab(tab.key)}\n className={cn(\n 'flex items-center gap-2 py-3 px-4 sm:px-6 text-sm font-medium whitespace-nowrap border-b-2 transition-colors',\n activeTab === tab.key\n ? 'border-primary text-primary'\n : 'border-transparent text-text-secondary hover:text-text-primary'\n )}\n >\n <TabIcon className=\"h-4 w-4\" />\n <span className=\"hidden sm:inline\">{tab.label}</span>\n </button>\n );\n })}\n </nav>\n </div>\n\n <div className=\"p-4 sm:p-6\">\n {/* Overview Tab */}\n {activeTab === 'overview' && (\n <div className=\"space-y-8\">\n <div>\n <h3 className=\"text-lg font-semibold text-text-primary mb-4\">\n Order Status Distribution\n </h3>\n {orderStats.total > 0 ? (\n <div className=\"grid grid-cols-1 sm:grid-cols-3 gap-4\">\n <div className=\"rounded-lg border border-status-success-text/30 bg-status-success-bg-subtle p-4\">\n <p className=\"text-sm text-status-success-text\">Completed Orders</p>\n <p className=\"text-2xl font-bold text-status-success-text\">\n {orderStats.completed.toLocaleString('en-IN')}\n </p>\n <p className=\"text-sm text-status-success-text/80\">\n {pct(orderStats.completed, orderStats.total).toFixed(1)}% of total\n </p>\n </div>\n <div className=\"rounded-lg border border-status-warning-text/30 bg-status-warning-bg-subtle p-4\">\n <p className=\"text-sm text-status-warning-text\">Pending Orders</p>\n <p className=\"text-2xl font-bold text-status-warning-text\">\n {orderStats.pending.toLocaleString('en-IN')}\n </p>\n <p className=\"text-sm text-status-warning-text/80\">\n {pct(orderStats.pending, orderStats.total).toFixed(1)}% of total\n </p>\n </div>\n <div className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle p-4\">\n <p className=\"text-sm text-status-error-text\">Cancelled Orders</p>\n <p className=\"text-2xl font-bold text-status-error-text\">\n {orderStats.cancelled.toLocaleString('en-IN')}\n </p>\n <p className=\"text-sm text-status-error-text/80\">\n {pct(orderStats.cancelled, orderStats.total).toFixed(1)}% of total\n </p>\n </div>\n </div>\n ) : (\n <p className=\"text-sm text-text-secondary\">\n Order breakdowns will appear here once orders are placed.\n </p>\n )}\n </div>\n\n <div>\n <h3 className=\"text-lg font-semibold text-text-primary mb-4\">Top Performing Carts</h3>\n {topCarts.length > 0 ? (\n <div className=\"rounded-lg border border-border-subtle overflow-hidden\">\n <table className=\"w-full\">\n <thead>\n <tr className=\"border-b border-border-subtle bg-bg-sunken/50\">\n <th className=\"px-4 py-3 text-left text-xs font-medium text-text-secondary uppercase\">\n Cart Name\n </th>\n <th className=\"px-4 py-3 text-right text-xs font-medium text-text-secondary uppercase\">\n Revenue\n </th>\n <th className=\"px-4 py-3 text-right text-xs font-medium text-text-secondary uppercase\">\n Orders\n </th>\n <th className=\"px-4 py-3 text-right text-xs font-medium text-text-secondary uppercase\">\n Rating\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border\">\n {topCarts.map((cart, i) => (\n <tr key={cart.id} className=\"hover:bg-accent/50 transition-colors\">\n <td className=\"px-4 py-3\">\n <div className=\"flex items-center gap-2\">\n {medalIcon(i)}\n <span className=\"text-sm font-medium text-text-primary\">\n {cart.name}\n </span>\n </div>\n </td>\n <td className=\"px-4 py-3 text-sm text-right font-medium text-text-primary\">\n {fmtCur(cart.revenue)}\n </td>\n <td className=\"px-4 py-3 text-sm text-right text-text-primary\">\n {cart.orders.toLocaleString('en-IN')}\n </td>\n <td className=\"px-4 py-3 text-sm text-right text-text-primary\">\n <span className=\"flex items-center justify-end gap-1\">\n <Star className=\"h-3.5 w-3.5 fill-status-warning-text text-status-warning-text\" />\n {cart.rating.toFixed(1)}\n </span>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n ) : (\n <p className=\"text-sm text-text-secondary\">\n Top-performing carts will be ranked here once orders start flowing.\n </p>\n )}\n </div>\n </div>\n )}\n\n {/* Revenue Tab */}\n {activeTab === 'revenue' && (\n <div className=\"space-y-8\">\n <div className=\"grid grid-cols-1 md:grid-cols-3 gap-4\">\n <div className=\"rounded-lg border border-border-focus/30 bg-[var(--color-accent-soft)] p-6\">\n <h4 className=\"text-sm font-medium text-text-primary mb-2\">Total Revenue</h4>\n <p className=\"text-2xl font-bold text-text-primary\">\n {fmtCur(stats.totalRevenue)}\n </p>\n </div>\n <div className=\"rounded-lg border border-border-subtle bg-bg-sunken/30 p-6\">\n <h4 className=\"text-sm font-medium text-text-secondary mb-2\">Total Orders</h4>\n <p className=\"text-2xl font-bold text-text-primary\">\n {stats.totalOrders.toLocaleString('en-IN')}\n </p>\n </div>\n <div className=\"rounded-lg border border-status-success-text/30 bg-status-success-bg-subtle p-6\">\n <h4 className=\"text-sm font-medium text-status-success-text mb-2\">\n Average Order Value\n </h4>\n <p className=\"text-2xl font-bold text-status-success-text\">\n {fmtCur(orderStats.avgOrderValue)}\n </p>\n </div>\n </div>\n\n <div>\n <h3 className=\"text-lg font-semibold text-text-primary mb-4\">Revenue by Category</h3>\n {categoryRows.length > 0 ? (\n <div className=\"space-y-3\">\n {categoryRows.map((row, i) => (\n <div\n key={row.category}\n className=\"flex items-center justify-between p-4 rounded-lg border border-border-subtle bg-bg-sunken/30\"\n >\n <div className=\"flex items-center gap-3\">\n {medalIcon(i)}\n <div>\n <p className=\"font-medium text-text-primary capitalize\">\n {row.category}\n </p>\n <p className=\"text-sm text-text-secondary\">\n {row.orders.toLocaleString('en-IN')} orders\n </p>\n </div>\n </div>\n <div className=\"text-right\">\n <p className=\"font-bold text-text-primary\">{fmtCur(row.revenue)}</p>\n <p className=\"text-sm text-text-secondary\">\n {row.percentage.toFixed(1)}%\n </p>\n </div>\n </div>\n ))}\n </div>\n ) : (\n <p className=\"text-sm text-text-secondary\">\n Category revenue will appear here once orders are recorded.\n </p>\n )}\n </div>\n </div>\n )}\n\n {/* Users Tab */}\n {activeTab === 'users' && (\n <div className=\"space-y-8\">\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-sunken/30 p-6\">\n <div className=\"flex items-center gap-2 mb-2\">\n <Users className=\"h-5 w-5 text-text-secondary\" />\n <h4 className=\"text-sm font-medium text-text-secondary\">Active Customers</h4>\n </div>\n <p className=\"text-3xl font-bold text-text-primary\">\n {stats.activeCustomers.toLocaleString('en-IN')}\n </p>\n </div>\n <div className=\"rounded-lg border border-border-subtle bg-bg-sunken/30 p-6\">\n <div className=\"flex items-center gap-2 mb-2\">\n <Store className=\"h-5 w-5 text-text-secondary\" />\n <h4 className=\"text-sm font-medium text-text-secondary\">Active Cart Owners</h4>\n </div>\n <p className=\"text-3xl font-bold text-text-primary\">\n {stats.activeProviders.toLocaleString('en-IN')}\n </p>\n </div>\n </div>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-sunken/20 p-6\">\n <h3 className=\"text-lg font-semibold text-text-primary mb-4\">Customer Growth</h3>\n {customerGrowth.length > 0 ? (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full\">\n <thead>\n <tr className=\"border-b border-border-subtle\">\n <th className=\"px-4 py-2 text-left text-xs font-medium text-text-secondary uppercase\">\n Month\n </th>\n <th className=\"px-4 py-2 text-right text-xs font-medium text-text-secondary uppercase\">\n New Customers\n </th>\n <th className=\"px-4 py-2 text-right text-xs font-medium text-text-secondary uppercase\">\n Total Customers\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border\">\n {customerGrowth.map((row) => (\n <tr key={row.month}>\n <td className=\"px-4 py-2 text-sm font-medium text-text-primary\">\n {row.month}\n </td>\n <td className=\"px-4 py-2 text-sm text-right text-text-primary\">\n +{row.newCustomers.toLocaleString('en-IN')}\n </td>\n <td className=\"px-4 py-2 text-sm text-right text-text-primary\">\n {row.totalCustomers.toLocaleString('en-IN')}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n ) : (\n <p className=\"text-sm text-text-secondary\">\n Customer growth trends will appear here as your customer base builds up.\n </p>\n )}\n </div>\n\n {categoryDistribution.length > 0 && (\n <div>\n <h3 className=\"text-lg font-semibold text-text-primary mb-4\">\n Cart Category Distribution\n </h3>\n <div className=\"space-y-3\">\n {categoryDistribution.map((row) => (\n <div key={row.category}>\n <div className=\"flex items-center justify-between mb-1\">\n <span className=\"text-sm font-medium text-text-primary capitalize\">\n {row.category}\n </span>\n <span className=\"text-sm text-text-secondary\">\n {row.count.toLocaleString('en-IN')} ({row.percentage.toFixed(1)}%)\n </span>\n </div>\n <div className=\"w-full bg-bg-sunken rounded-full h-2\">\n <div\n className=\"bg-action-primary-bg h-2 rounded-full transition-all duration-300\"\n style={{ width: `${row.percentage}%` }}\n />\n </div>\n </div>\n ))}\n </div>\n </div>\n )}\n </div>\n )}\n\n {/* Performance Tab */}\n {activeTab === 'performance' && (\n <div className=\"space-y-8\">\n <div className=\"grid grid-cols-1 md:grid-cols-3 gap-6\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <div className=\"flex items-center gap-2 mb-2\">\n <Star className=\"h-4 w-4 text-text-secondary\" />\n <h4 className=\"text-sm font-medium text-text-secondary\">\n Customer Satisfaction\n </h4>\n </div>\n <p className=\"text-3xl font-bold text-text-primary flex items-center gap-1\">\n <Star className=\"h-6 w-6 fill-status-warning-text text-status-warning-text\" />\n {stats.avgRating > 0 ? stats.avgRating.toFixed(1) : '—'}\n </p>\n <p className=\"text-sm text-text-secondary mt-1\">Average rating across carts</p>\n </div>\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <div className=\"flex items-center gap-2 mb-2\">\n <TrendingUp className=\"h-4 w-4 text-text-secondary\" />\n <h4 className=\"text-sm font-medium text-text-secondary\">Completion Rate</h4>\n </div>\n <p className=\"text-3xl font-bold text-text-primary\">\n {orderStats.total > 0\n ? `${pct(orderStats.completed, orderStats.total).toFixed(1)}%`\n : '—'}\n </p>\n <p className=\"text-sm text-text-secondary mt-1\">Orders delivered</p>\n </div>\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <div className=\"flex items-center gap-2 mb-2\">\n <BarChart3 className=\"h-4 w-4 text-text-secondary\" />\n <h4 className=\"text-sm font-medium text-text-secondary\">Cancellation Rate</h4>\n </div>\n <p className=\"text-3xl font-bold text-text-primary\">\n {orderStats.total > 0\n ? `${pct(orderStats.cancelled, orderStats.total).toFixed(1)}%`\n : '—'}\n </p>\n <p className=\"text-sm text-text-secondary mt-1\">Orders cancelled</p>\n </div>\n </div>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-lg font-semibold text-text-primary mb-4\">Today&apos;s Activity</h3>\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-6\">\n <div>\n <p className=\"text-sm text-text-secondary mb-2\">Orders Today</p>\n <p className=\"text-3xl font-bold text-text-primary\">\n {orderStats.ordersToday.toLocaleString('en-IN')}\n </p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary mb-2\">Pending Orders</p>\n <p className=\"text-3xl font-bold text-status-warning-text\">\n {stats.pendingOrders.toLocaleString('en-IN')}\n </p>\n </div>\n </div>\n </div>\n </div>\n )}\n </div>\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;AAgDA,SAAgB,IAAqB;CACnC,IAAM,EAAE,kBAAe,GAAc,EAE/B,EAAE,MAAM,GAAO,WAAW,MAAiB,GAAmB,EAC9D,EAAE,MAAM,GAAW,WAAW,MAAqB,GAAmB,EACtE,EAAE,MAAM,IAAY,EAAE,EAAE,WAAW,MAAqB,GAAc,EACtE,EAAE,MAAM,IAAS,EAAE,EAAE,WAAW,MAAkB,EAAU,EAAE,CAAC,EAE/D,CAAC,GAAW,KAAgB,EAAiB,WAAW,EAExD,IAAU,KAAgB,KAAoB,KAAoB,GAElE,KAAU,MACV,KAAU,MAAiB,KAAK,IAAS,KAAU,QAAQ,EAAE,CAAC,MAC9D,KAAU,MAAe,KAAK,IAAS,K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f,CACE,kBAAC,GAAD,EAAW,WAAU,+BAAgC,CAAA,EACrD,kBAAC,MAAD;aAAI,WAAU;uBAA0C;aAAsB,CAAA,CAC1E;;WACN,kBAAC,KAAD;YAAG,WAAU;sBACV,EAAW,QAAQ,IAChB,GAAG,EAAI,EAAW,WAAW,EAAW,MAAM,CAAC,QAAQ,EAAE,CAAC,KAC1D;YACF,CAAA;WACJ,kBAAC,KAAD;YAAG,WAAU;sBAAmC;YAAoB,CAAA;WAChE;;SACF;WAEN,kBAAC,OAAD;QAAK,WAAU;kBAAf,CACE,kBAAC,MAAD;SAAI,WAAU;mBAA+C;SAA0B,CAAA,EACvF,kBAAC,OAAD;SAAK,WAAU;mBAAf,CACE,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,KAAD;UAAG,WAAU;oBAAmC;UAAgB,CAAA,EAChE,kBAAC,KAAD;UAAG,WAAU;oBACV,EAAW,YAAY,eAAe,QAAQ;UAC7C,CAAA,CACA,EAAA,CAAA,EACN,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,KAAD;UAAG,WAAU;oBAAmC;UAAkB,CAAA,EAClE,kBAAC,KAAD;UAAG,WAAU;oBACV,EAAM,cAAc,eAAe,QAAQ;UAC1C,CAAA,CACA,EAAA,CAAA,CACF;WACF;UACF;;MAEJ;OACF;;GACK"}
1
+ {"version":3,"file":"AdminAnalyticsPage.js","names":[],"sources":["../../../../src/kadaikodi/pages/admin/AdminAnalyticsPage.tsx"],"sourcesContent":["/**\n * Admin Analytics Page\n * @module kadaikodi/pages/admin\n *\n * Platform analytics wired to the live backend (useDashboardStats +\n * useAdminAnalytics + useProviders + useOrders). Every figure is real or\n * derived from real records — order-status distribution is counted from\n * loaded orders, category/growth breakdowns come from the analytics hook.\n * Metrics with no honest source (operating costs, delivery time, etc.) are\n * omitted rather than fabricated.\n */\n\nimport { useMemo, useState } from 'react';\nimport {\n Users,\n ShoppingBag,\n IndianRupee,\n BarChart3,\n Zap,\n Loader2,\n Star,\n Award,\n Store,\n TrendingUp,\n} from 'lucide-react';\nimport { EmphasisPanel, PagePurpose, NextSteps } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components/PageLayout';\nimport { MetricsCard } from '../../components/MetricsCard';\nimport { useKadaikodi } from '../../context/KadaikodiContext';\nimport {\n useDashboardStats,\n useAdminAnalytics,\n useProviders,\n useOrders,\n} from '../../hooks/useKadaikodiApi';\nimport { cn } from '../../utils/cn';\nimport { formatCurrency } from '../../utils/formatters';\n\n/* ------------------------------------------------------------------ */\n/* Types */\n/* ------------------------------------------------------------------ */\n\ntype TabKey = 'overview' | 'revenue' | 'users' | 'performance';\n\n/* ------------------------------------------------------------------ */\n/* Component */\n/* ------------------------------------------------------------------ */\n\nexport function AdminAnalyticsPage() {\n const { navigateTo } = useKadaikodi();\n\n const { data: stats, isLoading: statsLoading } = useDashboardStats();\n const { data: analytics, isLoading: analyticsLoading } = useAdminAnalytics();\n const { data: providers = [], isLoading: providersLoading } = useProviders();\n const { data: orders = [], isLoading: ordersLoading } = useOrders({});\n\n const [activeTab, setActiveTab] = useState<TabKey>('overview');\n\n const loading = statsLoading || analyticsLoading || providersLoading || ordersLoading;\n\n const fmtCur = (amount: number) => {\n if (amount >= 10000000) return `₹${(amount / 10000000).toFixed(1)}Cr`;\n if (amount >= 100000) return `₹${(amount / 100000).toFixed(1)}L`;\n return formatCurrency(amount, { minimumFractionDigits: 0 });\n };\n\n // Order status distribution — counted from real loaded orders.\n const orderStats = useMemo(() => {\n const total = orders.length;\n const completed = orders.filter((o) => o.status === 'delivered').length;\n const cancelled = orders.filter((o) => o.status === 'cancelled').length;\n const pending = orders.filter((o) => o.status === 'pending' || o.status === 'confirmed').length;\n const startOfToday = new Date();\n startOfToday.setHours(0, 0, 0, 0);\n const ordersToday = orders.filter(\n (o) => new Date(o.orderDate).getTime() >= startOfToday.getTime()\n ).length;\n const avgOrderValue =\n stats && stats.totalOrders > 0 ? stats.totalRevenue / stats.totalOrders : 0;\n return { total, completed, cancelled, pending, ordersToday, avgOrderValue };\n }, [orders, stats]);\n\n const pendingCarts = useMemo(() => providers.filter((p) => !p.isOpen).length, [providers]);\n\n const topCarts = analytics?.topProviders ?? [];\n const customerTotal = analytics?.customerGrowth?.customers ?? 0;\n\n // Cart distribution per category with a real, derived share percentage.\n // The backend exposes counts per category, not revenue per category.\n const categoryDistRows = useMemo(() => {\n const entries = Object.entries(analytics?.categoryDistribution ?? {});\n const total = entries.reduce((sum, [, count]) => sum + count, 0);\n return entries\n .map(([category, count]) => ({\n category,\n count,\n percentage: total > 0 ? (count / total) * 100 : 0,\n }))\n .sort((a, b) => b.count - a.count);\n }, [analytics]);\n\n const prettyCategory = (c: string) => c.replace(/_/g, ' ').toLowerCase();\n\n const pct = (part: number, whole: number) => (whole > 0 ? (part / whole) * 100 : 0);\n\n const medalIcon = (index: number) => {\n if (index < 3) return <Award className=\"h-5 w-5 text-status-warning-text\" />;\n return <BarChart3 className=\"h-5 w-5 text-text-secondary\" />;\n };\n\n if (loading || !stats) {\n return (\n <PageLayout title=\"Platform Analytics\" description=\"Loading analytics...\">\n <div className=\"flex flex-col items-center justify-center py-20\">\n <Loader2 className=\"h-10 w-10 animate-spin text-text-secondary mb-4\" />\n <p className=\"text-text-secondary\">Loading analytics...</p>\n </div>\n </PageLayout>\n );\n }\n\n const tabs: Array<{ key: TabKey; label: string; icon: typeof BarChart3 }> = [\n { key: 'overview', label: 'Overview', icon: BarChart3 },\n { key: 'revenue', label: 'Revenue', icon: IndianRupee },\n { key: 'users', label: 'Users', icon: Users },\n { key: 'performance', label: 'Performance', icon: Zap },\n ];\n\n return (\n <PageLayout title=\"Platform Analytics\" description=\"Comprehensive platform metrics and trends\">\n <PagePurpose className=\"mb-6\">\n Your bird&apos;s-eye view of how Kadaikodi is performing. Spot revenue and order trends, see\n which carts and categories drive the most business, and understand where customers are\n growing — so you can decide where to invest and which carts to promote. Switch tabs to drill\n into revenue, users, and operational performance.\n </PagePurpose>\n\n <NextSteps\n storageKey=\"kadaikodi-admin-analytics\"\n className=\"mb-6\"\n steps={[\n {\n id: 'review-carts',\n label: 'Review top-performing carts',\n description: 'See which carts drive the most revenue and orders.',\n onClick: () => setActiveTab('overview'),\n },\n {\n id: 'check-revenue',\n label: 'Break down revenue by category',\n description: 'Find your strongest categories in the Revenue tab.',\n onClick: () => setActiveTab('revenue'),\n },\n {\n id: 'manage-carts',\n label: 'Approve pending carts',\n description: 'Onboard the carts waiting for review.',\n onClick: () => navigateTo('/admin/carts'),\n done: pendingCarts === 0,\n },\n ]}\n />\n\n <div className=\"flex justify-end mb-6\">\n <span className=\"text-sm text-text-secondary\">\n Last updated: {new Date().toLocaleString('en-IN')}\n </span>\n </div>\n\n {/* Key Metrics — the one emphasis zone for this page */}\n <EmphasisPanel className=\"mb-8\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">Key Metrics</h2>\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4\">\n <MetricsCard\n featured\n icon={<IndianRupee className=\"h-5 w-5\" />}\n value={fmtCur(stats.totalRevenue)}\n label=\"Total Revenue\"\n />\n <MetricsCard\n icon={<ShoppingBag className=\"h-5 w-5\" />}\n value={(stats.totalOrders ?? 0).toLocaleString('en-IN')}\n label=\"Total Orders\"\n />\n <MetricsCard\n icon={<Users className=\"h-5 w-5\" />}\n value={(stats.activeCustomers ?? 0).toLocaleString('en-IN')}\n label=\"Active Customers\"\n />\n <MetricsCard\n icon={<Store className=\"h-5 w-5\" />}\n value={(stats.activeProviders ?? 0).toLocaleString('en-IN')}\n label=\"Active Carts\"\n trendValue={`${pendingCarts} pending`}\n />\n </div>\n </EmphasisPanel>\n\n {/* Tabs */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface mb-8\">\n <div className=\"border-b border-border-subtle\">\n <nav className=\"flex -mb-px overflow-x-auto\">\n {tabs.map((tab) => {\n const TabIcon = tab.icon;\n return (\n <button\n key={tab.key}\n type=\"button\"\n onClick={() => setActiveTab(tab.key)}\n className={cn(\n 'flex items-center gap-2 py-3 px-4 sm:px-6 text-sm font-medium whitespace-nowrap border-b-2 transition-colors',\n activeTab === tab.key\n ? 'border-primary text-primary'\n : 'border-transparent text-text-secondary hover:text-text-primary'\n )}\n >\n <TabIcon className=\"h-4 w-4\" />\n <span className=\"hidden sm:inline\">{tab.label}</span>\n </button>\n );\n })}\n </nav>\n </div>\n\n <div className=\"p-4 sm:p-6\">\n {/* Overview Tab */}\n {activeTab === 'overview' && (\n <div className=\"space-y-8\">\n <div>\n <h3 className=\"text-lg font-semibold text-text-primary mb-4\">\n Order Status Distribution\n </h3>\n {orderStats.total > 0 ? (\n <div className=\"grid grid-cols-1 sm:grid-cols-3 gap-4\">\n <div className=\"rounded-lg border border-status-success-text/30 bg-status-success-bg-subtle p-4\">\n <p className=\"text-sm text-status-success-text\">Completed Orders</p>\n <p className=\"text-2xl font-bold text-status-success-text\">\n {orderStats.completed.toLocaleString('en-IN')}\n </p>\n <p className=\"text-sm text-status-success-text/80\">\n {pct(orderStats.completed, orderStats.total).toFixed(1)}% of total\n </p>\n </div>\n <div className=\"rounded-lg border border-status-warning-text/30 bg-status-warning-bg-subtle p-4\">\n <p className=\"text-sm text-status-warning-text\">Pending Orders</p>\n <p className=\"text-2xl font-bold text-status-warning-text\">\n {orderStats.pending.toLocaleString('en-IN')}\n </p>\n <p className=\"text-sm text-status-warning-text/80\">\n {pct(orderStats.pending, orderStats.total).toFixed(1)}% of total\n </p>\n </div>\n <div className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle p-4\">\n <p className=\"text-sm text-status-error-text\">Cancelled Orders</p>\n <p className=\"text-2xl font-bold text-status-error-text\">\n {orderStats.cancelled.toLocaleString('en-IN')}\n </p>\n <p className=\"text-sm text-status-error-text/80\">\n {pct(orderStats.cancelled, orderStats.total).toFixed(1)}% of total\n </p>\n </div>\n </div>\n ) : (\n <p className=\"text-sm text-text-secondary\">\n Order breakdowns will appear here once orders are placed.\n </p>\n )}\n </div>\n\n <div>\n <h3 className=\"text-lg font-semibold text-text-primary mb-4\">\n Top Performing Carts\n </h3>\n {topCarts.length > 0 ? (\n <div className=\"rounded-lg border border-border-subtle overflow-hidden\">\n <table className=\"w-full\">\n <thead>\n <tr className=\"border-b border-border-subtle bg-bg-sunken/50\">\n <th className=\"px-4 py-3 text-left text-xs font-medium text-text-secondary uppercase\">\n Cart Name\n </th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-text-secondary uppercase\">\n Category\n </th>\n <th className=\"px-4 py-3 text-right text-xs font-medium text-text-secondary uppercase\">\n Rating\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border\">\n {topCarts.map((cart, i) => (\n <tr key={cart.id} className=\"hover:bg-accent/50 transition-colors\">\n <td className=\"px-4 py-3\">\n <div className=\"flex items-center gap-2\">\n {medalIcon(i)}\n <span className=\"text-sm font-medium text-text-primary\">\n {cart.name}\n </span>\n </div>\n </td>\n <td className=\"px-4 py-3 text-sm text-left text-text-secondary capitalize\">\n {prettyCategory(cart.category)}\n </td>\n <td className=\"px-4 py-3 text-sm text-right text-text-primary\">\n <span className=\"flex items-center justify-end gap-1\">\n <Star className=\"h-3.5 w-3.5 fill-status-warning-text text-status-warning-text\" />\n {(cart.rating ?? 0).toFixed(1)}\n </span>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n ) : (\n <p className=\"text-sm text-text-secondary\">\n Top-performing carts will be ranked here once orders start flowing.\n </p>\n )}\n </div>\n </div>\n )}\n\n {/* Revenue Tab */}\n {activeTab === 'revenue' && (\n <div className=\"space-y-8\">\n <div className=\"grid grid-cols-1 md:grid-cols-3 gap-4\">\n <div className=\"rounded-lg border border-border-focus/30 bg-[var(--color-accent-soft)] p-6\">\n <h4 className=\"text-sm font-medium text-text-primary mb-2\">Total Revenue</h4>\n <p className=\"text-2xl font-bold text-text-primary\">\n {fmtCur(stats.totalRevenue)}\n </p>\n </div>\n <div className=\"rounded-lg border border-border-subtle bg-bg-sunken/30 p-6\">\n <h4 className=\"text-sm font-medium text-text-secondary mb-2\">Total Orders</h4>\n <p className=\"text-2xl font-bold text-text-primary\">\n {(stats.totalOrders ?? 0).toLocaleString('en-IN')}\n </p>\n </div>\n <div className=\"rounded-lg border border-status-success-text/30 bg-status-success-bg-subtle p-6\">\n <h4 className=\"text-sm font-medium text-status-success-text mb-2\">\n Average Order Value\n </h4>\n <p className=\"text-2xl font-bold text-status-success-text\">\n {fmtCur(orderStats.avgOrderValue)}\n </p>\n </div>\n </div>\n\n <p className=\"text-sm text-text-secondary\">\n Revenue is not broken down by category by the platform backend. See the Users tab for\n how carts are distributed across categories.\n </p>\n </div>\n )}\n\n {/* Users Tab */}\n {activeTab === 'users' && (\n <div className=\"space-y-8\">\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-sunken/30 p-6\">\n <div className=\"flex items-center gap-2 mb-2\">\n <Users className=\"h-5 w-5 text-text-secondary\" />\n <h4 className=\"text-sm font-medium text-text-secondary\">Active Customers</h4>\n </div>\n <p className=\"text-3xl font-bold text-text-primary\">\n {(stats.activeCustomers ?? 0).toLocaleString('en-IN')}\n </p>\n </div>\n <div className=\"rounded-lg border border-border-subtle bg-bg-sunken/30 p-6\">\n <div className=\"flex items-center gap-2 mb-2\">\n <Store className=\"h-5 w-5 text-text-secondary\" />\n <h4 className=\"text-sm font-medium text-text-secondary\">Active Cart Owners</h4>\n </div>\n <p className=\"text-3xl font-bold text-text-primary\">\n {(stats.activeProviders ?? 0).toLocaleString('en-IN')}\n </p>\n </div>\n </div>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-sunken/20 p-6\">\n <div className=\"flex items-center gap-2 mb-2\">\n <Users className=\"h-5 w-5 text-text-secondary\" />\n <h3 className=\"text-sm font-medium text-text-secondary\">Total Customers</h3>\n </div>\n <p className=\"text-3xl font-bold text-text-primary\">\n {customerTotal.toLocaleString('en-IN')}\n </p>\n <p className=\"mt-1 text-sm text-text-secondary\">\n Customers on the platform to date.\n </p>\n </div>\n\n {categoryDistRows.length > 0 && (\n <div>\n <h3 className=\"text-lg font-semibold text-text-primary mb-4\">\n Cart Category Distribution\n </h3>\n <div className=\"space-y-3\">\n {categoryDistRows.map((row) => (\n <div key={row.category}>\n <div className=\"flex items-center justify-between mb-1\">\n <span className=\"text-sm font-medium text-text-primary capitalize\">\n {prettyCategory(row.category)}\n </span>\n <span className=\"text-sm text-text-secondary\">\n {(row.count ?? 0).toLocaleString('en-IN')} (\n {(row.percentage ?? 0).toFixed(1)}%)\n </span>\n </div>\n <div className=\"w-full bg-bg-sunken rounded-full h-2\">\n <div\n className=\"bg-action-primary-bg h-2 rounded-full transition-all duration-300\"\n style={{ width: `${row.percentage}%` }}\n />\n </div>\n </div>\n ))}\n </div>\n </div>\n )}\n </div>\n )}\n\n {/* Performance Tab */}\n {activeTab === 'performance' && (\n <div className=\"space-y-8\">\n <div className=\"grid grid-cols-1 md:grid-cols-3 gap-6\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <div className=\"flex items-center gap-2 mb-2\">\n <Star className=\"h-4 w-4 text-text-secondary\" />\n <h4 className=\"text-sm font-medium text-text-secondary\">\n Customer Satisfaction\n </h4>\n </div>\n <p className=\"text-3xl font-bold text-text-primary flex items-center gap-1\">\n <Star className=\"h-6 w-6 fill-status-warning-text text-status-warning-text\" />\n {stats.avgRating > 0 ? stats.avgRating.toFixed(1) : '—'}\n </p>\n <p className=\"text-sm text-text-secondary mt-1\">Average rating across carts</p>\n </div>\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <div className=\"flex items-center gap-2 mb-2\">\n <TrendingUp className=\"h-4 w-4 text-text-secondary\" />\n <h4 className=\"text-sm font-medium text-text-secondary\">Completion Rate</h4>\n </div>\n <p className=\"text-3xl font-bold text-text-primary\">\n {orderStats.total > 0\n ? `${pct(orderStats.completed, orderStats.total).toFixed(1)}%`\n : '—'}\n </p>\n <p className=\"text-sm text-text-secondary mt-1\">Orders delivered</p>\n </div>\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <div className=\"flex items-center gap-2 mb-2\">\n <BarChart3 className=\"h-4 w-4 text-text-secondary\" />\n <h4 className=\"text-sm font-medium text-text-secondary\">Cancellation Rate</h4>\n </div>\n <p className=\"text-3xl font-bold text-text-primary\">\n {orderStats.total > 0\n ? `${pct(orderStats.cancelled, orderStats.total).toFixed(1)}%`\n : '—'}\n </p>\n <p className=\"text-sm text-text-secondary mt-1\">Orders cancelled</p>\n </div>\n </div>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-lg font-semibold text-text-primary mb-4\">\n Today&apos;s Activity\n </h3>\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-6\">\n <div>\n <p className=\"text-sm text-text-secondary mb-2\">Orders Today</p>\n <p className=\"text-3xl font-bold text-text-primary\">\n {orderStats.ordersToday.toLocaleString('en-IN')}\n </p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary mb-2\">Pending Orders</p>\n <p className=\"text-3xl font-bold text-status-warning-text\">\n {(stats.pendingOrders ?? 0).toLocaleString('en-IN')}\n </p>\n </div>\n </div>\n </div>\n </div>\n )}\n </div>\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;AAgDA,SAAgB,IAAqB;CACnC,IAAM,EAAE,kBAAe,GAAc,EAE/B,EAAE,MAAM,GAAO,WAAW,MAAiB,GAAmB,EAC9D,EAAE,MAAM,GAAW,WAAW,MAAqB,GAAmB,EACtE,EAAE,MAAM,IAAY,EAAE,EAAE,WAAW,MAAqB,GAAc,EACtE,EAAE,MAAM,IAAS,EAAE,EAAE,WAAW,MAAkB,EAAU,EAAE,CAAC,EAE/D,CAAC,GAAW,KAAgB,EAAiB,WAAW,EAExD,IAAU,KAAgB,KAAoB,KAAoB,GAElE,KAAU,MACV,KAAU,MAAiB,KAAK,IAAS,KAAU,QAAQ,EAAE,CAAC,MAC9D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AAU;sBAAmC;YAAoB,CAAA;WAChE;;SACN,kBAAC,OAAD;UAAK,WAAU;oBAAf;WACE,kBAAC,OAAD;YAAK,WAAU;sBAAf,CACE,kBAAC,GAAD,EAAW,WAAU,+BAAgC,CAAA,EACrD,kBAAC,MAAD;aAAI,WAAU;uBAA0C;aAAsB,CAAA,CAC1E;;WACN,kBAAC,KAAD;YAAG,WAAU;sBACV,EAAW,QAAQ,IAChB,GAAG,EAAI,EAAW,WAAW,EAAW,MAAM,CAAC,QAAQ,EAAE,CAAC,KAC1D;YACF,CAAA;WACJ,kBAAC,KAAD;YAAG,WAAU;sBAAmC;YAAoB,CAAA;WAChE;;SACF;WAEN,kBAAC,OAAD;QAAK,WAAU;kBAAf,CACE,kBAAC,MAAD;SAAI,WAAU;mBAA+C;SAExD,CAAA,EACL,kBAAC,OAAD;SAAK,WAAU;mBAAf,CACE,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,KAAD;UAAG,WAAU;oBAAmC;UAAgB,CAAA,EAChE,kBAAC,KAAD;UAAG,WAAU;oBACV,EAAW,YAAY,eAAe,QAAQ;UAC7C,CAAA,CACA,EAAA,CAAA,EACN,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,KAAD;UAAG,WAAU;oBAAmC;UAAkB,CAAA,EAClE,kBAAC,KAAD;UAAG,WAAU;qBACT,EAAM,iBAAiB,GAAG,eAAe,QAAQ;UACjD,CAAA,CACA,EAAA,CAAA,CACF;WACF;UACF;;MAEJ;OACF;;GACK"}
@@ -11,7 +11,7 @@ import { jsx as T, jsxs as E } from "react/jsx-runtime";
11
11
  import { CTAOverflowMenu as D, EmphasisPanel as O, NextSteps as k, PagePurpose as A } from "@burdenoff/fe-libs/ui";
12
12
  //#region src/kadaikodi/pages/admin/AdminDashboard.tsx
13
13
  function j() {
14
- let { navigateTo: j, currentUser: M } = e(), N = M?.firstName ?? M?.name ?? "Admin", { data: P, isLoading: F } = o(), { data: I = [], isLoading: L } = c(), { data: R = [], isLoading: z } = s({}), { data: B } = a(), V = F || L || z, H = (e) => l(e, { minimumFractionDigits: 0 }), U = d(() => I.filter((e) => !e.isOpen).length, [I]), W = d(() => [...R].sort((e, t) => new Date(t.orderDate).getTime() - new Date(e.orderDate).getTime()).slice(0, 6), [R]), G = (e) => e === "delivered" ? "bg-status-success-bg-subtle text-status-success-text" : e === "cancelled" ? "bg-status-error-bg-subtle text-status-error-text" : "bg-status-warning-bg-subtle text-status-warning-text";
14
+ let { navigateTo: j, currentUser: M } = e(), N = M?.firstName ?? M?.name ?? "Admin", { data: P, isLoading: F } = o(), { data: I = [], isLoading: L } = c(), { data: R = [], isLoading: z } = s({}), { data: B } = a(), V = F || L || z, H = (e) => l(e, { minimumFractionDigits: 0 }), U = d(() => I.filter((e) => !e.isOpen).length, [I]), W = d(() => [...R].sort((e, t) => new Date(t.orderDate).getTime() - new Date(e.orderDate).getTime()).slice(0, 6), [R]), G = (e) => e.replace(/_/g, " ").toLowerCase(), K = B?.topProviders ?? [], q = Object.entries(B?.categoryDistribution ?? {}).sort((e, t) => t[1] - e[1]), J = (e) => e === "delivered" ? "bg-status-success-bg-subtle text-status-success-text" : e === "cancelled" ? "bg-status-error-bg-subtle text-status-error-text" : "bg-status-warning-bg-subtle text-status-warning-text";
15
15
  return V ? /* @__PURE__ */ T(n, {
16
16
  title: "Admin Dashboard",
17
17
  description: "Loading...",
@@ -130,17 +130,17 @@ function j() {
130
130
  children: [
131
131
  /* @__PURE__ */ T(r, {
132
132
  icon: /* @__PURE__ */ T(w, { className: "h-5 w-5" }),
133
- value: P.activeCustomers.toLocaleString("en-IN"),
133
+ value: (P.activeCustomers ?? 0).toLocaleString("en-IN"),
134
134
  label: "Active Customers"
135
135
  }),
136
136
  /* @__PURE__ */ T(r, {
137
137
  icon: /* @__PURE__ */ T(C, { className: "h-5 w-5" }),
138
- value: P.activeProviders.toLocaleString("en-IN"),
138
+ value: (P.activeProviders ?? 0).toLocaleString("en-IN"),
139
139
  label: "Active Carts"
140
140
  }),
141
141
  /* @__PURE__ */ T(r, {
142
142
  icon: /* @__PURE__ */ T(x, { className: "h-5 w-5" }),
143
- value: P.totalOrders.toLocaleString("en-IN"),
143
+ value: (P.totalOrders ?? 0).toLocaleString("en-IN"),
144
144
  label: "Total Orders"
145
145
  }),
146
146
  /* @__PURE__ */ T(r, {
@@ -181,7 +181,7 @@ function j() {
181
181
  children: "Pending Orders"
182
182
  }), /* @__PURE__ */ T("p", {
183
183
  className: "text-xl font-bold text-status-warning-text",
184
- children: P.pendingOrders.toLocaleString("en-IN")
184
+ children: (P.pendingOrders ?? 0).toLocaleString("en-IN")
185
185
  })]
186
186
  }),
187
187
  /* @__PURE__ */ E("div", {
@@ -226,14 +226,14 @@ function j() {
226
226
  className: "text-sm font-medium text-text-primary",
227
227
  children: ["Order from ", e.cartName]
228
228
  }), /* @__PURE__ */ T("span", {
229
- className: t("inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium capitalize w-fit", G(e.status)),
229
+ className: t("inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium capitalize w-fit", J(e.status)),
230
230
  children: e.status.replace(/_/g, " ")
231
231
  })]
232
232
  }), /* @__PURE__ */ E("div", {
233
233
  className: "flex flex-wrap items-center mt-1 text-xs text-text-secondary gap-3",
234
234
  children: [/* @__PURE__ */ T("span", { children: u(e.orderDate) }), /* @__PURE__ */ E("span", {
235
235
  className: "flex items-center gap-1",
236
- children: [/* @__PURE__ */ T(v, { className: "h-3 w-3" }), e.total.toLocaleString("en-IN")]
236
+ children: [/* @__PURE__ */ T(v, { className: "h-3 w-3" }), (e.total ?? 0).toLocaleString("en-IN")]
237
237
  })]
238
238
  })]
239
239
  })]
@@ -252,26 +252,30 @@ function j() {
252
252
  className: "flex items-center gap-2 mb-4",
253
253
  children: [/* @__PURE__ */ T(g, { className: "h-5 w-5 text-text-secondary" }), /* @__PURE__ */ T("h3", {
254
254
  className: "text-lg font-semibold text-text-primary",
255
- children: "Revenue by Category"
255
+ children: "Carts by Category"
256
256
  })]
257
- }), B && B.revenueByCategory.length > 0 ? /* @__PURE__ */ T("div", {
257
+ }), q.length > 0 ? /* @__PURE__ */ T("div", {
258
258
  className: "space-y-3",
259
- children: B.revenueByCategory.map((e) => /* @__PURE__ */ E("div", {
259
+ children: q.map(([e, t]) => /* @__PURE__ */ E("div", {
260
260
  className: "flex items-center justify-between rounded-lg bg-bg-sunken/50 p-3",
261
- children: [/* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("p", {
261
+ children: [/* @__PURE__ */ T("p", {
262
262
  className: "text-sm font-medium text-text-primary capitalize",
263
- children: e.category
263
+ children: G(e)
264
264
  }), /* @__PURE__ */ E("p", {
265
- className: "text-xs text-text-secondary",
266
- children: [e.orders.toLocaleString("en-IN"), " orders"]
267
- })] }), /* @__PURE__ */ T("p", {
268
265
  className: "text-sm font-semibold text-text-primary",
269
- children: H(e.revenue)
266
+ children: [
267
+ (t ?? 0).toLocaleString("en-IN"),
268
+ " ",
269
+ /* @__PURE__ */ T("span", {
270
+ className: "text-xs font-normal text-text-secondary",
271
+ children: t === 1 ? "cart" : "carts"
272
+ })
273
+ ]
270
274
  })]
271
- }, e.category))
275
+ }, e))
272
276
  }) : /* @__PURE__ */ T("p", {
273
277
  className: "text-sm text-text-secondary",
274
- children: "Category revenue will appear here once orders are recorded."
278
+ children: "Cart categories will appear here as carts are onboarded."
275
279
  })]
276
280
  }), /* @__PURE__ */ E("div", {
277
281
  className: "rounded-lg border border-border-subtle bg-bg-surface p-6",
@@ -281,25 +285,19 @@ function j() {
281
285
  className: "text-lg font-semibold text-text-primary",
282
286
  children: "Top Carts"
283
287
  })]
284
- }), B && B.topProviders.length > 0 ? /* @__PURE__ */ T("div", {
288
+ }), K.length > 0 ? /* @__PURE__ */ T("div", {
285
289
  className: "space-y-3",
286
- children: B.topProviders.map((e) => /* @__PURE__ */ E("div", {
290
+ children: K.map((e) => /* @__PURE__ */ E("div", {
287
291
  className: "flex items-center justify-between rounded-lg bg-bg-sunken/50 p-3",
288
292
  children: [/* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("p", {
289
293
  className: "text-sm font-medium text-text-primary",
290
294
  children: e.name
291
- }), /* @__PURE__ */ E("p", {
292
- className: "text-xs text-text-secondary flex items-center gap-1",
293
- children: [
294
- /* @__PURE__ */ T(S, { className: "h-3 w-3 fill-status-warning-text text-status-warning-text" }),
295
- e.rating.toFixed(1),
296
- " · ",
297
- e.orders.toLocaleString("en-IN"),
298
- " orders"
299
- ]
300
- })] }), /* @__PURE__ */ T("p", {
301
- className: "text-sm font-semibold text-text-primary",
302
- children: H(e.revenue)
295
+ }), /* @__PURE__ */ T("p", {
296
+ className: "text-xs text-text-secondary capitalize",
297
+ children: G(e.category)
298
+ })] }), /* @__PURE__ */ E("p", {
299
+ className: "text-sm font-semibold text-text-primary flex items-center gap-1",
300
+ children: [/* @__PURE__ */ T(S, { className: "h-3.5 w-3.5 fill-status-warning-text text-status-warning-text" }), (e.rating ?? 0).toFixed(1)]
303
301
  })]
304
302
  }, e.id))
305
303
  }) : /* @__PURE__ */ T("p", {