diff --git a/src/app/dashboard/_components/charts-client.tsx b/src/app/dashboard/_components/charts-client.tsx new file mode 100644 index 0000000..a27a8e7 --- /dev/null +++ b/src/app/dashboard/_components/charts-client.tsx @@ -0,0 +1,21 @@ +"use client"; + +import dynamic from "next/dynamic"; +import { Skeleton } from "~/components/ui/skeleton"; + +const chartSkeleton = () => ; + +export const RevenueChart = dynamic( + () => import("./revenue-chart").then((m) => m.RevenueChart), + { ssr: false, loading: chartSkeleton }, +); + +export const InvoiceStatusChart = dynamic( + () => import("./invoice-status-chart").then((m) => m.InvoiceStatusChart), + { ssr: false, loading: chartSkeleton }, +); + +export const MonthlyMetricsChart = dynamic( + () => import("./monthly-metrics-chart").then((m) => m.MonthlyMetricsChart), + { ssr: false, loading: chartSkeleton }, +); diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index e642b0f..b1e5a6f 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -20,20 +20,7 @@ import { auth } from "~/lib/auth"; import { headers } from "next/headers"; import { HydrateClient, api } from "~/trpc/server"; import type { StoredInvoiceStatus } from "~/types/invoice"; -import dynamic from "next/dynamic"; - -const RevenueChart = dynamic( - () => import("~/app/dashboard/_components/revenue-chart").then((m) => m.RevenueChart), - { ssr: false, loading: () => }, -); -const InvoiceStatusChart = dynamic( - () => import("~/app/dashboard/_components/invoice-status-chart").then((m) => m.InvoiceStatusChart), - { ssr: false, loading: () => }, -); -const MonthlyMetricsChart = dynamic( - () => import("~/app/dashboard/_components/monthly-metrics-chart").then((m) => m.MonthlyMetricsChart), - { ssr: false, loading: () => }, -); +import { RevenueChart, InvoiceStatusChart, MonthlyMetricsChart } from "~/app/dashboard/_components/charts-client"; import { AnimatedStatsCard } from "~/app/dashboard/_components/animated-stats-card"; import type { DashboardStats, RecentInvoice } from "./types";