From 8d5c7f5caddf8f17dd348aaa0866ddfaaf31444f Mon Sep 17 00:00:00 2001 From: Delba de Oliveira Date: Tue, 19 Sep 2023 15:58:44 +0100 Subject: [PATCH] Clean up --- dashboard/15-final/app/ui/dashboard/card.tsx | 2 +- .../15-final/app/ui/dashboard/overview.tsx | 69 ------------------- 2 files changed, 1 insertion(+), 70 deletions(-) delete mode 100644 dashboard/15-final/app/ui/dashboard/overview.tsx diff --git a/dashboard/15-final/app/ui/dashboard/card.tsx b/dashboard/15-final/app/ui/dashboard/card.tsx index 5d2d224b..18f8534d 100644 --- a/dashboard/15-final/app/ui/dashboard/card.tsx +++ b/dashboard/15-final/app/ui/dashboard/card.tsx @@ -18,7 +18,7 @@ export default function Card({ type, }: { title: string; - value: number | string | undefined; + value: number | string; type: 'invoices' | 'customers' | 'pending' | 'collected'; }) { const Icon = iconMap[type]; diff --git a/dashboard/15-final/app/ui/dashboard/overview.tsx b/dashboard/15-final/app/ui/dashboard/overview.tsx deleted file mode 100644 index b263076e..00000000 --- a/dashboard/15-final/app/ui/dashboard/overview.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import Card from '@/app/ui/dashboard/card'; -import RevenueChart from '@/app/ui/dashboard/revenue-chart'; -import LatestInvoices from '@/app/ui/dashboard/latest-invoices'; -import { - fetchRevenueDelayed, - fetchLatestInvoices, - fetchCounts, - fetchTotalAmountByStatus, -} from '@/app/lib/data'; - -export const dynamic = 'force-dynamic'; - -export default async function DashboardOverview() { - const [ - revenueResult, - latestInvoicesResult, - countsResult, - totalAmountByStatusResult, - ] = await Promise.allSettled([ - fetchRevenueDelayed(), - fetchLatestInvoices(), - fetchCounts(), - fetchTotalAmountByStatus(), - ]); - - let revenue; - let latestInvoices; - let numberOfInvoices; - let numberOfCustomers; - let totalPaidInvoices; - let totalPendingInvoices; - - if (revenueResult.status === 'fulfilled') { - revenue = revenueResult.value; - } - - if (latestInvoicesResult.status === 'fulfilled') { - latestInvoices = latestInvoicesResult.value; - } - - if (countsResult.status === 'fulfilled') { - numberOfInvoices = countsResult.value.numberOfInvoices; - numberOfCustomers = countsResult.value.numberOfCustomers; - } - - if (totalAmountByStatusResult.status === 'fulfilled') { - totalPaidInvoices = totalAmountByStatusResult.value.totalPaidInvoices; - totalPendingInvoices = totalAmountByStatusResult.value.totalPendingInvoices; - } - - return ( - <> -
- - - - -
-
- - -
- - ); -}