Skip to content

Commit 816c08d

Browse files
feat(types): add Invoice interface and related types for invoice management
1 parent 1b4c140 commit 816c08d

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import { DataTableColumnHeader } from '@/components/data-table-column-header';
2+
import DropdownMenuCopyButton from '@/components/ui-helpers/dropdown-menu-copy-button';
3+
import { Badge } from '@/components/ui/badge';
4+
import { Button } from '@/components/ui/button';
5+
import {
6+
DropdownMenu,
7+
DropdownMenuContent,
8+
DropdownMenuItem,
9+
DropdownMenuLabel,
10+
DropdownMenuSeparator,
11+
DropdownMenuTrigger,
12+
} from '@/components/ui/dropdown-menu';
13+
import { normalizeString } from '@/lib/utils';
14+
import { Invoice } from '@/types/application/invoice';
15+
import { ColumnDef } from '@tanstack/react-table';
16+
import { format } from 'date-fns';
17+
import { MoreHorizontal } from 'lucide-react';
18+
19+
export const column: ColumnDef<Invoice>[] = [
20+
{
21+
accessorKey: 'id',
22+
header: ({ column }) => <DataTableColumnHeader column={column} title="ID" />,
23+
enableSorting: true,
24+
},
25+
{
26+
accessorKey: 'consultation_date',
27+
header: ({ column }) => <DataTableColumnHeader column={column} title="Consultation Date" />,
28+
cell: ({ row }) => format(row.original.consultation_date, 'PPP'),
29+
enableSorting: true,
30+
},
31+
{
32+
accessorKey: 'amount',
33+
header: ({ column }) => <DataTableColumnHeader column={column} title="Amount" />,
34+
cell: ({ row }) => {
35+
const formattedAmount = new Intl.NumberFormat('en-US', {
36+
style: 'currency',
37+
currency: 'USD',
38+
}).format(Number.parseFloat(row.original.amount));
39+
return formattedAmount;
40+
},
41+
enableSorting: true,
42+
},
43+
{
44+
accessorKey: 'due_date',
45+
header: ({ column }) => <DataTableColumnHeader column={column} title="Due Date" />,
46+
cell: ({ row }) => format(row.original.due_date, 'PPP'),
47+
enableSorting: true,
48+
},
49+
{
50+
accessorKey: 'payment_method',
51+
header: ({ column }) => <DataTableColumnHeader column={column} title="Payment Method" />,
52+
cell: ({ row }) => normalizeString(row.original.payment_method),
53+
enableSorting: true,
54+
},
55+
{
56+
accessorKey: 'status',
57+
header: ({ column }) => <DataTableColumnHeader column={column} title="Status" />,
58+
cell: ({ row }) => {
59+
const variant = row.original.status === 'paid' ? 'default' : 'destructive';
60+
return (
61+
<Badge variant={variant} className="select-none">
62+
{normalizeString(row.original.status)}
63+
</Badge>
64+
);
65+
},
66+
enableSorting: true,
67+
},
68+
69+
{
70+
id: 'actions',
71+
cell: ({ row }) => {
72+
const notes = row.original.notes;
73+
return (
74+
<DropdownMenu>
75+
<DropdownMenuTrigger asChild>
76+
<Button variant="ghost" className="h-8 w-8 p-0">
77+
<span className="sr-only">Open menu</span>
78+
<MoreHorizontal className="h-4 w-4" />
79+
</Button>
80+
</DropdownMenuTrigger>
81+
<DropdownMenuContent align="end">
82+
<DropdownMenuLabel>Actions</DropdownMenuLabel>
83+
<DropdownMenuItem asChild>
84+
<DropdownMenuCopyButton content={notes}>Copy Notes</DropdownMenuCopyButton>
85+
</DropdownMenuItem>
86+
87+
<DropdownMenuSeparator />
88+
<DropdownMenuItem asChild>
89+
{/* TODO: Implement PDF generation */}
90+
<a href="#" target="_blank" rel="external">
91+
Generate PDF
92+
</a>
93+
</DropdownMenuItem>
94+
</DropdownMenuContent>
95+
</DropdownMenu>
96+
);
97+
},
98+
},
99+
];
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { PatientInfo } from './patient';
2+
3+
export interface Invoice {
4+
id: number;
5+
patient_info_id: number;
6+
consultation_date: string;
7+
notes: string;
8+
due_date: string;
9+
amount: string;
10+
payment_method: string;
11+
status: string;
12+
created_at: string;
13+
updated_at: string;
14+
}
15+
16+
export interface InvoiceWithRelations extends Invoice {
17+
patient_info: PatientInfo;
18+
}
19+
20+
export type PaginationInvoice = PaginationMeta<Invoice[]>;

0 commit comments

Comments
 (0)