"use client" import { Wrench } from "lucide-react" import { Card, CardContent, CardHeader, CardTitle, } from "@/shared/components/ui/card" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/shared/components/ui/table" import { formatCurrency, formatNumber } from "@/shared/utils/formatters" type InvoicePart = { id: number invoice_id: number part_id: number quantity: string | number rate: string | number description?: string chart_of_account?: string department_id?: number created_at?: string updated_at?: string } type InvoicePartsSectionProps = { parts?: InvoicePart[] } export function InvoicePartsSection({ parts = [] }: InvoicePartsSectionProps) { if (!parts || parts.length === 0) { return null } const subtotal = parts.reduce((sum, part) => { const qty = parseFloat(String(part.quantity)) const rate = parseFloat(String(part.rate)) return sum + (qty * rate) }, 0) return ( Parts
Description Quantity Rate Amount {parts.map((part) => { const qty = parseFloat(String(part.quantity)) const rate = parseFloat(String(part.rate)) const amount = qty * rate return ( {part.description || `Part #${part.part_id}`} {formatNumber(qty)} {formatCurrency(rate)} {formatCurrency(amount)} ) })} Subtotal {formatCurrency(subtotal)}
) }