import type { WholesaleOrder, WholesaleDashboardStats } from "@/actions/wholesale"; import StatusBadge from "./StatusBadge"; import type { MsgFn, WebhookActivityEntry } from "./types"; interface DashboardTabProps { stats: WholesaleDashboardStats; recentOrders: WholesaleOrder[]; webhookActivity: WebhookActivityEntry[]; } // Top-level dashboard: stat cards + recent orders table + recent webhook activity. export default function DashboardTab({ stats, recentOrders, webhookActivity }: DashboardTabProps) { return (
{/* Stat cards */}
{[ { label: "Open Orders", value: stats.open_orders, variant: "default" }, { label: "Pickup Today", value: stats.pickup_today, variant: "default" }, { label: "Past Due", value: stats.past_due, variant: "danger" }, { label: "Total Unpaid", value: `$${stats.total_unpaid.toFixed(2)}`, variant: "default" }, { label: "Awaiting Deposit", value: stats.awaiting_deposit, variant: "warning" }, { label: "Fulfilled Today", value: stats.fulfilled_today, variant: "success" }, ].map((card) => (

{card.label}

{card.value}

))}
{/* Recent orders */}

Recent Orders

{recentOrders.length === 0 ? (

No wholesale orders yet

Wholesale orders placed by your customers will appear here.

) : (
{recentOrders.map((order) => ( ))}
Invoice Customer Pickup Date Total Status Payment
{order.invoice_number ?? "—"} {order.company_name} {order.anticipated_pickup_date ?? "—"} ${Number(order.subtotal).toFixed(2)} {order.payment_status === "paid" ? "Paid" : order.balance_due > 0 ? `$${Number(order.balance_due).toFixed(2)} due` : "Partial"}
)}
{/* Recent webhook activity */} {webhookActivity.length > 0 && (

Recent Webhook Activity

{webhookActivity.map((entry) => ( ))}
Event Order Status Attempts Sent At
{entry.event_type} {entry.order_id ? entry.order_id.slice(0, 8) : "—"} {entry.status} {entry.attempts} {new Date(entry.created_at).toLocaleString()}
)}
); }