{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "invoice-01",
  "description": "An overdue invoice with discount, sales tax, deposit and balance due, payment instructions and a reminder to send.",
  "registryDependencies": [
    "button",
    "https://www.dashboardblocks.com/r/radix/billing.json",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/invoice.json",
    "https://www.dashboardblocks.com/r/radix/record-detail.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/invoice/invoice-01.tsx",
      "content": "'use client'\n\nimport {\n  InvoiceStatusLabel,\n  formatBillingDate,\n  getDaysUntil,\n} from '@/registry/components/dashboardblocks/billing'\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  DocumentBrand,\n  DocumentFooter,\n  DocumentHeader,\n  DocumentHeadline,\n  DocumentLayout,\n  DocumentMeta,\n  DocumentPage,\n  DocumentParties,\n  DocumentSection,\n  DocumentSummary,\n  DocumentToolbar,\n  DocumentTotals,\n  type DocumentLine,\n  type DocumentParty,\n  LineItemsTable,\n  PrintButton,\n  formatDocumentAmount,\n  formatRate,\n  getDocumentTotals,\n  getTotalRows,\n} from '@/registry/components/dashboardblocks/invoice'\nimport {\n  Property,\n  PropertyList,\n} from '@/registry/components/dashboardblocks/record-detail'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { startTransition, useState } from 'react'\n\nimport { Button, buttonVariants } from '@/components/ui/button'\n\ninterface Invoice1Props extends BlockStateProps {\n  bank: { accountName: string; accountNumber: string; bank: string; routing: string }\n  billTo: DocumentParty\n  brand: { name: string; website: string }\n  /** @default 'USD' */\n  currency?: string\n  /** A share off the subtotal, 0.05 for 5%. */\n  discountRate?: number\n  dueDate: Date\n  /** Facts about the sender, printed at the foot of the page. */\n  footer: string[]\n  from: DocumentParty\n  issueDate: Date\n  /** Leave out, or pass none, to show the empty state. */\n  lines?: DocumentLine[]\n  notes: string\n  /** Pass a fixed date, so the status renders the same on the server and in the browser. */\n  now: Date\n  number: string\n  onDownload?: () => void\n  onSendReminder?: () => Promise<void>\n  paid?: number\n  payUrl: string\n  poNumber?: string\n  sentTo: string\n  taxRate?: number\n  terms: string\n}\n\nconst exampleProps: Invoice1Props = {\n  bank: {\n    accountName: 'Halden Studio LLC',\n    accountNumber: '•••• 7702',\n    bank: 'Hudson Valley Credit Union',\n    routing: '221 970 443',\n  },\n  billTo: {\n    label: 'Bill to',\n    lines: [\n      'Attn: Priya Raman, Accounts Payable',\n      '500 Boylston Street, Floor 12',\n      'Boston, MA 02116',\n      'ap@brightwavehealth.com',\n    ],\n    name: 'Brightwave Health, Inc.',\n  },\n  brand: { name: 'Halden Studio', website: 'halden.studio' },\n  discountRate: 0.05,\n  dueDate: new Date(Date.UTC(2026, 8, 20)),\n  footer: ['Halden Studio LLC', '214 Wythe Avenue, Brooklyn, NY 11249', 'EIN 88-4410273'],\n  from: {\n    label: 'From',\n    lines: ['214 Wythe Avenue, Studio 3', 'Brooklyn, NY 11249', 'billing@halden.studio'],\n    name: 'Halden Studio LLC',\n  },\n  issueDate: new Date(Date.UTC(2026, 7, 31)),\n  lines: [\n    {\n      description: 'Product design sprint',\n      detail: 'Discovery, patient interviews and wireframes, Aug 4 – Aug 15',\n      id: 'sprint',\n      quantity: 1,\n      unitPrice: 7200,\n    },\n    {\n      description: 'Senior product engineering',\n      detail: 'Patient intake flow in React Native',\n      id: 'engineering',\n      quantity: 46,\n      unit: 'hrs',\n      unitPrice: 165,\n    },\n    {\n      description: 'Design system audit',\n      detail: 'Tokens, components and an accessibility review',\n      id: 'audit',\n      quantity: 1,\n      unitPrice: 2400,\n    },\n    {\n      description: 'Moderated usability sessions',\n      detail: 'Including participant incentives',\n      id: 'usability',\n      quantity: 8,\n      unit: 'sessions',\n      unitPrice: 180,\n    },\n    {\n      description: 'Travel, Boston on-site',\n      detail: 'Reimbursed at cost, not taxed. Receipts attached.',\n      id: 'travel',\n      quantity: 1,\n      taxRate: 0,\n      unitPrice: 612.48,\n    },\n  ],\n  notes:\n    'Thanks for another great sprint. The 5% retainer discount applies to every invoice through December.',\n  now: new Date(Date.UTC(2026, 8, 27, 12)),\n  number: 'INV-2026-0142',\n  paid: 6000,\n  payUrl: 'https://pay.halden.studio/inv/2026-0142',\n  poNumber: 'PO-88213',\n  sentTo: 'ap@brightwavehealth.com',\n  taxRate: 0.08875,\n  terms: 'Net 20. Balances unpaid after the due date accrue 1.5% interest per month.',\n}\n\nfunction sendReminder() {\n  return new Promise<void>((resolve) => setTimeout(resolve, 600))\n}\n\nconst logo = (\n  <svg viewBox='0 0 36 36' fill='none' aria-hidden>\n    <rect\n      x='1'\n      y='1'\n      width='34'\n      height='34'\n      rx='9'\n      stroke='currentColor'\n      strokeWidth='2'\n    />\n    <path d='M12 10v16M24 10v16M12 18h12' stroke='currentColor' strokeWidth='2.5' />\n  </svg>\n)\n\nconst Invoice1 = (props: Invoice1Props) => {\n  const {\n    bank,\n    billTo,\n    brand,\n    currency = 'USD',\n    discountRate,\n    dueDate,\n    footer,\n    from,\n    issueDate,\n    lines = [],\n    notes,\n    now,\n    number,\n    onDownload = () => {},\n    onSendReminder = sendReminder,\n    paid,\n    payUrl,\n    poNumber,\n    sentTo,\n    errorMessage,\n    status: blockStatus,\n    taxRate,\n    terms,\n  } = props\n  const state = getBlockState(blockStatus, lines)\n  const [reminder, setReminder] = useState<'idle' | 'sending' | 'sent'>('idle')\n  const amounts = getDocumentTotals(lines, { currency, discountRate, paid, taxRate })\n  const daysLeft = getDaysUntil(dueDate, now)\n  const status =\n    lines.length > 0 && amounts.balanceDue <= 0\n      ? 'paid'\n      : daysLeft < 0\n        ? 'overdue'\n        : 'due'\n  const due = formatDocumentAmount(amounts.balanceDue, currency)\n  const dueWhen =\n    status === 'overdue'\n      ? `${-daysLeft} ${daysLeft === -1 ? 'day' : 'days'} overdue`\n      : daysLeft === 0\n        ? 'Due today'\n        : `Due in ${daysLeft} ${daysLeft === 1 ? 'day' : 'days'}`\n\n  const remind = async () => {\n    setReminder('sending')\n    try {\n      await onSendReminder()\n      startTransition(() => setReminder('sent'))\n    } catch {\n      startTransition(() => setReminder('idle'))\n    }\n  }\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <DocumentLayout>\n        <DocumentToolbar\n          description={\n            <p role='status'>\n              <BlockReady className='text-sm'>\n                {reminder === 'sent'\n                  ? `Reminder sent to ${sentTo}`\n                  : `Sent to ${sentTo} on ${formatBillingDate(issueDate)}`}\n              </BlockReady>\n            </p>\n          }\n        >\n          <PrintButton />\n          <Button variant='outline' size='sm' disabled={!!state} onClick={onDownload}>\n            <IconPlaceholder\n              lucide='DownloadIcon'\n              tabler='IconDownload'\n              hugeicons='Download01Icon'\n              phosphor='DownloadIcon'\n              remixicon='RiDownloadLine'\n              aria-hidden\n            />\n            Download PDF\n          </Button>\n          {status !== 'paid' && (\n            <Button size='sm' disabled={!!state || reminder !== 'idle'} onClick={remind}>\n              <IconPlaceholder\n                lucide='SendIcon'\n                tabler='IconSend'\n                hugeicons='SentIcon'\n                phosphor='PaperPlaneTiltIcon'\n                remixicon='RiSendPlaneLine'\n                aria-hidden\n              />\n              {reminder === 'sending'\n                ? 'Sending'\n                : reminder === 'sent'\n                  ? 'Reminder sent'\n                  : 'Send reminder'}\n            </Button>\n          )}\n        </DocumentToolbar>\n        <DocumentPage>\n          <DocumentHeader\n            brand={<DocumentBrand logo={logo} name={brand.name} detail={brand.website} />}\n            title='Invoice'\n            number={number}\n            status={<InvoiceStatusLabel status={status} />}\n          />\n          <DocumentSummary>\n            <DocumentHeadline\n              label={status === 'paid' ? 'Total paid' : 'Amount due'}\n              value={\n                status === 'paid' ? formatDocumentAmount(amounts.total, currency) : due\n              }\n            >\n              {status === 'paid' ? (\n                'Paid in full, nothing left to pay.'\n              ) : (\n                <>\n                  <span\n                    className={\n                      status === 'overdue'\n                        ? 'font-medium text-orange-700 dark:text-orange-400 print:text-black!'\n                        : undefined\n                    }\n                  >\n                    {dueWhen}\n                  </span>\n                  {amounts.paid > 0 && (\n                    <>\n                      , with{' '}\n                      <span className='tabular-nums'>\n                        {formatDocumentAmount(amounts.paid, currency)}\n                      </span>{' '}\n                      of{' '}\n                      <span className='tabular-nums'>\n                        {formatDocumentAmount(amounts.total, currency)}\n                      </span>{' '}\n                      paid\n                    </>\n                  )}\n                  .\n                </>\n              )}\n            </DocumentHeadline>\n            <DocumentMeta\n              items={[\n                { label: 'Issued', value: formatBillingDate(issueDate) },\n                { label: 'Due', value: formatBillingDate(dueDate) },\n                ...(poNumber ? [{ label: 'PO number', value: poNumber }] : []),\n              ]}\n            />\n          </DocumentSummary>\n          {state !== 'empty' && state !== 'error' && (\n            <>\n              <DocumentParties parties={[from, billTo]} />\n              <div className='flex flex-col gap-6'>\n                <LineItemsTable currency={currency} lines={lines} />\n                <DocumentTotals\n                  currency={currency}\n                  rows={getTotalRows(amounts, {\n                    discount: discountRate\n                      ? `Discount (${formatRate(discountRate)})`\n                      : undefined,\n                    paid: 'Deposit paid',\n                    tax: 'Sales tax',\n                  })}\n                />\n              </div>\n              <div className='grid gap-8 border-t pt-8 @xl/document:grid-cols-2 print:grid-cols-2'>\n                <DocumentSection title='How to pay'>\n                  {status !== 'paid' && !state && (\n                    <a\n                      href={payUrl}\n                      className={buttonVariants({\n                        className: 'w-fit print:hidden',\n                        size: 'sm',\n                        variant: 'outline',\n                      })}\n                    >\n                      Pay {due} online\n                    </a>\n                  )}\n                  {state ? (\n                    <BlockStateRows rows={4} />\n                  ) : (\n                    <>\n                      <p className='text-muted-foreground'>\n                        <span className='print:hidden'>\n                          Or transfer to the account below.\n                        </span>\n                        <span className='hidden print:inline'>\n                          Pay online at {payUrl.replace(/^https:\\/\\//, '')} or transfer to\n                          the account below.\n                        </span>{' '}\n                        Use{' '}\n                        <span className='text-foreground font-mono whitespace-nowrap'>\n                          {number}\n                        </span>{' '}\n                        as the reference.\n                      </p>\n                      <PropertyList className='mt-1'>\n                        <Property label='Bank'>{bank.bank}</Property>\n                        <Property label='Account name'>{bank.accountName}</Property>\n                        <Property label='Routing'>\n                          <span className='font-mono'>{bank.routing}</span>\n                        </Property>\n                        <Property label='Account'>\n                          <span className='font-mono'>{bank.accountNumber}</span>\n                        </Property>\n                      </PropertyList>\n                    </>\n                  )}\n                </DocumentSection>\n                <div className='flex flex-col gap-6'>\n                  <DocumentSection title='Notes'>\n                    <BlockReady>\n                      <p className='text-muted-foreground text-pretty'>{notes}</p>\n                    </BlockReady>\n                  </DocumentSection>\n                  <DocumentSection title='Terms'>\n                    <BlockReady>\n                      <p className='text-muted-foreground text-pretty'>{terms}</p>\n                    </BlockReady>\n                  </DocumentSection>\n                </div>\n              </div>\n            </>\n          )}\n          <DocumentFooter parts={footer} />\n        </DocumentPage>\n      </DocumentLayout>\n    </BlockStateProvider>\n  )\n}\n\nexport { Invoice1, exampleProps as invoice1ExampleProps, type Invoice1Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/invoice/invoice-01.tsx"
    }
  ],
  "meta": {
    "shows": "An overdue invoice with discount, sales tax, deposit and balance due, payment instructions and a reminder to send.",
    "size": "full",
    "usedWith": [
      "billing-01",
      "invoice-02"
    ],
    "component": "Invoice1",
    "props": "{ bank: { accountName: string; accountNumber: string; bank: string; routing: string }; billTo: { label: string; lines: string[]; name: string }; brand: { name: string; website: string }; currency?: string; discountRate?: number; dueDate: Date; footer: string[]; from: { label: string; lines: string[]; name: string }; issueDate: Date; lines?: { detail?: string; description: string; id: string; optional?: boolean; quantity: number; sku?: string; taxRate?: number; unit?: string; unitPrice: number }[]; notes: string; now: Date; number: string; onDownload?: () => void; onSendReminder?: () => Promise<void>; paid?: number; payUrl: string; poNumber?: string; sentTo: string; taxRate?: number; terms: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
