"use client"; import useSWR from "swr"; import Link from "next/link"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { ClipboardList, ArrowRight } from "lucide-react"; import { formatCurrency } from "@/lib/format"; import type { Product } from "@/lib/types"; const fetcher = (url: string) => fetch(url).then((r) => r.json()); const statusStyles: Record = { draft: "bg-muted text-muted-foreground", active: "bg-accent/15 text-accent border-accent/30", deprecated: "bg-warning/15 text-warning border-warning/30", archived: "bg-muted text-muted-foreground", }; export default function BomIndexPage() { const { data: products = [] } = useSWR("/api/products", fetcher); return (

Bill of Materials

Select a product to view or manage its BOM

{products.length === 0 ? (

No products created yet. Create a product first to manage its BOM.

) : (
{products.map((prod) => (
{prod.name}

{prod.sku} · v{prod.version}

{prod.status}
{prod.bom_count || 0} items | {formatCurrency(Number(prod.total_cost || 0))}
))}
)}
); }