Chapter 9 - stream single component
This commit is contained in:
@@ -2,11 +2,11 @@ import { Card } from '@/app/ui/dashboard/cards';
|
|||||||
import RevenueChart from '@/app/ui/dashboard/revenue-chart';
|
import RevenueChart from '@/app/ui/dashboard/revenue-chart';
|
||||||
import LatestInvoices from '@/app/ui/dashboard/latest-invoices';
|
import LatestInvoices from '@/app/ui/dashboard/latest-invoices';
|
||||||
import { lusitana } from '@/app/ui/fonts';
|
import { lusitana } from '@/app/ui/fonts';
|
||||||
import { fetchRevenue, fetchLatestInvoices, fetchCardData} from "@/app/lib/data";
|
import { fetchLatestInvoices, fetchCardData} from "@/app/lib/data";
|
||||||
|
import { Suspense } from 'react';
|
||||||
|
import { RevenueChartSkeleton } from '@/app/ui/skeletons';
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
|
|
||||||
const revenue = await fetchRevenue();
|
|
||||||
const latestInvoices = await fetchLatestInvoices();
|
const latestInvoices = await fetchLatestInvoices();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -31,7 +31,9 @@ export default async function Page() {
|
|||||||
/>
|
/>
|
||||||
</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">
|
||||||
<RevenueChart revenue={revenue} />
|
<Suspense fallback={<RevenueChartSkeleton />}>
|
||||||
|
<RevenueChart />
|
||||||
|
</Suspense>
|
||||||
<LatestInvoices latestInvoices={latestInvoices} />
|
<LatestInvoices latestInvoices={latestInvoices} />
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -3,17 +3,17 @@ import { CalendarIcon } from '@heroicons/react/24/outline';
|
|||||||
import { lusitana } from '@/app/ui/fonts';
|
import { lusitana } from '@/app/ui/fonts';
|
||||||
import { Revenue } from '@/app/lib/definitions';
|
import { Revenue } from '@/app/lib/definitions';
|
||||||
|
|
||||||
|
import { fetchRevenue } from '@/app/lib/data';
|
||||||
|
|
||||||
// This component is representational only.
|
// This component is representational only.
|
||||||
// For data visualization UI, check out:
|
// For data visualization UI, check out:
|
||||||
// https://www.tremor.so/
|
// https://www.tremor.so/
|
||||||
// https://www.chartjs.org/
|
// https://www.chartjs.org/
|
||||||
// https://airbnb.io/visx/
|
// https://airbnb.io/visx/
|
||||||
|
|
||||||
export default async function RevenueChart({
|
|
||||||
revenue,
|
export default async function RevenueChart() { // Make component async, remove the props
|
||||||
}: {
|
const revenue = await fetchRevenue(); // Fetch data inside the component
|
||||||
revenue: Revenue[];
|
|
||||||
}) {
|
|
||||||
const chartHeight = 350;
|
const chartHeight = 350;
|
||||||
// NOTE: comment in this code when you get to this point in the course
|
// NOTE: comment in this code when you get to this point in the course
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user