Skip to content

Commit bdc3076

Browse files
Add pagination functionality to invoices page
1 parent 5ffbe9d commit bdc3076

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

app/dashboard/invoices/page.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,24 @@ import Pagination from '@/app/ui/invoices/pagination';
22
import Search from '@/app/ui/search';
33
import Table from '@/app/ui/invoices/table';
44
import { CreateInvoice } from '@/app/ui/invoices/buttons';
5+
import { fetchInvoicesPages } from '@/app/lib/data';
56
import { lusitana } from '@/app/ui/fonts';
67
import { InvoicesTableSkeleton } from '@/app/ui/skeletons';
78
import { Suspense } from 'react';
8-
9-
export default async function Page() {
9+
10+
export default async function Page({
11+
searchParams,
12+
}: {
13+
searchParams?: {
14+
query?: string;
15+
page?: string;
16+
};
17+
}) {
18+
const query = searchParams?.query || '';
19+
const currentPage = Number(searchParams?.page || 1);
20+
21+
const totalPages = await fetchInvoicesPages(query);
22+
1023
return (
1124
<div className="w-full">
1225
<div className="flex w-full items-center justify-between">
@@ -16,12 +29,12 @@ export default async function Page() {
1629
<Search placeholder="Search invoices..." />
1730
<CreateInvoice />
1831
</div>
19-
{/* <Suspense key={query + currentPage} fallback={<InvoicesTableSkeleton />}>
32+
<Suspense key={query + currentPage} fallback={<InvoicesTableSkeleton />}>
2033
<Table query={query} currentPage={currentPage} />
21-
</Suspense> */}
34+
</Suspense>
2235
<div className="mt-5 flex w-full justify-center">
23-
{/* <Pagination totalPages={totalPages} /> */}
36+
<Pagination totalPages={totalPages} />
2437
</div>
2538
</div>
2639
);
27-
}
40+
}

0 commit comments

Comments
 (0)