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
+
+
+
+### Portal
+
+#### Dashboard
+
+
+#### Edit Question Page
+
+
+#### Question Creation Page
+
+
+#### Question Page
+
+
+
+#### Users Page
+
+
+
+
## 🏁 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({
-
-
+
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 (
-
+