'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, CardTitle, DeltaPill, } from '@/components/dashboard/DashboardShared'; export default function B2BDashboardPage() { const { stats: displayStats, loading, refreshing, fetchData, activity, } = useDashboardData(); const totalOrders = displayStats.total_orders ?? 0; const averageOrderValue = totalOrders > 0 ? displayStats.revenue_all_time / totalOrders : 0; if (loading) { return (
{[...Array(4)].map((_, i) => (
))}
); } return (
fetchData(true)} /> {/* KPI Cards Row */}

Total Wholesale Revenue

{formatInr(displayStats.revenue_all_time)}

vs prior 7 days

Active B2B Accounts

{displayStats.total_users}

vs prior 7 days

Bulk Orders Volume

{totalOrders}

vs prior 7 days

Avg B2B Order Value

{formatInr(averageOrderValue)}

vs prior 7 days
{/* Orders Ledger & Top Wholesale Products */}
B2B Wholesale Orders Ledger View All Bulk Orders
{(displayStats.recent_orders ?? []).length === 0 ? ( ) : (displayStats.recent_orders ?? []).map((order) => ( ))}
Bulk Order # Corporate Client Order Value Fulfillment
No wholesale orders yet
{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)}
)) )}
); }