Chapter 9 - group cards to stream them at once
This commit is contained in:
@@ -4,7 +4,8 @@ import LatestInvoices from '@/app/ui/dashboard/latest-invoices';
|
|||||||
import { lusitana } from '@/app/ui/fonts';
|
import { lusitana } from '@/app/ui/fonts';
|
||||||
import { fetchCardData} from "@/app/lib/data";
|
import { fetchCardData} from "@/app/lib/data";
|
||||||
import { Suspense } from 'react';
|
import { Suspense } from 'react';
|
||||||
import {LatestInvoicesSkeleton, RevenueChartSkeleton} from '@/app/ui/skeletons';
|
import {CardsSkeleton, LatestInvoicesSkeleton, RevenueChartSkeleton} from '@/app/ui/skeletons';
|
||||||
|
import CardWrapper from '@/app/ui/dashboard/cards';
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
|
|
||||||
|
|
||||||
@@ -20,14 +21,9 @@ export default async function Page() {
|
|||||||
Dashboard
|
Dashboard
|
||||||
</h1>
|
</h1>
|
||||||
<div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-4">
|
<div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-4">
|
||||||
<Card title="Collected" value={totalPaidInvoices} type="collected" />
|
<Suspense fallback={<CardsSkeleton />}>
|
||||||
<Card title="Pending" value={totalPendingInvoices} type="pending" />
|
<CardWrapper />
|
||||||
<Card title="Total Invoices" value={numberOfInvoices} type="invoices" />
|
</Suspense>
|
||||||
<Card
|
|
||||||
title="Total Customers"
|
|
||||||
value={numberOfCustomers}
|
|
||||||
type="customers"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-6 grid grid-cols-1 gap-6 md:grid-cols-4 lg:grid-cols-8">
|
<div className="mt-6 grid grid-cols-1 gap-6 md:grid-cols-4 lg:grid-cols-8">
|
||||||
<Suspense fallback={<RevenueChartSkeleton />}>
|
<Suspense fallback={<RevenueChartSkeleton />}>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
InboxIcon,
|
InboxIcon,
|
||||||
} from '@heroicons/react/24/outline';
|
} from '@heroicons/react/24/outline';
|
||||||
import { lusitana } from '@/app/ui/fonts';
|
import { lusitana } from '@/app/ui/fonts';
|
||||||
|
import {fetchCardData} from "@/app/lib/data";
|
||||||
|
|
||||||
const iconMap = {
|
const iconMap = {
|
||||||
collected: BanknotesIcon,
|
collected: BanknotesIcon,
|
||||||
@@ -14,18 +15,22 @@ const iconMap = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default async function CardWrapper() {
|
export default async function CardWrapper() {
|
||||||
|
const {
|
||||||
|
numberOfInvoices,
|
||||||
|
numberOfCustomers,
|
||||||
|
totalPaidInvoices,
|
||||||
|
totalPendingInvoices,
|
||||||
|
} = await fetchCardData();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* NOTE: comment in this code when you get to this point in the course */}
|
<Card title="Collected" value={totalPaidInvoices} type="collected" />
|
||||||
|
|
||||||
{/* <Card title="Collected" value={totalPaidInvoices} type="collected" />
|
|
||||||
<Card title="Pending" value={totalPendingInvoices} type="pending" />
|
<Card title="Pending" value={totalPendingInvoices} type="pending" />
|
||||||
<Card title="Total Invoices" value={numberOfInvoices} type="invoices" />
|
<Card title="Total Invoices" value={numberOfInvoices} type="invoices" />
|
||||||
<Card
|
<Card
|
||||||
title="Total Customers"
|
title="Total Customers"
|
||||||
value={numberOfCustomers}
|
value={numberOfCustomers}
|
||||||
type="customers"
|
type="customers"
|
||||||
/> */}
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user