Skip to content

Commit 92ad25d

Browse files
handle expections for failed fetch
1 parent d671629 commit 92ad25d

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

app/dashboard/invoices/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export default async function Page({
3535
<Search placeholder="Search invoices..." />
3636
<CreateInvoice />
3737
</div>
38-
<Suspense key={query + currentPage} fallback={<InvoicesTableSkeleton />}>
39-
<Table query={query} currentPage={currentPage} />
38+
<Suspense key={query ?? 0 + currentPage ?? 1} fallback={<InvoicesTableSkeleton />}>
39+
<Table query={query ?? 0} currentPage={currentPage} />
4040
</Suspense>
4141
<div className="mt-5 flex w-full justify-center">
42-
<Pagination totalPages={totalPages} />
42+
<Pagination totalPages={totalPages ?? 1} />
4343
</div>
4444
</div>
4545
);

app/ui/dashboard/cards.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ const iconMap = {
1616

1717
export default async function CardWrapper() {
1818
const {
19-
numberOfInvoices,
20-
numberOfCustomers,
21-
totalPaidInvoices,
22-
totalPendingInvoices,
23-
} = await fetchCardData();
19+
numberOfInvoices = 0,
20+
numberOfCustomers = 0,
21+
totalPaidInvoices = "0",
22+
totalPendingInvoices = "0",
23+
} = await fetchCardData() ?? {};
2424

2525
return (
2626
<>

app/ui/dashboard/latest-invoices.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default async function LatestInvoices() {
1414
</h2>
1515
<div className="flex grow flex-col justify-between rounded-xl bg-gray-50 p-4">
1616
<div className="bg-white px-6">
17-
{latestInvoices.map((invoice, i) => {
17+
{latestInvoices && latestInvoices.map((invoice, i) => {
1818
return (
1919
<div
2020
key={invoice.id}

app/ui/dashboard/revenue-chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { fetchRevenue } from '@/app/lib/data';
1010
// https://airbnb.io/visx/
1111

1212
export default async function RevenueChart() {
13-
const revenue = await fetchRevenue();
13+
const revenue = await fetchRevenue() ?? [];
1414

1515
const chartHeight = 350;
1616

0 commit comments

Comments
 (0)