diff --git a/client/src/routes/Leaderboard.tsx b/client/src/routes/Leaderboard.tsx index fd25ac3d..9cd41107 100644 --- a/client/src/routes/Leaderboard.tsx +++ b/client/src/routes/Leaderboard.tsx @@ -112,7 +112,7 @@ export const Leaderboard = () => { />
- {["quiz", "forum"].map((option) => ( + {(["quiz", "forum"] as const).map((option) => (
- {["newest", "oldest", "popular"].map((option) => ( - - ))} + setSortBy(e.target.value)} + className="sr-only" + /> + + {option === "newest" && "Newest"} + {option === "oldest" && "Oldest"} + {option === "popular" && "Most Popular"} + {option === "most liked" && "Most Liked"} + + + ), + )}
diff --git a/client/src/types/quiz.ts b/client/src/types/quiz.ts index bc14e130..3ff77e9d 100644 --- a/client/src/types/quiz.ts +++ b/client/src/types/quiz.ts @@ -10,33 +10,6 @@ import { union, } from "valibot"; -// const quizSchema = object({ -// id: string(), -// title: string(), -// description: string(), -// author: object({ -// full_name: string(), -// username: string(), -// avatar: string(), -// }), -// created_at: string(), -// tags: array( -// object({ -// id: string(), -// name: string(), -// }), -// ), -// type: number(), -// num_taken: number(), -// is_taken: boolean(), -// question_count: number(), -// difficulty: string(), -// rating: object({ -// score: number(), -// count: number(), -// }), -// }); - export const quizAuthorSchema = object({ full_name: string(), username: string(), @@ -75,4 +48,25 @@ export const quizOverviewSchema = object({ rating: ratingSchema, }); +export const questionsSchema = array( + object({ + id: string(), + text: string(), + options: array( + object({ + id: string(), + text: string(), + is_correct: string(), + }), + ), + selected_option_id: string(), + }), +); + +export const quizDetailsSchema = object({ + ...quizOverviewSchema.entries, + questions: questionsSchema, +}); + export type QuizOverview = InferInput; +export type QuizDetails = InferInput; diff --git a/client/src/utils.tsx b/client/src/utils.tsx index 1acb0b78..18c41f32 100644 --- a/client/src/utils.tsx +++ b/client/src/utils.tsx @@ -66,7 +66,6 @@ export const getRelativeTime = ( const minutes = Math.floor(seconds / 60); const hours = Math.floor(minutes / 60); const days = Math.floor(hours / 24); - const weeks = Math.floor(days / 7); if (seconds < 60) return rtf.format(-seconds, "second"); if (minutes < 60) return rtf.format(-minutes, "minute"); diff --git a/client/tsconfig.app.tsbuildinfo b/client/tsconfig.app.tsbuildinfo index 5092e91d..e758b867 100644 --- a/client/tsconfig.app.tsbuildinfo +++ b/client/tsconfig.app.tsbuildinfo @@ -1,42 +1 @@ -{ - "root": [ - "./src/imagelink.tsx", - "./src/constants.ts", - "./src/hooks.ts", - "./src/main.tsx", - "./src/router.tsx", - "./src/store.ts", - "./src/utils.tsx", - "./src/vite-env.d.ts", - "./src/components/button.tsx", - "./src/components/input.tsx", - "./src/components/logo.tsx", - "./src/components/navbar.tsx", - "./src/components/sprite.tsx", - "./src/components/toast.tsx", - "./src/mocks/browser.ts", - "./src/mocks/handlers.auth.ts", - "./src/mocks/handlers.quiz.ts", - "./src/mocks/mocks.auth.ts", - "./src/mocks/mocks.quiz.ts", - "./src/routes/home.data.tsx", - "./src/routes/home.tsx", - "./src/routes/id.tsx", - "./src/routes/leaderboard.data.tsx", - "./src/routes/leaderboard.tsx", - "./src/routes/login.data.ts", - "./src/routes/login.tsx", - "./src/routes/logout.data.tsx", - "./src/routes/quiz.data.tsx", - "./src/routes/quiz.tsx", - "./src/routes/quizzes.data.tsx", - "./src/routes/quizzes.tsx", - "./src/routes/register.data.ts", - "./src/routes/register.tsx", - "./src/routes/_error.tsx", - "./src/routes/_root.tsx", - "./src/types/quiz.ts", - "./src/types/user.ts" - ], - "version": "5.6.3" -} \ No newline at end of file +{"root":["./src/imagelink.tsx","./src/constants.ts","./src/hooks.ts","./src/main.tsx","./src/router.tsx","./src/store.ts","./src/utils.tsx","./src/vite-env.d.ts","./src/components/avatar.tsx","./src/components/button.tsx","./src/components/input.tsx","./src/components/logo.tsx","./src/components/navbar.tsx","./src/components/page-head.tsx","./src/components/quiz-card.tsx","./src/components/score.tsx","./src/components/sprite.tsx","./src/components/toast.tsx","./src/mocks/browser.ts","./src/mocks/handlers.auth.ts","./src/mocks/handlers.quiz.ts","./src/mocks/mocks.auth.ts","./src/mocks/mocks.quiz.ts","./src/routes/forum.tsx","./src/routes/home.data.tsx","./src/routes/home.main.tsx","./src/routes/home.tsx","./src/routes/id.tsx","./src/routes/leaderboard.data.tsx","./src/routes/leaderboard.tsx","./src/routes/login.data.ts","./src/routes/login.tsx","./src/routes/logout.data.tsx","./src/routes/quiz.data.tsx","./src/routes/quiz.tsx","./src/routes/quizzes.data.tsx","./src/routes/quizzes.tsx","./src/routes/register.data.ts","./src/routes/register.tsx","./src/routes/_error.tsx","./src/routes/_root.tsx","./src/types/mockterm.ts","./src/types/quiz.ts","./src/types/quizquestion.ts","./src/types/user.ts"],"version":"5.6.3"} \ No newline at end of file