import { Head, Link } from '@inertiajs/react'; import { ArrowLeft, Printer } from 'lucide-react'; import { AppLogoIcon } from '@/components/brand'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; import { formatCurrency } from '@/lib/utils'; import { index as invoiceIndex } from '@/routes/admin/manage/invoices'; import { InvoiceShareButton } from './invoice-share-button'; type InvoiceItem = { id: number; name: string; quantity: number; price: number; subtotal: number; }; type Company = { name: string; address: string | null; email: string | null; phone: string | null; }; type PrintInvoice = { id: number; invoice_number: string; customer_name: string; customer_phone: string | null; customer_address: string | null; amount: number; formatted_amount: string; formatted_date: string; formatted_due_date: string | null; status: 'unpaid' | 'paid'; status_label: string; description: string | null; items: InvoiceItem[]; company: Company; }; type Props = { invoice: PrintInvoice; }; const STATUS_BADGE_CLASSES: Record = { unpaid: 'bg-yellow-100 text-yellow-800 hover:bg-yellow-100', paid: 'bg-green-100 text-green-800 hover:bg-green-100', }; export default function InvoicePrint({ invoice }: Props) { const { company } = invoice; return ( <>

INVOICE

{company.name}

{company.address && (

{company.address}

)} {(company.phone || company.email) && (

{[company.phone, company.email] .filter(Boolean) .join(' ยท ')}

)}

{invoice.invoice_number}

{invoice.status_label}

Ditagihkan Kepada

{invoice.customer_name}

{invoice.customer_phone && (

{invoice.customer_phone}

)} {invoice.customer_address && (

{invoice.customer_address}

)}

Tanggal Invoice

{invoice.formatted_date}

{invoice.formatted_due_date && ( <>

Jatuh Tempo

{invoice.formatted_due_date}

)}
Item Jumlah Harga Satuan Subtotal {invoice.items.map((item) => ( {item.name} {item.quantity} {formatCurrency(item.price)} {formatCurrency(item.subtotal)} ))}
Total {invoice.formatted_amount}
{invoice.description && (

Keterangan

{invoice.description}

)}
); }