From a75881c877b3c11e67e51d7b422174e573213bb4 Mon Sep 17 00:00:00 2001 From: Paul Pan Date: Sat, 16 Mar 2024 22:07:08 +0800 Subject: [PATCH] feat: add ProfilePage --- src/pages/ProfilePage.tsx | 52 +++++++++++++++++++++++++++++++++++++++ src/routes.tsx | 17 +++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/pages/ProfilePage.tsx diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx new file mode 100644 index 0000000..5b22f54 --- /dev/null +++ b/src/pages/ProfilePage.tsx @@ -0,0 +1,52 @@ +import { lazy } from "react"; +import { useParams } from "react-router-dom"; +import { Accordion, AccordionItem, AccordionPanel, Box, Stack, Table, Tbody, Td, Tr } from "@chakra-ui/react"; + +import { useProfileQuery, UserRole } from "../app/services/user"; + +const SubmissionTable = lazy(() => import("../components/SubmissionTable")); +const TitleItem = lazy(() => import("../components/AccordionTitleItem")); + +export default function ProfilePage() { + const { id } = useParams(); + const uid = Number(id) || 0; + const { data: profile } = useProfileQuery(uid); + const roleName = Object.entries(UserRole).filter(([, v]) => v === profile?.body.role); + + const userInfoMenu = ( + + + + + + + + + + + + + + + + + + + +
Nickname{profile?.body.nick_name}
Joined at{new Date(profile?.body.meta.CreatedAt || "").toLocaleString()}
Role{(roleName.length > 0 && roleName[0][0]) || "N/A"}
+
+
+
+ ); + + return ( + <> + + + + + {userInfoMenu} + + + ); +} diff --git a/src/routes.tsx b/src/routes.tsx index fbeb0a9..ab14c68 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -13,6 +13,7 @@ const ProblemDetailPage = lazy(() => import("./pages/ProblemDetailPage")); const SubmitPage = lazy(() => import("./pages/SubmitPage")); const SubmissionListPage = lazy(() => import("./pages/SubmissionListPage")); const StatusPage = lazy(() => import("./pages/StatusPage")); +const ProfilePage = lazy(() => import("./pages/ProfilePage")); export const router: RouteObject[] = [ { @@ -68,6 +69,22 @@ export const router: RouteObject[] = [ ), }, + { + path: "profile", + element: ( + + + + ), + }, + { + path: "profile/:id", + element: ( + + + + ), + }, ], }, ];