From 32a3529efaf562e9a661b1642d110ba1d26c8836 Mon Sep 17 00:00:00 2001 From: Stephanie Dietz <49788645+StephDietz@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:37:21 -0500 Subject: [PATCH] Update the UI for the invoices page. (#191) * table ui / invoice page * add mobile table styling * move css styles to parent * resolve comments * move create button to be inline with search * remove hey from table lol * fix awkward mobile scrolling --------- Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com> --- .../15-final/app/dashboard/invoices/page.tsx | 11 ++- dashboard/15-final/app/dashboard/layout.tsx | 2 +- dashboard/15-final/app/lib/data.ts | 2 +- .../15-final/app/ui/invoices/buttons.tsx | 15 +-- .../15-final/app/ui/invoices/pagination.tsx | 52 +++++----- dashboard/15-final/app/ui/invoices/search.tsx | 6 +- dashboard/15-final/app/ui/invoices/status.tsx | 14 +-- dashboard/15-final/app/ui/invoices/table.tsx | 94 +++++++++++++++---- 8 files changed, 132 insertions(+), 64 deletions(-) diff --git a/dashboard/15-final/app/dashboard/invoices/page.tsx b/dashboard/15-final/app/dashboard/invoices/page.tsx index c6de907..7b19125 100644 --- a/dashboard/15-final/app/dashboard/invoices/page.tsx +++ b/dashboard/15-final/app/dashboard/invoices/page.tsx @@ -3,6 +3,7 @@ import Search from '@/app/ui/invoices/search'; import { CreateInvoice } from '@/app/ui/invoices/buttons'; import Table from '@/app/ui/invoices/table'; import { fetchFilteredInvoices } from '@/app/lib/data'; +import { lusitana } from '@/app/ui/fonts'; export default async function Page({ searchParams, @@ -25,14 +26,16 @@ export default async function Page({ return (
-

Invoices

+

Invoices

+
+
+
-
- + +
-
); } diff --git a/dashboard/15-final/app/dashboard/layout.tsx b/dashboard/15-final/app/dashboard/layout.tsx index 291d5ca..024d269 100644 --- a/dashboard/15-final/app/dashboard/layout.tsx +++ b/dashboard/15-final/app/dashboard/layout.tsx @@ -6,7 +6,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
-
{children}
+
{children}
); } diff --git a/dashboard/15-final/app/lib/data.ts b/dashboard/15-final/app/lib/data.ts index 3138221..2ddced7 100644 --- a/dashboard/15-final/app/lib/data.ts +++ b/dashboard/15-final/app/lib/data.ts @@ -82,7 +82,7 @@ export async function fetchFilteredInvoices( query: string, currentPage: number, ) { - const itemsPerPage = 10; + const itemsPerPage = 6; const offset = (currentPage - 1) * itemsPerPage; try { diff --git a/dashboard/15-final/app/ui/invoices/buttons.tsx b/dashboard/15-final/app/ui/invoices/buttons.tsx index b2800cc..f3e348b 100644 --- a/dashboard/15-final/app/ui/invoices/buttons.tsx +++ b/dashboard/15-final/app/ui/invoices/buttons.tsx @@ -1,4 +1,4 @@ -import { PencilSquareIcon, TrashIcon } from '@heroicons/react/24/outline'; +import { PencilIcon, PlusIcon, TrashIcon } from '@heroicons/react/24/outline'; import Link from 'next/link'; import { deleteInvoice } from '@/app/lib/actions'; @@ -6,9 +6,10 @@ export function CreateInvoice() { return ( - Create Invoice + Create Invoice{' '} + ); } @@ -17,9 +18,9 @@ export function UpdateInvoice({ id }: { id: string }) { return ( - + ); } @@ -28,9 +29,9 @@ export function DeleteInvoice({ id }: { id: string }) { return (
- ); diff --git a/dashboard/15-final/app/ui/invoices/pagination.tsx b/dashboard/15-final/app/ui/invoices/pagination.tsx index 30ca93a..71f6f39 100644 --- a/dashboard/15-final/app/ui/invoices/pagination.tsx +++ b/dashboard/15-final/app/ui/invoices/pagination.tsx @@ -1,6 +1,6 @@ 'use client'; -import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/outline'; +import { ArrowLeftIcon, ArrowRightIcon } from '@heroicons/react/24/outline'; import { usePathname, useSearchParams } from 'next/navigation'; import clsx from 'clsx'; import Link from 'next/link'; @@ -26,46 +26,50 @@ export default function Pagination({ }; return ( -
+
- + - {allPages.map((page) => { - const PageTag = page === currentPage ? 'p' : Link; - return ( - - {page} - - ); - })} +
+ {allPages.map((page, i) => { + const PageTag = page === currentPage ? 'p' : Link; + return ( + + {page} + + ); + })} +
- +
); diff --git a/dashboard/15-final/app/ui/invoices/search.tsx b/dashboard/15-final/app/ui/invoices/search.tsx index a09b2cf..a7a3977 100644 --- a/dashboard/15-final/app/ui/invoices/search.tsx +++ b/dashboard/15-final/app/ui/invoices/search.tsx @@ -22,16 +22,16 @@ export default function Search() { }, 300); return ( -
+
-
+
{ handleSearch(e.target.value); }} diff --git a/dashboard/15-final/app/ui/invoices/status.tsx b/dashboard/15-final/app/ui/invoices/status.tsx index ce2534c..b79eb88 100644 --- a/dashboard/15-final/app/ui/invoices/status.tsx +++ b/dashboard/15-final/app/ui/invoices/status.tsx @@ -1,25 +1,27 @@ -import { CheckCircleIcon, ClockIcon } from '@heroicons/react/24/outline'; +import { CheckIcon, ClockIcon } from '@heroicons/react/24/outline'; import clsx from 'clsx'; export default function InvoiceStatus({ status }: { status: string }) { return ( {status === 'pending' ? ( <> - Pending + Pending + ) : null} {status === 'paid' ? ( <> - Paid + Paid + ) : null} diff --git a/dashboard/15-final/app/ui/invoices/table.tsx b/dashboard/15-final/app/ui/invoices/table.tsx index d8c2437..94fb312 100644 --- a/dashboard/15-final/app/ui/invoices/table.tsx +++ b/dashboard/15-final/app/ui/invoices/table.tsx @@ -9,38 +9,96 @@ export default async function InvoicesTable({ }: { invoices: InvoicesTable[]; }) { + const styles = ` + /* Round top-left and top-right corners of the first row in tbody */ + tbody tr:first-child td:first-child { + border-top-left-radius: 8px; + } + tbody tr:first-child td:last-child { + border-top-right-radius: 8px; + } + + /* Round bottom-left and bottom-right corners of the last row in tbody */ + tbody tr:last-child td:first-child { + border-bottom-left-radius: 8px; + } + tbody tr:last-child td:last-child { + border-bottom-right-radius: 8px; + } + `; return (
-
+ +
-
-
- +
+
+ {invoices?.map((invoice) => ( +
+
+
+
+ +

{invoice.name}

+
+

{invoice.email}

+
+ +
+
+
+

+ {formatCurrency(invoice.amount)} +

+

{formatDateToLocal(invoice.date)}

+
+
+ + +
+
+
+ ))} +
+
+ - - - - - - - + {invoices?.map((invoice) => ( - - + - - - - -
+ Customer + Email + Amount + Date + Status + Edit
+
{invoice.name}

+ {invoice.email} + {formatCurrency(invoice.amount)} + {formatDateToLocal(invoice.date)} + +