|
1 |
| -"use client"; |
2 |
| - |
3 |
| -import { useEffect, useState } from "react"; |
4 |
| -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; |
5 |
| -import { Skeleton } from "@/components/ui/skeleton"; |
6 |
| -import { useAuthStore } from "@/store/AuthStore/useAuthStore"; |
7 |
| -import DashboardNavbar from "@/components/dashboardComponents/DashboardNavbar"; |
8 |
| -import { DashboardContentSkeleton } from "@/components/dashboardComponents/DashboardContentSkeleton"; |
9 |
| -import { Bar } from "react-chartjs-2"; |
10 |
| -import { Chart as ChartJS, CategoryScale, LinearScale, BarElement } from "chart.js"; |
11 |
| - |
12 |
| -ChartJS.register(CategoryScale, LinearScale, BarElement); |
13 |
| - |
14 |
| -function DashboardContent({ authUser }: any) { |
15 |
| - return ( |
16 |
| - <main className="container mx-auto p-4 space-y-6"> |
17 |
| - <h1 className="text-3xl font-bold">Welcome, {authUser?.fullName}</h1> |
18 |
| - <Card> |
19 |
| - <CardHeader> |
20 |
| - <CardTitle>Your Profile</CardTitle> |
21 |
| - </CardHeader> |
22 |
| - <CardContent className="space-y-2"> |
23 |
| - <p> |
24 |
| - <span className="font-medium">LeetCode Username:</span>{" "} |
25 |
| - {authUser?.leetcodeUsername} |
26 |
| - </p> |
27 |
| - <p> |
28 |
| - <span className="font-medium">Gender:</span> {authUser?.gender} |
29 |
| - </p> |
30 |
| - </CardContent> |
31 |
| - </Card> |
32 |
| -{/* |
33 |
| - <Card> |
34 |
| - <CardHeader> |
35 |
| - <CardTitle>LeetCode Stats</CardTitle> |
36 |
| - </CardHeader> |
37 |
| - <CardContent> |
38 |
| - <p className="text-muted-foreground"> |
39 |
| - LeetCode stats are coming soon! |
40 |
| - </p> |
41 |
| - </CardContent> |
42 |
| - </Card> */} |
43 |
| - </main> |
44 |
| - ); |
45 |
| -} |
| 1 | +import React from "react"; |
46 | 2 |
|
47 | 3 | export default function Dashboard() {
|
48 |
| - const { authUser, fetchAuthUser, authUserLoading } = useAuthStore(); |
49 |
| - const [leetcodeStats, setLeetcodeStats] = useState<any>(null); |
50 |
| - |
51 |
| - useEffect(() => { |
52 |
| - fetchAuthUser(); |
53 |
| - }, [fetchAuthUser]); |
54 |
| - |
55 |
| - // Fetch and store stats once we have the user |
56 |
| - useEffect(() => { |
57 |
| - if (authUser?.leetcodeUsername && authUser?.id) { |
58 |
| - const fetchStats = async () => { |
59 |
| - const res = await fetch( |
60 |
| - `/api/leetcode?username=${authUser.leetcodeUsername}&id=${authUser.id}`, |
61 |
| - { method: "POST" } |
62 |
| - ); |
63 |
| - if (res.ok) { |
64 |
| - const data = await res.json(); |
65 |
| - setLeetcodeStats(data.stats); |
66 |
| - } |
67 |
| - }; |
68 |
| - fetchStats(); |
69 |
| - } |
70 |
| - }, [authUser]); |
71 |
| - |
72 |
| - // Simple bar chart config |
73 |
| - const chartData = { |
74 |
| - labels: ["Easy", "Medium", "Hard"], |
75 |
| - datasets: [ |
76 |
| - { |
77 |
| - label: "Solved", |
78 |
| - data: leetcodeStats?.submitStats.acSubmissionNum?.map((i: any) => i.count) || [0, 0, 0], |
79 |
| - backgroundColor: ["#4ade80", "#fbbf24", "#ef4444"], |
80 |
| - }, |
81 |
| - ], |
82 |
| - }; |
83 |
| - |
84 | 4 | return (
|
85 |
| - <div className="min-h-screen w-full"> |
86 |
| - {authUserLoading ? ( |
87 |
| - <DashboardContentSkeleton /> |
88 |
| - ) : ( |
89 |
| - <> |
90 |
| - <DashboardContent authUser={authUser} /> |
91 |
| - {leetcodeStats && ( |
92 |
| - <div className="container mx-auto mt-6"> |
93 |
| - <h2 className="text-xl font-semibold mb-4">Your LeetCode Progress</h2> |
94 |
| - <div className="max-w-xl"> |
95 |
| - <Bar data={chartData} /> |
96 |
| - </div> |
97 |
| - </div> |
98 |
| - )} |
99 |
| - </> |
100 |
| - )} |
| 5 | + <div className="flex flex-col items-center justify-center h-full"> |
| 6 | + <h1 className="text-6xl font-bold">This is the dashboard</h1> |
101 | 7 | </div>
|
102 | 8 | );
|
103 | 9 | }
|
0 commit comments