diff --git a/.eslintrc.cjs b/.eslintrc.cjs index a92fb0b..877501b 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,42 +1,40 @@ /** @type {import("eslint").Linter.Config} */ const config = { - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": true + parser: "@typescript-eslint/parser", + parserOptions: { + project: true, }, - "plugins": [ - "@typescript-eslint" - ], - "extends": [ + plugins: ["@typescript-eslint"], + extends: [ "next/core-web-vitals", "plugin:@typescript-eslint/recommended-type-checked", - "plugin:@typescript-eslint/stylistic-type-checked" + "plugin:@typescript-eslint/stylistic-type-checked", ], - "rules": { + rules: { "@typescript-eslint/array-type": "off", "@typescript-eslint/consistent-type-definitions": "off", "@typescript-eslint/consistent-type-imports": [ "warn", { - "prefer": "type-imports", - "fixStyle": "inline-type-imports" - } + prefer: "type-imports", + fixStyle: "inline-type-imports", + }, ], "@typescript-eslint/no-unused-vars": [ "warn", { - "argsIgnorePattern": "^_" - } + argsIgnorePattern: "^_", + }, ], "@typescript-eslint/require-await": "off", "@typescript-eslint/no-misused-promises": [ "error", { - "checksVoidReturn": { - "attributes": false - } - } - ] - } -} -module.exports = config; \ No newline at end of file + checksVoidReturn: { + attributes: false, + }, + }, + ], + }, +}; +module.exports = config; diff --git a/README.md b/README.md index a63441a..d042f81 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,32 @@ - Create, delete and update questions using intutive buttons. - All our tables have sorting with pagination and caching. +

+ +#### Login Page + +image + +### Portal + +#### Dashboard +image + +#### Edit Question Page +image + +#### Question Creation Page +image + +#### Question Page +image +image + +#### Users Page + +image + +

## 🏁 Get Started diff --git a/components.json b/components.json index e587754..05e185a 100644 --- a/components.json +++ b/components.json @@ -17,4 +17,4 @@ "lib": "@/lib", "hooks": "@/hooks" } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 75d307f..d09ab46 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "build": "next build", "dev": "next dev", "lint": "next lint", - "start": "next start" + "start": "next start", + "pretty": "prettier --write \"./**/*.{js,jsx,mjs,cjs,ts,tsx,json}\"" }, "dependencies": { "@blocknote/core": "^0.15.10", diff --git a/showcase_ss/dashboard_page.png b/showcase_ss/dashboard_page.png new file mode 100644 index 0000000..aa50d7f Binary files /dev/null and b/showcase_ss/dashboard_page.png differ diff --git a/showcase_ss/edit_question_page.png b/showcase_ss/edit_question_page.png new file mode 100644 index 0000000..c28da06 Binary files /dev/null and b/showcase_ss/edit_question_page.png differ diff --git a/showcase_ss/login_page.png b/showcase_ss/login_page.png new file mode 100644 index 0000000..11e6364 Binary files /dev/null and b/showcase_ss/login_page.png differ diff --git a/showcase_ss/question_creation_page.png b/showcase_ss/question_creation_page.png new file mode 100644 index 0000000..bfe520a Binary files /dev/null and b/showcase_ss/question_creation_page.png differ diff --git a/showcase_ss/question_page.png b/showcase_ss/question_page.png new file mode 100644 index 0000000..906bbd3 Binary files /dev/null and b/showcase_ss/question_page.png differ diff --git a/showcase_ss/testcase_question_page.png b/showcase_ss/testcase_question_page.png new file mode 100644 index 0000000..41688f4 Binary files /dev/null and b/showcase_ss/testcase_question_page.png differ diff --git a/showcase_ss/users_page.png b/showcase_ss/users_page.png new file mode 100644 index 0000000..24cfe07 Binary files /dev/null and b/showcase_ss/users_page.png differ diff --git a/src/api/adminDashboard.ts b/src/api/adminDashboard.ts index 39c9b1d..f66033d 100644 --- a/src/api/adminDashboard.ts +++ b/src/api/adminDashboard.ts @@ -1,6 +1,6 @@ import { handleAPIError } from "@/lib/error"; import api from "."; -import { generateSampleLeaderboard as generateSampleLeaderBoard } from "./sampleData"; +// import { generateSampleLeaderboard as generateSampleLeaderBoard } from "./sampleData"; export interface RoundParams { round_id: number; @@ -31,10 +31,9 @@ export async function GetLeaderBoard() { .slice(0, 10); // Take the top 10 // return generateSampleLeaderBoard() - // .filter((user) => user.Score !== null) + // .filter((user) => user.Score !== null) // .sort((a, b) => b.Score! - a.Score!) // .slice(0, 10); - } catch (e) { throw handleAPIError(e); } diff --git a/src/api/interfaces.ts b/src/api/interfaces.ts index 5063411..5d648ff 100644 --- a/src/api/interfaces.ts +++ b/src/api/interfaces.ts @@ -5,14 +5,14 @@ export interface UpdateQuestionParams { input_format: string[]; points: number; round: number; - constraints: string[] ; + constraints: string[]; output_format: string[]; sample_test_input: string[]; sample_test_output: string[]; sample_explanation: string[]; } -export interface QuestionResponse { +export interface QuestionResponse { ID: string; Description: string; Title: string; @@ -27,19 +27,18 @@ export interface QuestionResponse { } export interface CreateQuestionParams { - description: string, - title: string, - input_format: string[], - points: number, - round: number, - constraints: string[], - output_format: string[], - sample_test_input: string[], - sample_test_output: string[], - sample_explanation: string[], + description: string; + title: string; + input_format: string[]; + points: number; + round: number; + constraints: string[]; + output_format: string[]; + sample_test_input: string[]; + sample_test_output: string[]; + sample_explanation: string[]; } - export interface DeleteQuestionResponse { message: string; } diff --git a/src/api/login.ts b/src/api/login.ts index 6502e29..4443837 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -11,4 +11,4 @@ export async function login(body: z.infer) { } catch (e) { throw handleAPIError(e); } -} \ No newline at end of file +} diff --git a/src/api/questions.ts b/src/api/questions.ts index cc399c6..f6f79af 100644 --- a/src/api/questions.ts +++ b/src/api/questions.ts @@ -1,10 +1,6 @@ - - import { handleAPIError } from "@/lib/error"; import api from "."; -import { generateSampleData } from "./sampleData"; - - +// import { generateSampleData } from "./sampleData"; export interface UpdateQuestionParams { id: string; @@ -13,14 +9,14 @@ export interface UpdateQuestionParams { input_format: string[]; points: number; round: number; - constraints: string[] ; + constraints: string[]; output_format: string[]; sample_test_input: string[]; sample_test_output: string[]; sample_explanation: string[]; } -export interface QuestionResponse { +export interface QuestionResponse { ID: string; Description: string; Title: string; @@ -35,19 +31,18 @@ export interface QuestionResponse { } export interface CreateQuestionParams { - description: string, - title: string, - input_format: string[], - points: number, - round: number, - constraints: string[], - output_format: string[], - sample_test_input: string[], - sample_test_output: string[], - sample_explanation: string[], + description: string; + title: string; + input_format: string[]; + points: number; + round: number; + constraints: string[]; + output_format: string[]; + sample_test_input: string[]; + sample_test_output: string[]; + sample_explanation: string[]; } - interface DeleteQuestionResponse { message: string; } @@ -66,12 +61,11 @@ export async function GetAllQuestions() { // POST REQUEST export async function CreateQuestion(data: CreateQuestionParams) { try { - console.log(data) + console.log(data); const response = await api.post("/question/create", data); return response.data; } catch (e) { - - console.log(e) + console.log(e); throw handleAPIError(e); } } @@ -95,8 +89,7 @@ export async function GetQuestionById(id: string) { // PATCH REQUEST export async function UpdateQuestion(data: UpdateQuestionParams) { - try - { + try { const response = await api.patch("/question", data); return response.data; } catch (e) { diff --git a/src/api/sampleData.ts b/src/api/sampleData.ts index d666dd5..f123fc0 100644 --- a/src/api/sampleData.ts +++ b/src/api/sampleData.ts @@ -1,4 +1,4 @@ -import { LeaderBoardUser } from "./adminDashboard"; +import { type LeaderBoardUser } from "./adminDashboard"; import { type QuestionResponse } from "./questions"; const generateSampleData = (): QuestionResponse[] => { @@ -34,7 +34,7 @@ const generateSampleLeaderboard = (): LeaderBoardUser[] => { }, { ID: "01922fc8-5e18-7c90-89ee-5f2f3e1012c8", - Name: "abc", + Name: "InRandomOrder", Score: 100000, }, { diff --git a/src/api/testcases.ts b/src/api/testcases.ts index f914f84..17c5d57 100644 --- a/src/api/testcases.ts +++ b/src/api/testcases.ts @@ -9,69 +9,63 @@ export interface TestCaseUpdateParams { } export interface TestCaseResponse { - ID: string; - ExpectedOutput: string; - Memory: number; - Input: string; - Hidden: boolean; - QuestionID: string; - Runtime: number; - } - export interface getTestcaseByQuestion - { - data: TestCaseResponse[], - message: string - } -export interface CreateTestCaseParams { - expected_output: string; - memory: number; - input: string; - hidden: boolean; - runtime: number | null; - question_iD: string; - } - export async function CreateTestCase(data: CreateTestCaseParams) { - try { - console.log("Given data" + JSON.stringify(data)) - const response = await api.post("/testcase", data); - return response.data; - } catch (e) { - - console.log(e) - throw handleAPIError(e); - } + ID: string; + ExpectedOutput: string; + Memory: number; + Input: string; + Hidden: boolean; + QuestionID: string; + Runtime: number; +} +export interface getTestcaseByQuestion { + data: TestCaseResponse[]; + message: string; +} +export interface CreateTestCaseParams { + expected_output: string; + memory: number; + input: string; + hidden: boolean; + runtime: number | null; + question_iD: string; +} +export async function CreateTestCase(data: CreateTestCaseParams) { + try { + console.log("Given data" + JSON.stringify(data)); + const response = await api.post("/testcase", data); + return response.data; + } catch (e) { + console.log(e); + throw handleAPIError(e); } - - export async function getTestcaseByQuestion(id: string) - { - try - { - const response = await api.get(`/questions/${id}/testcases`) - return response.data.data; - } - catch(e) - { - console.log(e) - // handleAPIError(e) - return [] - } +} + +export async function getTestcaseByQuestion(id: string) { + try { + const response = await api.get( + `/questions/${id}/testcases`, + ); + return response.data.data; + } catch (e) { + console.log(e); + // handleAPIError(e) + return []; } - export async function DeleteTestCase(id: string) { - try { - const response = await api.delete<{message: string}>(`/testcase/${id}`,); - return response.data; - } catch (e) { - throw handleAPIError(e); - } +} +export async function DeleteTestCase(id: string) { + try { + const response = await api.delete<{ message: string }>(`/testcase/${id}`); + return response.data; + } catch (e) { + throw handleAPIError(e); } +} - export async function UpdateTestCase(id: string, data: TestCaseUpdateParams) { - try - { - const response = await api.put(`/testcase/${id}`, data); - return response.data; - } catch (e) { - throw handleAPIError(e); - } +export async function UpdateTestCase(id: string, data: TestCaseUpdateParams) { + try { + const response = await api.put(`/testcase/${id}`, data); + return response.data; + } catch (e) { + throw handleAPIError(e); } - +} diff --git a/src/api/users.ts b/src/api/users.ts index cf95419..64c0224 100644 --- a/src/api/users.ts +++ b/src/api/users.ts @@ -1,72 +1,63 @@ import { handleAPIError } from "@/lib/error"; import api from "."; export interface User { - ID: string; - Email: string; - RegNo: string; - Password: string; - Role: string; - RoundQualified: number; - Score: number | null; - Name: string; - IsBanned: boolean; - } + ID: string; + Email: string; + RegNo: string; + Password: string; + Role: string; + RoundQualified: number; + Score: number | null; + Name: string; + IsBanned: boolean; +} export interface SetUserRoundProps { - user_ids: string[]; - round: number; - } + user_ids: string[]; + round: number; +} export async function SetUserRound(data: SetUserRoundProps) { - try { - - console.log(data) - const response = await api.post("/upgrade",{ - round: Number(data.round), - user_ids: data.user_ids, - }); - return response.data; - } catch (e) { - - console.log(e) - throw handleAPIError(e); - } + try { + console.log(data); + const response = await api.post("/upgrade", { + round: Number(data.round), + user_ids: data.user_ids, + }); + return response.data; + } catch (e) { + console.log(e); + throw handleAPIError(e); } +} -export async function GetUsers() -{ - try - { - const response = await api.get("/users"); - return response.data - } - catch(e) - { - console.log(e); - return []; - } +export async function GetUsers() { + try { + const response = await api.get("/users"); + return response.data; + } catch (e) { + console.log(e); + return []; + } } -export async function Roast(id: string) -{ - try - { - const response = await api.post<{message: string}>("/roast", {user_id: id}); - return response.data - } - catch(error) - { - throw handleAPIError(error); - } +export async function Roast(id: string) { + try { + const response = await api.post<{ message: string }>("/roast", { + user_id: id, + }); + return response.data; + } catch (error) { + throw handleAPIError(error); + } } export async function UnRoast(id: string) { - try - { - const response = await api.post<{message: string}>("/unroast",{user_id:id}) - return response.data - } - catch(error) - { - throw handleAPIError(error); - } -} \ No newline at end of file + try { + const response = await api.post<{ message: string }>("/unroast", { + user_id: id, + }); + return response.data; + } catch (error) { + throw handleAPIError(error); + } +} diff --git a/src/app/dashboard/LeaderBoardDataColumn.tsx b/src/app/dashboard/LeaderBoardDataColumn.tsx index 7c0494f..06cb0fe 100644 --- a/src/app/dashboard/LeaderBoardDataColumn.tsx +++ b/src/app/dashboard/LeaderBoardDataColumn.tsx @@ -1,38 +1,38 @@ -import { LeaderBoardUser } from "@/api/adminDashboard"; +import {type LeaderBoardUser } from "@/api/adminDashboard"; import { DataTableColumnHeader } from "@/components/Table/DataTableColumnHeader"; -import { ColumnDef, createColumnHelper } from "@tanstack/react-table"; +import { type ColumnDef, createColumnHelper } from "@tanstack/react-table"; const columnHelper = createColumnHelper(); export const LeaderBoardDataColumn = [ - // columnHelper.accessor("ID", { - // header: ({ column }) => ( - // - // ), - // enableSorting: true, - // meta: { - // className: "text-left", - // displayName: "Round", - // }, - // }), - columnHelper.accessor("Name", { - header: ({ column }) => ( - - ), - enableSorting: true, - meta: { - className: "text-center", - displayName: "Name", - }, - }), - columnHelper.accessor("Score", { - header: ({ column }) => ( - - ), - enableSorting: true, - meta: { - className: "text-center", - displayName: "Score", - }, - }), + // columnHelper.accessor("ID", { + // header: ({ column }) => ( + // + // ), + // enableSorting: true, + // meta: { + // className: "text-left", + // displayName: "Round", + // }, + // }), + columnHelper.accessor("Name", { + header: ({ column }) => ( + + ), + enableSorting: true, + meta: { + className: "text-center", + displayName: "Name", + }, + }), + columnHelper.accessor("Score", { + header: ({ column }) => ( + + ), + enableSorting: true, + meta: { + className: "text-center", + displayName: "Score", + }, + }), ] as ColumnDef[]; diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index 68a477f..8b756bf 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -1,17 +1,8 @@ "use client"; -import { GetLeaderBoard, LeaderBoardUser } from "@/api/adminDashboard"; +import { GetLeaderBoard,type LeaderBoardUser } from "@/api/adminDashboard"; import Round from "@/components/round"; -import { - Table, - TableBody, - // TableCaption, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; + import { useQuery } from "@tanstack/react-query"; -import { table } from "console"; function Dashboard() { const { data, error, isLoading } = useQuery({ @@ -30,7 +21,16 @@ function Dashboard() {
Leaderboard
- {data && data.length > 0 ? ( + {/* Add Loading and Error Handling here */} + {isLoading ? ( +
+

Loading leaderboard...

+
+ ) : error ? ( +
+

Error loading leaderboard: {error.message}

+
+ ) : data && data.length > 0 ? (

No data available

)} +
{data?.slice(3, 6).map((user, index) => ( diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 93a4dde..5ea563e 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -23,7 +23,7 @@ export const metadata: Metadata = { "VIT", "Vellore Institute of Technology", "CodeChef-VIT", - "Cookoff" + "Cookoff", ], }; export default function RootLayout({ @@ -33,8 +33,7 @@ export default function RootLayout({ -
- +
{children}
diff --git a/src/app/page.tsx b/src/app/page.tsx index 6b028e1..8a27fe8 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -55,9 +55,7 @@ export default function Login() { width={580} height={400} /> -
- -
+
diff --git a/src/app/question/ModalCreate.tsx b/src/app/question/ModalCreate.tsx index 051f3df..7c58636 100644 --- a/src/app/question/ModalCreate.tsx +++ b/src/app/question/ModalCreate.tsx @@ -1,12 +1,18 @@ import { Button } from "@/components/ui/button"; -import {useRouter} from 'next/navigation' +import { useRouter } from "next/navigation"; const CreateButton = ({ children }: { children: React.ReactNode }) => { const router = useRouter(); return ( - + ); }; diff --git a/src/app/question/ModalCreateTestcase.tsx b/src/app/question/ModalCreateTestcase.tsx index ce8935c..c6528d5 100644 --- a/src/app/question/ModalCreateTestcase.tsx +++ b/src/app/question/ModalCreateTestcase.tsx @@ -1,5 +1,3 @@ - - import { CreateTestCase, type CreateTestCaseParams } from "@/api/testcases"; // Update import import { Button } from "@/components/ui/button"; import { @@ -15,30 +13,32 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { useMutation, useQueryClient } from "@tanstack/react-query"; -import {type ApiError } from "next/dist/server/api-utils"; +import { type ApiError } from "next/dist/server/api-utils"; import { useState } from "react"; import { useForm } from "react-hook-form"; import toast from "react-hot-toast"; -const CreateTestcaseButton = ({ id, children }: { id:string, children: React.ReactNode }) => { +const CreateTestcaseButton = ({ + id, + children, +}: { + id: string; + children: React.ReactNode; +}) => { const [isOpen, setIsOpen] = useState(false); const queryClient = useQueryClient(); - const { - register, - handleSubmit, - reset, - } = useForm(); + const { register, handleSubmit, reset } = useForm(); const createTestCase = useMutation({ mutationFn: (data: CreateTestCaseParams) => { - data.question_iD = id; - if (typeof data.hidden === "string") { - data.hidden = data.hidden === "true"; // Convert "true"/"false" to boolean - } - data.memory = Number(data.memory); - data.runtime = Number(data.runtime); - console.log(data); // Logging for debugging + data.question_iD = id; + if (typeof data.hidden === "string") { + data.hidden = data.hidden === "true"; // Convert "true"/"false" to boolean + } + data.memory = Number(data.memory); + data.runtime = Number(data.runtime); + console.log(data); // Logging for debugging return toast.promise(CreateTestCase(data), { loading: "Adding Test Case", success: "Success!", @@ -135,7 +135,6 @@ const CreateTestcaseButton = ({ id, children }: { id:string, children: React.Rea {...register("runtime")} />
- @@ -148,6 +147,3 @@ const CreateTestcaseButton = ({ id, children }: { id:string, children: React.Rea }; export default CreateTestcaseButton; - - - diff --git a/src/app/question/ModalDelete.tsx b/src/app/question/ModalDelete.tsx index c26d2bc..f8a7842 100644 --- a/src/app/question/ModalDelete.tsx +++ b/src/app/question/ModalDelete.tsx @@ -18,7 +18,6 @@ import { type ApiError } from "next/dist/server/api-utils"; import toast from "react-hot-toast"; import { useMutation, useQueryClient } from "@tanstack/react-query"; - const ModalDelete = ({ children, id, @@ -27,36 +26,28 @@ const ModalDelete = ({ children: React.ReactNode; id: string; }) => { - const queryClient = useQueryClient() - - + const queryClient = useQueryClient(); - const handleDelete = useMutation({ - mutationFn: (id: string) => { - return toast.promise( - DeleteQuestion(id), - { - loading: "Deleting Question", - success: "Success!", - error: (err: ApiError) => err.message, - })}, - onSuccess: async () => { - await queryClient.invalidateQueries({ queryKey: ["questions"] }) - - }, - - }) - - const onSubmit = () => { - handleDelete.mutate(id) - } - + const handleDelete = useMutation({ + mutationFn: (id: string) => { + return toast.promise(DeleteQuestion(id), { + loading: "Deleting Question", + success: "Success!", + error: (err: ApiError) => err.message, + }); + }, + onSuccess: async () => { + await queryClient.invalidateQueries({ queryKey: ["questions"] }); + }, + }); - + const onSubmit = () => { + handleDelete.mutate(id); + }; return ( - + {children} diff --git a/src/app/question/ModalGetTestcase.tsx b/src/app/question/ModalGetTestcase.tsx index 485caf9..a0c6ca7 100644 --- a/src/app/question/ModalGetTestcase.tsx +++ b/src/app/question/ModalGetTestcase.tsx @@ -24,23 +24,23 @@ const Page = ({ id }: { id: string }) => { }); console.log(data); return ( -
+
- + QID: {id} {" "} A table all about test cases -
+
Create -
+
{ ); }; +// const ModalDetails = ({ +// id, +// children, +// }: { +// id: string; +// children: React.ReactNode; +// }) => { +// // const [testcase] +// }; export default Page; diff --git a/src/app/question/ModalTestcaseDelete.tsx b/src/app/question/ModalTestcaseDelete.tsx index 1491080..49a0942 100644 --- a/src/app/question/ModalTestcaseDelete.tsx +++ b/src/app/question/ModalTestcaseDelete.tsx @@ -13,7 +13,7 @@ import { AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { useMutation, useQueryClient } from "@tanstack/react-query"; -import {type ApiError } from "next/dist/server/api-utils"; +import { type ApiError } from "next/dist/server/api-utils"; import toast from "react-hot-toast"; const ModalDelete = ({ diff --git a/src/app/question/ModalTestcaseUpdate.tsx b/src/app/question/ModalTestcaseUpdate.tsx index 638951b..38600ad 100644 --- a/src/app/question/ModalTestcaseUpdate.tsx +++ b/src/app/question/ModalTestcaseUpdate.tsx @@ -1,6 +1,10 @@ "use client"; -import {type TestCaseResponse,type TestCaseUpdateParams, UpdateTestCase } from "@/api/testcases"; +import { + type TestCaseResponse, + type TestCaseUpdateParams, + UpdateTestCase, +} from "@/api/testcases"; import { Button } from "@/components/ui/button"; import { Dialog, @@ -42,7 +46,7 @@ const ModalTestcaseUpdate = ({ const createQuestion = useMutation({ mutationFn: (data: TestCaseUpdateParams) => { if (typeof data.hidden === "string") { - data.hidden = data.hidden === "true"; // Convert "true"/"false" to boolean + data.hidden = data.hidden === "true"; // Convert "true"/"false" to boolean } data.memory = Number(data.memory); data.runtime = Number(data.runtime); @@ -56,7 +60,7 @@ const ModalTestcaseUpdate = ({ onSuccess: async () => { await queryClient.invalidateQueries({ queryKey: ["testcases"] }); reset(); - setModalOpen(false) + setModalOpen(false); // setIsOpen(false); }, }); @@ -66,12 +70,10 @@ const ModalTestcaseUpdate = ({ }; return (
- - {/* */} + + {/* */} -
+
{children}
@@ -145,7 +147,6 @@ const ModalTestcaseUpdate = ({ {...register("runtime")} />
-
diff --git a/src/app/question/ModalUpdate.tsx b/src/app/question/ModalUpdate.tsx index cc007f4..8100f25 100644 --- a/src/app/question/ModalUpdate.tsx +++ b/src/app/question/ModalUpdate.tsx @@ -1,12 +1,24 @@ -import { Button } from "@/components/ui/button" -import {useRouter} from "next/navigation" +import { useRouter } from "next/navigation"; -const ModalUpdate = ({id, children}: {id:string, children: React.ReactNode;}) => -{ - const router = useRouter() - console.log(id) - return(
{router.push(`/question/create/${id}`)}}>{children}
) - -} +const ModalUpdate = ({ + id, + children, +}: { + id: string; + children: React.ReactNode; +}) => { + const router = useRouter(); + console.log(id); + return ( +
{ + router.push(`/question/create/${id}`); + }} + > + {children} +
+ ); +}; export default ModalUpdate; diff --git a/src/app/question/ModalView.tsx b/src/app/question/ModalView.tsx index 77230fe..76f86c5 100644 --- a/src/app/question/ModalView.tsx +++ b/src/app/question/ModalView.tsx @@ -24,7 +24,6 @@ const ModalDetails = ({
-
@@ -68,7 +67,6 @@ const ModalDetails = ({ label="Constraints: " content={row.original.Constraints?.join("\n")} /> -
diff --git a/src/app/question/TestcaseColumns.tsx b/src/app/question/TestcaseColumns.tsx index 163c929..2e8b712 100644 --- a/src/app/question/TestcaseColumns.tsx +++ b/src/app/question/TestcaseColumns.tsx @@ -10,7 +10,6 @@ import ModalTestcaseUpdate from "./ModalTestcaseUpdate"; const columnHelper = createColumnHelper(); export const TestcaseDataColumn = [ - columnHelper.accessor("ID", { header: ({ column }) => ( @@ -41,7 +40,9 @@ export const TestcaseDataColumn = [
- +
diff --git a/src/app/question/create/[qid]/page.tsx b/src/app/question/create/[qid]/page.tsx index ec5bff3..9c49cff 100644 --- a/src/app/question/create/[qid]/page.tsx +++ b/src/app/question/create/[qid]/page.tsx @@ -27,32 +27,88 @@ const CreateButton = () => { const router = useRouter(); const [question, setQuestion] = useState(); const [description, setDescription] = useState("teri-mummy"); + + const [sampleInputs, setSampleInputs] = useState([""]); + const [sampleOutputs, setSampleOutputs] = useState([""]); + const [explanations, setExplanations] = useState([""]); + const [inputFormats, setInputFormats] = useState([""]); const queryClient = useQueryClient(); + const handleInputChange = (index: number, value: string, type: string) => { + if (type === "input") { + const newInputs = [...sampleInputs]; + newInputs[index] = value; + setSampleInputs(newInputs); + } else if (type === "output") { + const newOutputs = [...sampleOutputs]; + newOutputs[index] = value; + setSampleOutputs(newOutputs); + } else if (type === "explanation") { + const newExplanations = [...explanations]; + newExplanations[index] = value; + setExplanations(newExplanations); + } else if (type === "format") { + const newFormats = [...inputFormats]; + newFormats[index] = value; + setInputFormats(newFormats); + } + }; + + const deleteEntry = (index: number, type: string) => { + if (type === "input") { + setSampleInputs(sampleInputs.filter((_, i) => i !== index)); + } else if (type === "output") { + setSampleOutputs(sampleOutputs.filter((_, i) => i !== index)); + } else if (type === "explanation") { + setExplanations(explanations.filter((_, i) => i !== index)); + } else if (type === "format") { + setInputFormats(inputFormats.filter((_, i) => i !== index)); + } + }; + + const { setValue, register, handleSubmit, reset } = + useForm(); + useEffect(() => { - void toast.promise( - GetQuestionById(params.qid).then(async (q) => { + const fetchQuestion = async () => { + try { + const q = await GetQuestionById(params.qid); + setQuestion(q); - }), - { - loading: "Getting Question", - success: "Success!", - error: (err: ApiError) => err.message, - }, - ); - }, [params.qid]); - const { register, handleSubmit, reset } = useForm(); + setDescription(q.Description); + setExplanations(q.Explanation); + setInputFormats(q.InputFormat); + setSampleOutputs(q.SampleTestOutput); + setSampleInputs(q.SampleTestInput); + + if (q.Constraints) { + setValue("constraints.0", q.Constraints.join("\n")); + } + if (q.OutputFormat) { + setValue("output_format.0", q.OutputFormat.join("\n")); + } + if (q.Round) { + setValue("round", q.Round); + } + } catch (error) { + console.error("Error fetching question:", error); + } + }; + + void fetchQuestion(); + }, [params.qid, setValue]); + const createQuestion = useMutation({ mutationFn: (data: UpdateQuestionParams) => { data.id = params.qid; - data.input_format = data.input_format?.[0]?.split("\n") ?? []; + data.input_format = inputFormats; data.points = +data.points; data.round = +data.round; data.constraints = data.constraints?.[0]?.split("\n") ?? []; data.output_format = data.output_format?.[0]?.split("\n") ?? []; - data.sample_test_input = data.sample_test_input?.[0]?.split("\n") ?? []; - data.sample_test_output = data.sample_test_output?.[0]?.split("\n") ?? []; - data.sample_explanation = data.sample_explanation?.[0]?.split("\n") ?? []; - console.log(data); + data.sample_test_input = sampleInputs; + data.sample_test_output = sampleOutputs; + data.sample_explanation = explanations; + console.log("data", data); return toast.promise(UpdateQuestion(data), { loading: "Updating Question", success: "Success!", @@ -69,6 +125,21 @@ const CreateButton = () => { const onSubmit = (data: UpdateQuestionParams) => { createQuestion.mutate(data); }; + const addSampleInput = () => { + setSampleInputs([...sampleInputs, ""]); + }; + + const addSampleOutput = () => { + setSampleOutputs([...sampleOutputs, ""]); + }; + + const addExplanation = () => { + setExplanations([...explanations, ""]); + }; + + const addInputFormat = () => { + setInputFormats([...inputFormats, ""]); + }; return (
@@ -79,7 +150,7 @@ const CreateButton = () => {
@@ -102,7 +173,7 @@ const CreateButton = () => { {/* */} - {description} + + {description} +
diff --git a/src/app/question/page.tsx b/src/app/question/page.tsx index 73d20da..f692a89 100644 --- a/src/app/question/page.tsx +++ b/src/app/question/page.tsx @@ -15,7 +15,7 @@ const Page = () => {
- {data && Create} + Create
( ), - + enableSorting: true, enableHiding: false, meta: { @@ -85,17 +85,13 @@ export const QuestionsDataColumn = [ }, cell: ({ row }) => ( -
+
- Delete - - Update - - -
- + Update +
+
), }), @@ -110,10 +106,7 @@ export const QuestionsDataColumn = [ }, cell: ({ row }) => (
- - - - +
), }), diff --git a/src/app/users/page.tsx b/src/app/users/page.tsx index 0579b2b..371975b 100644 --- a/src/app/users/page.tsx +++ b/src/app/users/page.tsx @@ -3,7 +3,7 @@ import ClientTable from "@/components/Table/ClientTable"; import { useQuery } from "@tanstack/react-query"; // import "./ModalCreate"; // import CreateButton from "./ModalCreate"; -import { GetUsers,type User } from "@/api/users"; +import { GetUsers, type User } from "@/api/users"; import { UserDataColumn } from "./user-columns"; const Page = () => { const { data, error, isLoading } = useQuery({ diff --git a/src/app/users/user-ban.tsx b/src/app/users/user-ban.tsx index 0bb8af9..42decb9 100644 --- a/src/app/users/user-ban.tsx +++ b/src/app/users/user-ban.tsx @@ -2,7 +2,7 @@ import { Roast, UnRoast, type User } from "@/api/users"; import { Button } from "@/components/ui/button"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { type Row } from "@tanstack/react-table"; -import {type ApiError } from "next/dist/server/api-utils"; +import { type ApiError } from "next/dist/server/api-utils"; import toast from "react-hot-toast"; const BanBtn = ({ row }: { row: Row }) => { const queryClient = useQueryClient(); @@ -36,16 +36,23 @@ const BanBtn = ({ row }: { row: Row }) => { }; const onunRoastSubmit = (id: string) => { handleUnban.mutate(id); - } + }; return (
{row.original.IsBanned ? (
- +
) : (
{" "}
- )}
); diff --git a/src/app/users/user-columns.tsx b/src/app/users/user-columns.tsx index 6390a2a..0e785bb 100644 --- a/src/app/users/user-columns.tsx +++ b/src/app/users/user-columns.tsx @@ -1,4 +1,4 @@ -import { type User } from "@/api/users"; +import { type User } from "@/api/users"; import { DataTableColumnHeader } from "@/components/Table/DataTableColumnHeader"; import { Checkbox } from "@/components/ui/checkbox"; import { type ColumnDef, createColumnHelper } from "@tanstack/react-table"; @@ -33,33 +33,33 @@ export const UserDataColumn = [ enableSorting: false, enableHiding: false, }, - columnHelper.accessor("Name", { - header: ({ column }) => ( - - ), - cell: ({ row }) => ( -
- {row.original.Role === "admin" && } - {row.getValue("Name")} -
- ), - enableSorting: true, - enableHiding: false, - meta: { - className: "text-left", - displayName: "Name", - }, - }), -// columnHelper.accessor("Name", { -// header: ({ column }) => ( -// -// ), -// enableSorting: true, -// meta: { -// className: "text-left", -// displayName: "Name", -// }, -// }), + columnHelper.accessor("Name", { + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
+ {row.original.Role === "admin" && } + {row.getValue("Name")} +
+ ), + enableSorting: true, + enableHiding: false, + meta: { + className: "text-left", + displayName: "Name", + }, + }), + // columnHelper.accessor("Name", { + // header: ({ column }) => ( + // + // ), + // enableSorting: true, + // meta: { + // className: "text-left", + // displayName: "Name", + // }, + // }), columnHelper.accessor("RegNo", { header: ({ column }) => ( @@ -113,9 +113,7 @@ export const UserDataColumn = [ cell: ({ row }) => (
-
), }), ] as ColumnDef[]; - diff --git a/src/components/AreyBC.tsx b/src/components/AreyBC.tsx index 74561fe..06dbffb 100644 --- a/src/components/AreyBC.tsx +++ b/src/components/AreyBC.tsx @@ -10,8 +10,9 @@ const AreyBC = ({ children }: { children: React.ReactNode }) => { return (
-
- +
{children}
diff --git a/src/components/Table/DataTableRowActions.tsx b/src/components/Table/DataTableRowActions.tsx index 0d79f6f..7719c4a 100644 --- a/src/components/Table/DataTableRowActions.tsx +++ b/src/components/Table/DataTableRowActions.tsx @@ -1,24 +1,27 @@ -"use client" - - -import { RiMoreFill } from "react-icons/ri" -import {type Row } from "@tanstack/react-table" -import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../ui/dropdown-menu" -import { Button } from "../ui/button" +"use client"; +import { RiMoreFill } from "react-icons/ri"; +import { type Row } from "@tanstack/react-table"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "../ui/dropdown-menu"; +import { Button } from "../ui/button"; interface Action { - label: string - onClick: (row: Row) => void - className?: string + label: string; + onClick: (row: Row) => void; + className?: string; } interface DataTableRowActionsProps { - row: Row - editAction?: Action - destructiveAction?: Action - additionalActions?: Action[] - children?: React.ReactNode + row: Row; + editAction?: Action; + destructiveAction?: Action; + additionalActions?: Action[]; + children?: React.ReactNode; } export function DataTableRowActions({ @@ -70,5 +73,5 @@ export function DataTableRowActions({ {children} - ) + ); } diff --git a/src/components/Table/DataTableToolbar.tsx b/src/components/Table/DataTableToolbar.tsx index d13d597..15dce7d 100644 --- a/src/components/Table/DataTableToolbar.tsx +++ b/src/components/Table/DataTableToolbar.tsx @@ -36,14 +36,10 @@ export function DataTableToolbar({ }: DataTableToolbarProps) { const queryClient = useQueryClient(); const [isOpen, setIsOpen] = useState(false); - const [rowsPerPage, setRowsPerPage] = useState(10); // State for rows per page + // const [rowsPerPage, setRowsPerPage] = useState(10); // State for rows per page const pathname = usePathname(); - const { - register, - handleSubmit, - setValue, - reset, - } = useForm(); + const { register, handleSubmit, setValue, reset } = + useForm(); const promoteUsers = useMutation({ mutationFn: (data: SetUserRoundProps) => { diff --git a/src/components/Table/TanstackTable.d.ts b/src/components/Table/TanstackTable.d.ts index 3a49015..a37facc 100644 --- a/src/components/Table/TanstackTable.d.ts +++ b/src/components/Table/TanstackTable.d.ts @@ -1,8 +1,8 @@ -import "@tanstack/react-table" +import "@tanstack/react-table"; declare module "@tanstack/react-table" { - interface ColumnMeta { - className?: string - displayName: string + interface ColumnMeta<> { + className?: string; + displayName: string; } } diff --git a/src/components/round.tsx b/src/components/round.tsx index 8cd9306..bb18d09 100644 --- a/src/components/round.tsx +++ b/src/components/round.tsx @@ -11,10 +11,8 @@ import { AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; -import { Button } from "@/components/ui/button"; -import { useForm } from "react-hook-form"; import toast from "react-hot-toast"; -import { ApiError } from "next/dist/server/api-utils"; +import { type ApiError } from "next/dist/server/api-utils"; import { RoundEnable } from "@/api/adminDashboard"; const Round = () => { @@ -33,10 +31,13 @@ const Round = () => { onChange={(e) => { setRound(Number(e.target.value)); }} - defaultValue="1" + defaultValue="" id="round" className="rounded-md border bg-gray-200 p-2 text-black" > + diff --git a/src/components/ui/alert-dialog.tsx b/src/components/ui/alert-dialog.tsx index 57760f2..f69596f 100644 --- a/src/components/ui/alert-dialog.tsx +++ b/src/components/ui/alert-dialog.tsx @@ -1,16 +1,16 @@ -"use client" +"use client"; -import * as React from "react" -import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" +import * as React from "react"; +import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"; -import { cn } from "@/lib/utils" -import { buttonVariants } from "@/components/ui/button" +import { cn } from "@/lib/utils"; +import { buttonVariants } from "@/components/ui/button"; -const AlertDialog = AlertDialogPrimitive.Root +const AlertDialog = AlertDialogPrimitive.Root; -const AlertDialogTrigger = AlertDialogPrimitive.Trigger +const AlertDialogTrigger = AlertDialogPrimitive.Trigger; -const AlertDialogPortal = AlertDialogPrimitive.Portal +const AlertDialogPortal = AlertDialogPrimitive.Portal; const AlertDialogOverlay = React.forwardRef< React.ElementRef, @@ -19,13 +19,13 @@ const AlertDialogOverlay = React.forwardRef< -)) -AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName +)); +AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName; const AlertDialogContent = React.forwardRef< React.ElementRef, @@ -37,13 +37,13 @@ const AlertDialogContent = React.forwardRef< ref={ref} className={cn( "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg", - className + className, )} {...props} /> -)) -AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName +)); +AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName; const AlertDialogHeader = ({ className, @@ -52,12 +52,12 @@ const AlertDialogHeader = ({
-) -AlertDialogHeader.displayName = "AlertDialogHeader" +); +AlertDialogHeader.displayName = "AlertDialogHeader"; const AlertDialogFooter = ({ className, @@ -66,12 +66,12 @@ const AlertDialogFooter = ({
-) -AlertDialogFooter.displayName = "AlertDialogFooter" +); +AlertDialogFooter.displayName = "AlertDialogFooter"; const AlertDialogTitle = React.forwardRef< React.ElementRef, @@ -82,8 +82,8 @@ const AlertDialogTitle = React.forwardRef< className={cn("text-lg font-semibold", className)} {...props} /> -)) -AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName +)); +AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName; const AlertDialogDescription = React.forwardRef< React.ElementRef, @@ -94,9 +94,9 @@ const AlertDialogDescription = React.forwardRef< className={cn("text-sm text-muted-foreground", className)} {...props} /> -)) +)); AlertDialogDescription.displayName = - AlertDialogPrimitive.Description.displayName + AlertDialogPrimitive.Description.displayName; const AlertDialogAction = React.forwardRef< React.ElementRef, @@ -107,8 +107,8 @@ const AlertDialogAction = React.forwardRef< className={cn(buttonVariants(), className)} {...props} /> -)) -AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName +)); +AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName; const AlertDialogCancel = React.forwardRef< React.ElementRef, @@ -119,12 +119,12 @@ const AlertDialogCancel = React.forwardRef< className={cn( buttonVariants({ variant: "outline" }), "mt-2 sm:mt-0", - className + className, )} {...props} /> -)) -AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName +)); +AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName; export { AlertDialog, @@ -138,4 +138,4 @@ export { AlertDialogDescription, AlertDialogAction, AlertDialogCancel, -} +}; diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx index 0270f64..225e113 100644 --- a/src/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -1,8 +1,8 @@ -import * as React from "react" -import { Slot } from "@radix-ui/react-slot" -import { cva, type VariantProps } from "class-variance-authority" +import * as React from "react"; +import { Slot } from "@radix-ui/react-slot"; +import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const buttonVariants = cva( "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50", @@ -31,27 +31,27 @@ const buttonVariants = cva( variant: "default", size: "default", }, - } -) + }, +); export interface ButtonProps extends React.ButtonHTMLAttributes, VariantProps { - asChild?: boolean + asChild?: boolean; } const Button = React.forwardRef( ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : "button" + const Comp = asChild ? Slot : "button"; return ( - ) - } -) -Button.displayName = "Button" + ); + }, +); +Button.displayName = "Button"; -export { Button, buttonVariants } +export { Button, buttonVariants }; diff --git a/src/components/ui/checkbox.tsx b/src/components/ui/checkbox.tsx index 7d2b3c3..6d36331 100644 --- a/src/components/ui/checkbox.tsx +++ b/src/components/ui/checkbox.tsx @@ -1,10 +1,10 @@ -"use client" +"use client"; -import * as React from "react" -import * as CheckboxPrimitive from "@radix-ui/react-checkbox" -import { CheckIcon } from "@radix-ui/react-icons" +import * as React from "react"; +import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; +import { CheckIcon } from "@radix-ui/react-icons"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const Checkbox = React.forwardRef< React.ElementRef, @@ -14,7 +14,7 @@ const Checkbox = React.forwardRef< ref={ref} className={cn( "peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", - className + className, )} {...props} > @@ -24,7 +24,7 @@ const Checkbox = React.forwardRef< -)) -Checkbox.displayName = CheckboxPrimitive.Root.displayName +)); +Checkbox.displayName = CheckboxPrimitive.Root.displayName; -export { Checkbox } +export { Checkbox }; diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx index 95b0d38..3676f3e 100644 --- a/src/components/ui/dialog.tsx +++ b/src/components/ui/dialog.tsx @@ -1,18 +1,18 @@ -"use client" +"use client"; -import * as React from "react" -import * as DialogPrimitive from "@radix-ui/react-dialog" -import { Cross2Icon } from "@radix-ui/react-icons" +import * as React from "react"; +import * as DialogPrimitive from "@radix-ui/react-dialog"; +import { Cross2Icon } from "@radix-ui/react-icons"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; -const Dialog = DialogPrimitive.Root +const Dialog = DialogPrimitive.Root; -const DialogTrigger = DialogPrimitive.Trigger +const DialogTrigger = DialogPrimitive.Trigger; -const DialogPortal = DialogPrimitive.Portal +const DialogPortal = DialogPrimitive.Portal; -const DialogClose = DialogPrimitive.Close +const DialogClose = DialogPrimitive.Close; const DialogOverlay = React.forwardRef< React.ElementRef, @@ -21,13 +21,13 @@ const DialogOverlay = React.forwardRef< -)) -DialogOverlay.displayName = DialogPrimitive.Overlay.displayName +)); +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; const DialogContent = React.forwardRef< React.ElementRef, @@ -39,7 +39,7 @@ const DialogContent = React.forwardRef< ref={ref} className={cn( "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg", - className + className, )} {...props} > @@ -50,8 +50,8 @@ const DialogContent = React.forwardRef< -)) -DialogContent.displayName = DialogPrimitive.Content.displayName +)); +DialogContent.displayName = DialogPrimitive.Content.displayName; const DialogHeader = ({ className, @@ -60,12 +60,12 @@ const DialogHeader = ({
-) -DialogHeader.displayName = "DialogHeader" +); +DialogHeader.displayName = "DialogHeader"; const DialogFooter = ({ className, @@ -74,12 +74,12 @@ const DialogFooter = ({
-) -DialogFooter.displayName = "DialogFooter" +); +DialogFooter.displayName = "DialogFooter"; const DialogTitle = React.forwardRef< React.ElementRef, @@ -89,12 +89,12 @@ const DialogTitle = React.forwardRef< ref={ref} className={cn( "text-lg font-semibold leading-none tracking-tight", - className + className, )} {...props} /> -)) -DialogTitle.displayName = DialogPrimitive.Title.displayName +)); +DialogTitle.displayName = DialogPrimitive.Title.displayName; const DialogDescription = React.forwardRef< React.ElementRef, @@ -105,8 +105,8 @@ const DialogDescription = React.forwardRef< className={cn("text-sm text-muted-foreground", className)} {...props} /> -)) -DialogDescription.displayName = DialogPrimitive.Description.displayName +)); +DialogDescription.displayName = DialogPrimitive.Description.displayName; export { Dialog, @@ -119,4 +119,4 @@ export { DialogFooter, DialogTitle, DialogDescription, -} +}; diff --git a/src/components/ui/dropdown-menu.tsx b/src/components/ui/dropdown-menu.tsx index 242b07a..9de6e7f 100644 --- a/src/components/ui/dropdown-menu.tsx +++ b/src/components/ui/dropdown-menu.tsx @@ -1,31 +1,31 @@ -"use client" +"use client"; -import * as React from "react" -import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu" +import * as React from "react"; +import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; import { CheckIcon, ChevronRightIcon, DotFilledIcon, -} from "@radix-ui/react-icons" +} from "@radix-ui/react-icons"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; -const DropdownMenu = DropdownMenuPrimitive.Root +const DropdownMenu = DropdownMenuPrimitive.Root; -const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger +const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger; -const DropdownMenuGroup = DropdownMenuPrimitive.Group +const DropdownMenuGroup = DropdownMenuPrimitive.Group; -const DropdownMenuPortal = DropdownMenuPrimitive.Portal +const DropdownMenuPortal = DropdownMenuPrimitive.Portal; -const DropdownMenuSub = DropdownMenuPrimitive.Sub +const DropdownMenuSub = DropdownMenuPrimitive.Sub; -const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup +const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup; const DropdownMenuSubTrigger = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { - inset?: boolean + inset?: boolean; } >(({ className, inset, children, ...props }, ref) => ( {children} -)) +)); DropdownMenuSubTrigger.displayName = - DropdownMenuPrimitive.SubTrigger.displayName + DropdownMenuPrimitive.SubTrigger.displayName; const DropdownMenuSubContent = React.forwardRef< React.ElementRef, @@ -52,13 +52,13 @@ const DropdownMenuSubContent = React.forwardRef< ref={ref} className={cn( "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", - className + className, )} {...props} /> -)) +)); DropdownMenuSubContent.displayName = - DropdownMenuPrimitive.SubContent.displayName + DropdownMenuPrimitive.SubContent.displayName; const DropdownMenuContent = React.forwardRef< React.ElementRef, @@ -71,31 +71,31 @@ const DropdownMenuContent = React.forwardRef< className={cn( "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", - className + className, )} {...props} /> -)) -DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName +)); +DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName; const DropdownMenuItem = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { - inset?: boolean + inset?: boolean; } >(({ className, inset, ...props }, ref) => ( -)) -DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName +)); +DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName; const DropdownMenuCheckboxItem = React.forwardRef< React.ElementRef, @@ -104,8 +104,8 @@ const DropdownMenuCheckboxItem = React.forwardRef< {children} -)) +)); DropdownMenuCheckboxItem.displayName = - DropdownMenuPrimitive.CheckboxItem.displayName + DropdownMenuPrimitive.CheckboxItem.displayName; const DropdownMenuRadioItem = React.forwardRef< React.ElementRef, @@ -128,8 +128,8 @@ const DropdownMenuRadioItem = React.forwardRef< @@ -140,13 +140,13 @@ const DropdownMenuRadioItem = React.forwardRef< {children} -)) -DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName +)); +DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName; const DropdownMenuLabel = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { - inset?: boolean + inset?: boolean; } >(({ className, inset, ...props }, ref) => ( -)) -DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName +)); +DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName; const DropdownMenuSeparator = React.forwardRef< React.ElementRef, @@ -170,8 +170,8 @@ const DropdownMenuSeparator = React.forwardRef< className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} /> -)) -DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName +)); +DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName; const DropdownMenuShortcut = ({ className, @@ -182,9 +182,9 @@ const DropdownMenuShortcut = ({ className={cn("ml-auto text-xs tracking-widest opacity-60", className)} {...props} /> - ) -} -DropdownMenuShortcut.displayName = "DropdownMenuShortcut" + ); +}; +DropdownMenuShortcut.displayName = "DropdownMenuShortcut"; export { DropdownMenu, @@ -202,4 +202,4 @@ export { DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuRadioGroup, -} +}; diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx index 45f5847..6f95410 100644 --- a/src/components/ui/input.tsx +++ b/src/components/ui/input.tsx @@ -1,22 +1,23 @@ -import * as React from "react" -import { cn } from "@/lib/utils" +import * as React from "react"; +import { cn } from "@/lib/utils"; -const Input = React.forwardRef>( - ({ className, type, ...props }, ref) => { - return ( - - ) - } -) +const Input = React.forwardRef< + HTMLInputElement, + React.InputHTMLAttributes +>(({ className, type, ...props }, ref) => { + return ( + + ); +}); -Input.displayName = "Input" +Input.displayName = "Input"; -export { Input } +export { Input }; diff --git a/src/components/ui/label.tsx b/src/components/ui/label.tsx index 5341821..84f8b0c 100644 --- a/src/components/ui/label.tsx +++ b/src/components/ui/label.tsx @@ -1,14 +1,14 @@ -"use client" +"use client"; -import * as React from "react" -import * as LabelPrimitive from "@radix-ui/react-label" -import { cva, type VariantProps } from "class-variance-authority" +import * as React from "react"; +import * as LabelPrimitive from "@radix-ui/react-label"; +import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const labelVariants = cva( - "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" -) + "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", +); const Label = React.forwardRef< React.ElementRef, @@ -20,7 +20,7 @@ const Label = React.forwardRef< className={cn(labelVariants(), className)} {...props} /> -)) -Label.displayName = LabelPrimitive.Root.displayName +)); +Label.displayName = LabelPrimitive.Root.displayName; -export { Label } +export { Label }; diff --git a/src/components/ui/select.tsx b/src/components/ui/select.tsx index ac2a8f2..78cb697 100644 --- a/src/components/ui/select.tsx +++ b/src/components/ui/select.tsx @@ -1,21 +1,21 @@ -"use client" +"use client"; -import * as React from "react" +import * as React from "react"; import { CaretSortIcon, CheckIcon, ChevronDownIcon, ChevronUpIcon, -} from "@radix-ui/react-icons" -import * as SelectPrimitive from "@radix-ui/react-select" +} from "@radix-ui/react-icons"; +import * as SelectPrimitive from "@radix-ui/react-select"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; -const Select = SelectPrimitive.Root +const Select = SelectPrimitive.Root; -const SelectGroup = SelectPrimitive.Group +const SelectGroup = SelectPrimitive.Group; -const SelectValue = SelectPrimitive.Value +const SelectValue = SelectPrimitive.Value; const SelectTrigger = React.forwardRef< React.ElementRef, @@ -25,7 +25,7 @@ const SelectTrigger = React.forwardRef< ref={ref} className={cn( "flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1", - className + className, )} {...props} > @@ -34,8 +34,8 @@ const SelectTrigger = React.forwardRef< -)) -SelectTrigger.displayName = SelectPrimitive.Trigger.displayName +)); +SelectTrigger.displayName = SelectPrimitive.Trigger.displayName; const SelectScrollUpButton = React.forwardRef< React.ElementRef, @@ -45,14 +45,14 @@ const SelectScrollUpButton = React.forwardRef< ref={ref} className={cn( "flex cursor-default items-center justify-center py-1", - className + className, )} {...props} > -)) -SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName +)); +SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName; const SelectScrollDownButton = React.forwardRef< React.ElementRef, @@ -62,15 +62,15 @@ const SelectScrollDownButton = React.forwardRef< ref={ref} className={cn( "flex cursor-default items-center justify-center py-1", - className + className, )} {...props} > -)) +)); SelectScrollDownButton.displayName = - SelectPrimitive.ScrollDownButton.displayName + SelectPrimitive.ScrollDownButton.displayName; const SelectContent = React.forwardRef< React.ElementRef, @@ -83,7 +83,7 @@ const SelectContent = React.forwardRef< "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", - className + className, )} position={position} {...props} @@ -93,7 +93,7 @@ const SelectContent = React.forwardRef< className={cn( "p-1", position === "popper" && - "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]" + "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]", )} > {children} @@ -101,8 +101,8 @@ const SelectContent = React.forwardRef< -)) -SelectContent.displayName = SelectPrimitive.Content.displayName +)); +SelectContent.displayName = SelectPrimitive.Content.displayName; const SelectLabel = React.forwardRef< React.ElementRef, @@ -113,8 +113,8 @@ const SelectLabel = React.forwardRef< className={cn("px-2 py-1.5 text-sm font-semibold", className)} {...props} /> -)) -SelectLabel.displayName = SelectPrimitive.Label.displayName +)); +SelectLabel.displayName = SelectPrimitive.Label.displayName; const SelectItem = React.forwardRef< React.ElementRef, @@ -123,8 +123,8 @@ const SelectItem = React.forwardRef< @@ -135,8 +135,8 @@ const SelectItem = React.forwardRef< {children} -)) -SelectItem.displayName = SelectPrimitive.Item.displayName +)); +SelectItem.displayName = SelectPrimitive.Item.displayName; const SelectSeparator = React.forwardRef< React.ElementRef, @@ -147,8 +147,8 @@ const SelectSeparator = React.forwardRef< className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} /> -)) -SelectSeparator.displayName = SelectPrimitive.Separator.displayName +)); +SelectSeparator.displayName = SelectPrimitive.Separator.displayName; export { Select, @@ -161,4 +161,4 @@ export { SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, -} +}; diff --git a/src/components/ui/sidebar.tsx b/src/components/ui/sidebar.tsx index 709b713..4979869 100644 --- a/src/components/ui/sidebar.tsx +++ b/src/components/ui/sidebar.tsx @@ -3,8 +3,7 @@ import cookoff from "@/assets/images/codechef_logo.svg"; import Image from "next/image"; import { usePathname, useRouter } from "next/navigation"; -import { FaHome, FaQuestion, FaUser, FaArrowAltCircleUp } from "react-icons/fa"; - +import { FaHome, FaQuestion, FaUser } from "react-icons/fa"; // import { Router } from ""; export default function Sidebar() { @@ -62,10 +61,8 @@ export default function Sidebar() { Users
{" "} - - ) ); -} \ No newline at end of file +} diff --git a/src/components/ui/table.tsx b/src/components/ui/table.tsx index 8174447..26fa900 100644 --- a/src/components/ui/table.tsx +++ b/src/components/ui/table.tsx @@ -1,6 +1,6 @@ -import * as React from "react" +import * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const Table = React.forwardRef< HTMLTableElement, @@ -13,16 +13,16 @@ const Table = React.forwardRef< {...props} />
-)) -Table.displayName = "Table" +)); +Table.displayName = "Table"; const TableHeader = React.forwardRef< HTMLTableSectionElement, React.HTMLAttributes >(({ className, ...props }, ref) => (
-)) -TableHeader.displayName = "TableHeader" +)); +TableHeader.displayName = "TableHeader"; const TableBody = React.forwardRef< HTMLTableSectionElement, @@ -33,8 +33,8 @@ const TableBody = React.forwardRef< className={cn("[&_tr:last-child]:border-0", className)} {...props} /> -)) -TableBody.displayName = "TableBody" +)); +TableBody.displayName = "TableBody"; const TableFooter = React.forwardRef< HTMLTableSectionElement, @@ -44,12 +44,12 @@ const TableFooter = React.forwardRef< ref={ref} className={cn( "border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", - className + className, )} {...props} /> -)) -TableFooter.displayName = "TableFooter" +)); +TableFooter.displayName = "TableFooter"; const TableRow = React.forwardRef< HTMLTableRowElement, @@ -59,12 +59,12 @@ const TableRow = React.forwardRef< ref={ref} className={cn( "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted", - className + className, )} {...props} /> -)) -TableRow.displayName = "TableRow" +)); +TableRow.displayName = "TableRow"; const TableHead = React.forwardRef< HTMLTableCellElement, @@ -74,12 +74,12 @@ const TableHead = React.forwardRef< ref={ref} className={cn( "h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", - className + className, )} {...props} /> -)) -TableHead.displayName = "TableHead" +)); +TableHead.displayName = "TableHead"; const TableCell = React.forwardRef< HTMLTableCellElement, @@ -89,12 +89,12 @@ const TableCell = React.forwardRef< ref={ref} className={cn( "p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", - className + className, )} {...props} /> -)) -TableCell.displayName = "TableCell" +)); +TableCell.displayName = "TableCell"; // const TableCaption = React.forwardRef< // HTMLTableCaptionElement, @@ -119,4 +119,4 @@ export { TableRow, TableCell, // TableCaption, -} +}; diff --git a/src/components/ui/textarea.tsx b/src/components/ui/textarea.tsx index 2576f8d..569de90 100644 --- a/src/components/ui/textarea.tsx +++ b/src/components/ui/textarea.tsx @@ -1,20 +1,21 @@ -import * as React from "react" -import { cn } from "@/lib/utils" +import * as React from "react"; +import { cn } from "@/lib/utils"; -const Textarea = React.forwardRef>( - ({ className, ...props }, ref) => { - return ( -