diff --git a/dashboard/15-final/app/dashboard/invoices/page.tsx b/dashboard/15-final/app/dashboard/invoices/page.tsx
index 403df46..dc34ed8 100644
--- a/dashboard/15-final/app/dashboard/invoices/page.tsx
+++ b/dashboard/15-final/app/dashboard/invoices/page.tsx
@@ -1,3 +1,9 @@
+import Table from "@/app/ui/table";
+
export default function Page() {
- return
List of invoices
+ return (
+
+ )
}
diff --git a/dashboard/15-final/app/dashboard/layout.tsx b/dashboard/15-final/app/dashboard/layout.tsx
index 12c6697..97baef4 100644
--- a/dashboard/15-final/app/dashboard/layout.tsx
+++ b/dashboard/15-final/app/dashboard/layout.tsx
@@ -11,4 +11,4 @@ export default function Layout({ children }: { children: React.ReactNode }) {
);
-}
+}
\ No newline at end of file
diff --git a/dashboard/15-final/app/lib/definitions.tsx b/dashboard/15-final/app/lib/definitions.tsx
index 5618fff..95c633a 100644
--- a/dashboard/15-final/app/lib/definitions.tsx
+++ b/dashboard/15-final/app/lib/definitions.tsx
@@ -18,6 +18,7 @@ export type Invoice = {
id: number
customerId: number
amount: number
+ date: string
status: "pending" | "paid" // In TypeScript, this is called a string union type.
// It means that the "status" property can only be one of the two strings.
}
diff --git a/dashboard/15-final/app/lib/dummy-data.tsx b/dashboard/15-final/app/lib/dummy-data.tsx
index 5be5b0b..bf83355 100644
--- a/dashboard/15-final/app/lib/dummy-data.tsx
+++ b/dashboard/15-final/app/lib/dummy-data.tsx
@@ -38,24 +38,28 @@ export const invoices: Invoice[] = [
id: 1,
customerId: 1,
amount: 15795,
+ date: "2021-01-01",
status: "pending",
},
{
id: 2,
customerId: 2,
amount: 20348,
+ date: "2021-02-01",
status: "pending",
},
{
id: 3,
customerId: 3,
amount: 3040,
+ date: "2021-03-01",
status: "paid",
},
{
id: 4,
customerId: 4,
amount: 44800,
+ date: "2021-04-01",
status: "paid",
},
];
diff --git a/dashboard/15-final/app/ui/table.tsx b/dashboard/15-final/app/ui/table.tsx
new file mode 100644
index 0000000..80e80fb
--- /dev/null
+++ b/dashboard/15-final/app/ui/table.tsx
@@ -0,0 +1,70 @@
+import {invoices, customers} from "../lib/dummy-data";
+import Link from "next/link";
+
+export default function Example() {
+ function getNameById(customerId: number) {
+ const customerName = customers.find(customer => customer.id === customerId);
+ return customerName ? customerName.name : null;
+ }
+ return (
+
+
+
Invoices
+
+ Add Invoice
+
+
+
+
+
+
+
+
+ |
+ ID
+ |
+
+ Customer Name
+ |
+
+ Amount
+ |
+
+ Status
+ |
+
+ Date
+ |
+
+ View
+ |
+
+
+
+ {invoices.map((invoice) => (
+
+ |
+ {invoice.id}
+ |
+ {getNameById(invoice.customerId)} |
+ {(invoice.amount / 100).toLocaleString("en-US", {style: "currency", currency: "USD"})} |
+ {invoice.status} |
+ {invoice.date} |
+
+
+ View, {invoice.id}
+
+ |
+
+ ))}
+
+
+
+
+
+
+ )
+}