'use client'; import { ArrowRight, ShoppingBag, Clock, Boxes, CheckCircle2, Building2, Layers, AlertCircle, } from 'lucide-react'; import { cn } from '@/lib/utils'; import Link from 'next/link'; import { DashboardHeaderNav } from '@/components/dashboard/DashboardHeaderNav'; import { useDashboardData } from '@/components/dashboard/useDashboardData'; import { CARD, PIPELINE, PAYMENT_TAG, formatCompact, formatInr, CardTitle, DeltaPill, } from '@/components/dashboard/DashboardShared'; export default function StoreManagerDashboardPage() { const { stats: displayStats, loading, refreshing, fetchData, activity, } = useDashboardData(); const byStatus = displayStats.orders_by_status ?? {}; const countOf = (key: string) => byStatus[key] ?? 0; const totalOrders = displayStats.total_orders ?? 0; const delivered = countOf('delivered'); const pipelineRows = PIPELINE.map((stage) => ({ ...stage, count: countOf(stage.key), value: countOf(stage.key) * (displayStats.revenue_all_time / Math.max(totalOrders, 1)), })); const maxPipeline = Math.max(...pipelineRows.map((row) => row.count), 1); if (loading) { return (
{[...Array(4)].map((_, i) => (
))}
); } return (
fetchData(true)} /> {/* KPI Cards Row */}

Active Store Orders

{totalOrders}

vs prior 7 days

Pending & In-Transit

{countOf('pending') + countOf('processing') + countOf('shipped')}

Requires Dispatch Action

Catalog Stock Units

{(displayStats.total_stock_units ?? 0).toLocaleString()}

{displayStats.total_products} Active SKUs

Fulfilled Orders

{delivered}

vs prior 7 days
{/* Fulfillment Pipeline & Inventory */}
Store Operations & Fulfillment Pipeline
{pipelineRows.map((row) => (

{row.label}

{row.count} Orders

{formatCompact(row.value)}

))}
{pipelineRows.map((row) => (
{row.label}
))}
Store Inventory Overview
Total Catalog Products
{displayStats.total_products}
Active Brands
{displayStats.total_brands}
Categories Listed
{displayStats.total_categories}
Total Stock Units
{displayStats.total_stock_units}
{/* Dispatch Queue Table */}
Store Manager Order Dispatch Queue Manage Orders
{(displayStats.recent_orders ?? []).map((order) => ( ))}
Order Dispatch Stage Value Payment Customer
{order.order_no} {order.status} {formatInr(order.amount)} {order.payment_status || '—'} {order.customer_name}
); }