2023-10-30 06:54:52 +00:00
|
|
|
import { Suspense } from "react";
|
2023-10-31 05:55:15 +00:00
|
|
|
import { Metadata } from "next";
|
2023-10-30 06:54:52 +00:00
|
|
|
import Pagination from "@/app/ui/invoices/pagination";
|
|
|
|
|
import Search from "@/app/ui/search";
|
|
|
|
|
import Table from "@/app/ui/invoices/table";
|
|
|
|
|
import { CreateInvoice } from "@/app/ui/invoices/buttons";
|
|
|
|
|
import { lusitana } from "@/app/ui/fonts";
|
|
|
|
|
import { InvoicesTableSkeleton } from "@/app/ui/skeletons";
|
2023-10-31 05:24:00 +00:00
|
|
|
import { fetchInvoicesPages } from "@/app/lib/data";
|
2023-10-30 06:54:52 +00:00
|
|
|
|
2023-10-31 05:55:15 +00:00
|
|
|
export const metadata: Metadata = {
|
|
|
|
|
title: 'Invoices',
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-30 06:54:52 +00:00
|
|
|
export default async function Page({
|
|
|
|
|
searchParams,
|
|
|
|
|
}: {
|
|
|
|
|
searchParams?: {
|
|
|
|
|
query?: string;
|
|
|
|
|
page?: string;
|
|
|
|
|
};
|
|
|
|
|
}) {
|
|
|
|
|
const query = searchParams?.query || "";
|
|
|
|
|
const currentPage = Number(searchParams?.page) || 1;
|
2023-10-31 05:24:00 +00:00
|
|
|
const totalPages = await fetchInvoicesPages(query);
|
2023-10-30 06:54:52 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="w-full">
|
|
|
|
|
<div className="flex w-full items-center justify-between">
|
|
|
|
|
<h1 className={`${lusitana.className} text-2xl`}>Invoices</h1>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="mt-4 flex items-center justify-between gap-2 md:mt-8">
|
|
|
|
|
<Search placeholder="Search invoices..." />
|
|
|
|
|
<CreateInvoice />
|
|
|
|
|
</div>
|
|
|
|
|
<Suspense key={query + currentPage} fallback={<InvoicesTableSkeleton />}>
|
|
|
|
|
<Table query={query} currentPage={currentPage} />
|
|
|
|
|
</Suspense>
|
|
|
|
|
<div className="mt-5 flex w-full justify-center">
|
2023-10-31 05:24:00 +00:00
|
|
|
<Pagination totalPages={totalPages} />
|
2023-10-30 06:54:52 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|