Fixes #68 : Implemented NewProblem page #69
Conversation
|
@Kmadhav824 is attempting to deploy a commit to the Shivam verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR wires up the admin "New Problem" page in the frontend, renaming the route/component to CreateProblem//createproblem, and also bundles several unrelated backend tweaks: a tsconfig module change, ESM __dirname handling in config/index.ts, relaxed validation on editorialContent/editorialLink/tags in the problem schema, a rewrite of seed-admin.js to use the Drizzle schema, and a commented-out import in contest.route.ts.
Changes:
- Frontend: rename
NewProblemimport/route toCreateProblemand update navbar link to/createProblem; cosmetic JSX/whitespace cleanup inNavBar.jsx. - Backend: loosen
createProblemSchema(editorial fields + tags now optional with defaults); rewriteseed-admin.jsagainst the Drizzleusertable; switchtsconfigtonode16modules; add ESM__dirnameshim inconfig/index.ts. - Backend: comment out
verifyJWTimport incontest.route.ts.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Frontend/src/App.jsx | Rename import to CreateProblem and route path to /createproblem. |
| Frontend/src/components/NavBar.jsx | Update admin/author nav link to /createProblem; whitespace/formatting tweaks. |
| backend/src/api/problem/problem-schema.ts | Make editorialContent, editorialLink, and tags optional with defaults. |
| backend/src/api/contest/contest.route.ts | Comment out the remaining verifyJWT import, leaving the file with no exports. |
| backend/src/config/index.ts | Add ESM-compatible __dirname derivation via import.meta.url; whitespace reformatting. |
| backend/src/scripts/seed-admin.js | Replace Mongoose User model with Drizzle user table and tidy formatting (but uses non-existent findOne/create methods). |
| backend/tsconfig.json | Change module/moduleResolution from commonjs/node to node16. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { user } from "../db/schema.ts"; | ||
| import env from '../config/index.ts' | ||
|
|
||
| export async function seedAdmin() { | ||
|
|
||
| const adminExists = await User.findOne({ role: "admin" }); | ||
| const adminExists = await user.findOne({ role: "ADMIN" }); | ||
| if (adminExists) { | ||
| console.log("Admin already exists. Skipping."); | ||
| process.exit(0); | ||
| } | ||
|
|
||
| const { ADMIN_USERNAME,ADMIN_FULLNAME, ADMIN_EMAIL, ADMIN_PASSWORD } = env; | ||
| const { ADMIN_USERNAME, ADMIN_FULLNAME, ADMIN_EMAIL, ADMIN_PASSWORD } = env; | ||
| if (!ADMIN_EMAIL || !ADMIN_PASSWORD) { | ||
| throw new Error("ADMIN_EMAIL / ADMIN_PASSWORD missing"); | ||
| } | ||
|
|
||
| const passwordHash = await bcrypt.hash(ADMIN_PASSWORD, 12); | ||
|
|
||
| await User.create({ | ||
| await user.create({ | ||
| username: ADMIN_USERNAME, | ||
| fullName : ADMIN_FULLNAME, | ||
| fullName: ADMIN_FULLNAME, | ||
| email: ADMIN_EMAIL, | ||
| password : passwordHash, | ||
| password: passwordHash, | ||
| role: "admin", | ||
| }); |
| { to: "/newproblem", label: "Create Problem" }, | ||
| { to: "/contests/create", label: "Create Contest" }, | ||
| ] | ||
| { to: "/createProblem", label: "Create Problem" }, |
| editorialLink: yup.string().optional().default(""), | ||
| solution: yup.string().required("Solution is required"), | ||
| tags: yup.array().of(yup.string()).required("Tags is required"), | ||
| tags: yup.array().of(yup.string()).optional().default([]), |
| "moduleResolution": "node16", | ||
| "module": "node16", |
| // import {createContest,getAllContests,getContestById,getClock,getLeaderboard,registerContest} from "./contest.controller.js" | ||
| // import { Router } from 'express'; | ||
| import { verifyJWT } from '../../middlewares/auth.middleware.js'; | ||
| // import { verifyJWT } from '../../middlewares/auth.middleware.js'; |
New Problem Page was integrated, admins can start creating the problems