Skip to content

Commit 72b9c84

Browse files
committed
Add admin requirement for leetcode dashboard
1 parent 3bb5d3b commit 72b9c84

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

3-
import AddQuestionDialog from "@/app/(auth)/leetcode-dashboard/AddQuestionDialog";
4-
import { LeetcodeDashboardTable } from "@/app/(auth)/leetcode-dashboard/LeetcodeDashboardTable";
3+
import AddQuestionDialog from "@/app/(auth)/leetcode-dashboard/components/AddQuestionDialog";
4+
import { LeetcodeDashboardTable } from "@/app/(auth)/leetcode-dashboard/components/LeetcodeDashboardTable";
55
import { Button } from "@/components/ui/button";
66
import Container from "@/components/ui/Container";
77
import { PlusIcon } from "lucide-react";
File renamed without changes.
File renamed without changes.

frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboardTable.tsx renamed to frontend/src/app/(auth)/leetcode-dashboard/components/LeetcodeDashboardTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
} from "@/api/leetcode-dashboard";
2929
import { QuestionMinified } from "@/types/find-match";
3030
import MoonLoader from "react-spinners/MoonLoader";
31-
import EditQuestionDialog from "@/app/(auth)/leetcode-dashboard/EditQuestionDialog";
31+
import EditQuestionDialog from "@/app/(auth)/leetcode-dashboard/components/EditQuestionDialog";
3232
import { motion } from "framer-motion";
3333
import Modal from "react-modal";
3434
import Swal from "sweetalert2";

frontend/src/app/(auth)/leetcode-dashboard/page.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
"use client";
22

3-
import { useAuth } from "@/components/auth/AuthContext";
3+
import { AuthStatus, useAuth } from "@/components/auth/AuthContext";
44
import { useState, useEffect } from "react";
55
import LandingPage from "@/app/(home)/components/landing-page/LandingPage";
66
import LeetcodeDashboard from "./LeetcodeDashboard";
7+
import { getToken } from "@/api/user";
78

8-
const Home = () => {
9-
const { token } = useAuth();
9+
const LeetcodeDashboardPage = () => {
10+
const token = getToken();
11+
const { authStatus } = useAuth();
1012
const [loading, setLoading] = useState(true);
1113

1214
// Simulate token fetching or resolving logic
@@ -20,7 +22,7 @@ const Home = () => {
2022
return null;
2123
}
2224

23-
return token ? <LeetcodeDashboard /> : <LandingPage />;
25+
return authStatus === AuthStatus.ADMIN ? <LeetcodeDashboard /> : <LandingPage />;
2426
};
2527

26-
export default Home;
28+
export default LeetcodeDashboardPage;

0 commit comments

Comments
 (0)