'use client'; import { Building2, Users, Boxes, DollarSign, } 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, formatInr, deltaFromWeek, CardTitle, DeltaPill, } from '@/components/dashboard/DashboardShared'; export default function B2BDashboardPage() { const { stats: displayStats, loading, refreshing, userName, fetchData, } = useDashboardData(); const totalOrders = displayStats.total_orders ?? 0; const revenueDelta = deltaFromWeek( displayStats.revenue_last_7_days ?? 0, displayStats.revenue_last_30_days ?? 0 ); const customersDelta = 2.5; if (loading) { return (
{[...Array(4)].map((_, i) => (
))}
); } return (
fetchData(true)} /> {/* KPI Cards Row */}

Total Wholesale Revenue

{formatInr(displayStats.revenue_all_time)}

B2B volume growth

Active B2B Accounts

{displayStats.total_users}

Verified clients

Bulk Orders Volume

{totalOrders}

Wholesale fulfillment

Avg B2B Order Value

{formatInr((displayStats.revenue_all_time / Math.max(totalOrders, 1)) * 1.5)}

High-value basket size
{/* Orders Ledger & Top Wholesale Products */}
B2B Wholesale Orders Ledger View All Bulk Orders
{(displayStats.recent_orders ?? []).map((order) => ( ))}
Bulk Order # Corporate Client Order Value Fulfillment
{order.order_no} {order.customer_name} {formatInr(order.amount)} {order.status}
Top Wholesale Products
{(displayStats.top_products ?? []).length === 0 ? (

No wholesale data yet

) : ( (displayStats.top_products ?? []).slice(0, 5).map((product) => (

{product.name}

{product.total_sold} units sold

{formatInr(product.total_revenue)}
)) )}
); }