From f3434c06c289c336ddcdef3f28f9079fe71d2a86 Mon Sep 17 00:00:00 2001 From: myselfaryan Date: Wed, 4 Dec 2024 21:36:58 +0530 Subject: [PATCH 1/2] Create stats dashboard --- app/testings/page.tsx | 83 ++++ components/statstable.tsx | 827 ++++++++++++++++++++++++++++++++++++++ mint/unauthorized.tsx | 8 +- 3 files changed, 915 insertions(+), 3 deletions(-) create mode 100644 app/testings/page.tsx create mode 100644 components/statstable.tsx diff --git a/app/testings/page.tsx b/app/testings/page.tsx new file mode 100644 index 0000000..b10ab01 --- /dev/null +++ b/app/testings/page.tsx @@ -0,0 +1,83 @@ +'use client' +import Charts from "@/components/statstable"; + + +interface ChartData { + submissions: { + total: number; + weeklyData: Array<{ + date: string; + steps: number; + }>; + weeklyTotal: number; + }; + upcomingContest: { + count: number; + variability: number; + weeklyData: Array<{ + date: string; + resting: number; + }>; + }; + contestDetails: { + currentYear: { + year: string; + contestsPerDay: number; + }; + previousYear: { + year: string; + contestsPerDay: number; + }; + }; + } + + + export default function Page(){ + const chartData: ChartData = { + submissions: { + total: 12584, + weeklyData: [ + { date: "2024-01-01", steps: 2000 }, + { date: "2024-01-02", steps: 2100 }, + { date: "2024-01-03", steps: 2200 }, + { date: "2024-01-04", steps: 2300 }, + { date: "2024-01-05", steps: 2400 }, + { date: "2024-01-06", steps: 2500 }, + { date: "2024-01-07", steps: 2600 }, + // ... more data + ], + weeklyTotal: 5305 + }, + upcomingContest: { + count: 62, + variability: 35, + weeklyData: [ + { date: "2024-01-01", resting: 62 }, + { date: "2024-01-02", resting: 63 }, + { date: "2024-01-03", resting: 64 }, + { date: "2024-01-04", resting: 65 }, + { date: "2024-01-05", resting: 66 }, + { date: "2024-01-06", resting: 67 }, + { date: "2024-01-07", resting: 68 }, + + // ... more data + ] + }, + contestDetails: { + currentYear: { + year: "2024", + contestsPerDay: 12453 + }, + previousYear: { + year: "2023", + contestsPerDay: 10103 + } + } + }; + + return ( +
+ +
+ ); +} diff --git a/components/statstable.tsx b/components/statstable.tsx new file mode 100644 index 0000000..0d19ccf --- /dev/null +++ b/components/statstable.tsx @@ -0,0 +1,827 @@ +"use client" + +import { + Area, + AreaChart, + Bar, + BarChart, + CartesianGrid, + Label, + LabelList, + Line, + LineChart, + PolarAngleAxis, + RadialBar, + RadialBarChart, + Rectangle, + ReferenceLine, + XAxis, + YAxis, +} from "recharts" + +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from "@/components/ui/card" +import { + ChartContainer, + ChartTooltip, + ChartTooltipContent, +} from "@/components/ui/chart" +import { Separator } from "@/components/ui/separator" + +export const description = "A collection of health charts." + +interface ChartData { + submissions: { + total: number; + weeklyData: Array<{ + date: string; + steps: number; + }>; + weeklyTotal: number; + }; + upcomingContest: { + count: number; + variability: number; + weeklyData: Array<{ + date: string; + resting: number; + }>; + }; + contestDetails: { + currentYear: { + year: string; + contestsPerDay: number; + }; + previousYear: { + year: string; + contestsPerDay: number; + }; + }; +} + +export default function Charts({ data }: { data: ChartData }) { + return ( +
+
+ + + Submissions + + {data.submissions.total}{" "} + + submissions + + + + + + + } + /> + { + return new Date(value).toLocaleDateString("en-US", { + weekday: "short", + }) + }} + /> + { + return new Date(value).toLocaleDateString("en-US", { + day: "numeric", + month: "long", + year: "numeric", + }) + }} + /> + } + cursor={false} + /> + + + + + + + + Over the past 7 days, you have submitted{" "} + {data.submissions.weeklyTotal} problems. + + + + + + +
+ Upcomming Contest + + {data.upcomingContest.count} + + +
+
+ Variability + + {data.upcomingContest.variability} + + +
+
+ + + + + + { + return new Date(value).toLocaleDateString("en-US", { + weekday: "short", + }) + }} + /> + + { + return new Date(value).toLocaleDateString("en-US", { + day: "numeric", + month: "long", + year: "numeric", + }) + }} + /> + } + cursor={false} + /> + + + +
+
+
+ + + Contest Details + + + +
+
+ {data.contestDetails.currentYear.contestsPerDay} + + contests/day + +
+ + + + + + + + + +
+
+
+ {data.contestDetails.previousYear.contestsPerDay} + + contests/day + +
+ + + + + + + + + +
+
+
+ + + total contest + + + + + +
+ 1234 + + contests + +
+ + + } + /> + + + +
+
+ + + + + + + + + + + + + +
+
+
submissions
+
+ 562 + +
+
+ +
+
correct submission
+
+ 73 + +
+
+ +
+
wrong submission
+
+ 14 + +
+
+
+
+
+
+
+ + +
+
+
Submissions
+
+ 562/600 + +
+
+
+
correct submissions
+
+ 73/120 + +
+
+
+
wrong submission
+
+ 8/12 + +
+
+
+ + + + + + +
+
+ + + contests last month + + + +
+ 1,254 + +
+ + + } + /> + + + +
+
+ + + Time in platform + + 8 + + hr + + 35 + + min + + + + + + + + + + + + + + + + } + formatter={(value) => ( +
+ Time in platform +
+ {value} + + hr + +
+
+ )} + /> +
+
+
+
+
+
+ ) +} \ No newline at end of file diff --git a/mint/unauthorized.tsx b/mint/unauthorized.tsx index 60389d3..ad6a5cf 100644 --- a/mint/unauthorized.tsx +++ b/mint/unauthorized.tsx @@ -15,8 +15,10 @@ import { useContext } from "react"; export function UnauthorizedPage() { const { logout } = useContext(AuthContext); - const handleLogout = async () => { + const handleLogout = async (e: React.MouseEvent) => { + e.preventDefault(); await logout(); + window.location.href = '/'; }; return ( @@ -37,8 +39,8 @@ export function UnauthorizedPage() {

-