MCPcopy Create free account
hub / github.com/TheOrcDev/orcish-fullstack-admin / Analytics

Function Analytics

app/admin/analytics/page.tsx:37–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35} satisfies ChartConfig;
36
37export default function Analytics() {
38 const [activeChart, setActiveChart] =
39 React.useState<keyof typeof chartConfig>("desktop");
40
41 const total = React.useMemo(
42 () => ({
43 desktop: chartData.reduce((acc, curr) => acc + curr.desktop, 0),
44 mobile: chartData.reduce((acc, curr) => acc + curr.mobile, 0),
45 }),
46 []
47 );
48
49 return (
50 <section className="flex items-center justify-center p-3 md:p-12 w-full">
51 <Card className="w-full">
52 <CardHeader className="flex flex-col items-stretch space-y-0 border-b p-0 sm:flex-row">
53 <div className="flex flex-1 flex-col justify-center gap-1 px-6 py-5 sm:py-6">
54 <CardTitle>Bar Chart - Interactive</CardTitle>
55 <CardDescription>
56 Showing total visitors for the last 3 months
57 </CardDescription>
58 </div>
59 <div className="flex">
60 {["desktop", "mobile"].map((key) => {
61 const chart = key as keyof typeof chartConfig;
62 return (
63 <button
64 key={chart}
65 data-active={activeChart === chart}
66 className="relative z-30 flex flex-1 flex-col justify-center gap-1 border-t px-6 py-4 text-left even:border-l data-[active=true]:bg-muted/50 sm:border-l sm:border-t-0 sm:px-8 sm:py-6"
67 onClick={() => setActiveChart(chart)}
68 >
69 <span className="text-xs text-muted-foreground">
70 {chartConfig[chart].label}
71 </span>
72 <span className="text-lg font-bold leading-none sm:text-3xl">
73 {total[key as keyof typeof total].toLocaleString()}
74 </span>
75 </button>
76 );
77 })}
78 </div>
79 </CardHeader>
80 <CardContent className="px-2 sm:p-6">
81 <ChartContainer
82 config={chartConfig}
83 className="aspect-auto h-[250px] w-full"
84 >
85 <BarChart
86 accessibilityLayer
87 data={chartData}
88 margin={{
89 left: 12,
90 right: 12,
91 }}
92 >
93 <CartesianGrid vertical={false} />
94 <XAxis

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected