Skip to content

Commit ffe7d05

Browse files
committed
Add admin page
Question table should have a search functionality that searches by question name. Mantine-datatable can be used for enhanced table features in the future.
1 parent 6c33266 commit ffe7d05

File tree

4 files changed

+79
-4
lines changed

4 files changed

+79
-4
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import {
2+
Grid,
3+
useMantineTheme,
4+
Button
5+
} from "@mantine/core";
6+
7+
import StatsCard from "../components/statscard";
8+
import QuestionsTable from "~/components/table/questionstable";
9+
import type {QuestionHistory} from "../components/table/questionstable";
10+
import QueueModal from "~/components/queueupmodal/queuemodal";
11+
12+
import { useState } from "react";
13+
14+
export function meta() {
15+
return [
16+
{ title: "PeerPrep - Homepage" },
17+
{ name: "description", content: "Welcome to PeerPrep!" },
18+
];
19+
}
20+
21+
export default function Userpage() {
22+
const theme = useMantineTheme();
23+
24+
const [data, ] = useState<QuestionHistory[]>([
25+
{
26+
question: "Two Sum",
27+
dateAdded: "2024-10-01",
28+
lastEdited: "2024-10-01",
29+
difficulty: "Easy",
30+
topic: "Array",
31+
},
32+
]);
33+
34+
return (
35+
<Grid>
36+
<Grid.Col span={12}>
37+
<Grid gutter="md" align="center">
38+
<Grid.Col span={{ base: 6, md: 2 }}>
39+
<StatsCard
40+
title="Total Questions"
41+
stat="1,234"
42+
color={theme.colors.gray[0]}
43+
/>
44+
</Grid.Col>
45+
<Grid.Col span={{ base: 6, md: 2 }}>
46+
<StatsCard
47+
title="Easy"
48+
stat="1,234"
49+
color={theme.colors.green[5]}
50+
/>
51+
</Grid.Col>
52+
<Grid.Col span={{ base: 6, md: 2 }}>
53+
<StatsCard
54+
title="Medium"
55+
stat="1,234"
56+
color={theme.colors.yellow[5]}
57+
/>
58+
</Grid.Col>
59+
<Grid.Col span={{ base: 6, md: 2 }}>
60+
<StatsCard title="Hard" stat="1,234" color={theme.colors.red[5]} />
61+
</Grid.Col>
62+
<Grid.Col span={{ base: 12, md: 2 }} offset={{ md: 2 }}>
63+
<Button fullWidth onClick={() => {}}>Add Question</Button>
64+
</Grid.Col>
65+
</Grid>
66+
</Grid.Col>
67+
<Grid.Col span={12}>
68+
<QuestionsTable
69+
data={data}
70+
/>
71+
</Grid.Col>
72+
</Grid>
73+
);
74+
}

frontend/peerprep/app/pages/userpage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {
44
} from "@mantine/core";
55

66
import StatsCard from "../components/statscard";
7-
import HistoryTable from "../components/table/table";
8-
import type {InterviewHistory} from "../components/table/table";
7+
import HistoryTable from "../components/table/historytable";
8+
import type {InterviewHistory} from "../components/table/historytable";
99
import QueueModal from "~/components/queueupmodal/queuemodal";
1010

1111
import { useState } from "react";

frontend/peerprep/app/root.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ export function Layout({ children }: { children: React.ReactNode }) {
144144

145145
export default function App() {
146146
const location = useLocation();
147-
const linksWithHeader = ["/user"];
147+
const linksWithoutHeader = ["/", "/login", "/signup"];
148148

149149
const isHeader = () => {
150-
return linksWithHeader.includes(location.pathname);
150+
return !linksWithoutHeader.includes(location.pathname);
151151
};
152152

153153
return (

frontend/peerprep/app/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export default [
55
route("login", "pages/login.tsx"),
66
route("signup", "pages/signup.tsx"),
77
route("user", "pages/userpage.tsx"),
8+
route("admin", "pages/adminpage.tsx"),
89
] satisfies RouteConfig;

0 commit comments

Comments
 (0)