Siddhant: All changes - #21
Conversation
|
Someone is attempting to deploy a commit to the Sky Ruler'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 performs a broad server/client refactor to a feature-based structure and adds multiple new platform capabilities (user/clan management enhancements, resources, chat, badges, question sets, richer profiles), along with email notifications, seeding, and deployment/runtime adjustments.
Changes:
- Server: reorganize routes/controllers/models under
server/src/features/*, add new features (chat, resources, badges, question sets), and extend auth/user/submission behavior (refresh tokens, XP awarding, emails). - Client: add new pages and dashboards (resources, badges, clan chat, chief/admin tabs), remove mock usage in several places, and update navigation/UI styling.
- Ops/tooling: update seeding flow, socket room support, build/dev scripts, and production SPA static serving.
Reviewed changes
Copilot reviewed 101 out of 114 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| test-leetcode.js | Removed standalone LeetCode test script |
| server/validators/submissionSchemas.js | Updated submission validation (language enum; update schema) |
| server/validators/challengeSchemas.js | Simplified challenge validation schemas and exports |
| server/utils/emailService.js | Added nodemailer-based email utility |
| server/utils/audit.js | Updated AuditLog model import path |
| server/standalone.js | Adjusted standalone seeding invocation |
| server/src/features/users/user.routes.js | Added feature-based user routes |
| server/src/features/users/User.model.js | Extended user fields (level/points/status/etc.) and role enum |
| server/src/features/users/user.controller.js | Added user admin/chief actions (role/level/warn/ban) |
| server/src/features/submissions/submission.routes.js | Moved to feature-based routes and updated imports |
| server/src/features/submissions/Submission.model.js | Replaced review fields with feedback |
| server/src/features/submissions/submission.controller.js | Feature-based submission logic; added XP awarding + email notifications |
| server/src/features/resources/resource.routes.js | Added resource routes |
| server/src/features/resources/Resource.model.js | Added Resource model with folder/type metadata |
| server/src/features/resources/resource.controller.js | Added resource CRUD handlers |
| server/src/features/profile/profile.routes.js | Added profile routes incl. public profile endpoints |
| server/src/features/notices/notice.routes.js | Updated notice routes to feature structure |
| server/src/features/notices/notice.controller.js | Added notice priority/pin + email broadcast; simplified history query |
| server/src/features/notices/GlobalNotice.model.js | Added priority and isPinned fields |
| server/src/features/notices/EntityRevision.model.js | Fixed stableStringify import path |
| server/src/features/notices/AuditLog.model.js | Fixed stableStringify import path |
| server/src/features/dashboard/dashboard.routes.js | Added dashboard routes (user + admin summary) |
| server/src/features/dashboard/dashboard.controller.js | Added public profile aggregation and admin dashboard summary |
| server/src/features/clans/clan.routes.js | Updated clan routes and added /mine + admin stats endpoint |
| server/src/features/clans/Clan.model.js | Added Clan model under features |
| server/src/features/clans/clan.controller.js | Added my-clan/admin-stats; removed some socket emits; added emails |
| server/src/features/chat/ChatMessage.model.js | Added ChatMessage model |
| server/src/features/chat/chat.routes.js | Added chat routes |
| server/src/features/chat/chat.controller.js | Added clan chat history + send message with room emit |
| server/src/features/challenges/questionSet.routes.js | Added question set routes |
| server/src/features/challenges/QuestionSet.model.js | Added QuestionSet model |
| server/src/features/challenges/questionSet.controller.js | Added question set CRUD + audit + email notification |
| server/src/features/challenges/challenge.routes.js | Added challenge routes (incl import + LeetCode fetch) |
| server/src/features/challenges/Challenge.model.js | Simplified Challenge model fields/indexes |
| server/src/features/challenges/challenge.controller.js | Added full challenge controller incl import + LeetCode details |
| server/src/features/badges/badge.routes.js | Added badge routes |
| server/src/features/badges/Badge.model.js | Added Badge model |
| server/src/features/badges/badge.controller.js | Added badges listing controller |
| server/src/features/auth/RefreshToken.model.js | Added refresh token persistence model |
| server/src/features/auth/auth.routes.js | Updated auth route imports to feature structure |
| server/src/features/auth/auth.controller.js | Updated auth controller; added daily XP bonus; chief detection |
| server/services/leetcode.service.js | Renamed export and adjusted logging/style |
| server/server.js | Added optional seeding; introduced MongoMemoryServer for non-prod; DNS tweaks for prod |
| server/seed.js | Reworked seeding to populate many collections and feature-based models |
| server/routes/userRoutes.js | Removed legacy user routes |
| server/routes/profileRoutes.js | Removed legacy profile routes |
| server/routes/dashboardRoutes.js | Removed legacy dashboard routes |
| server/routes/challengeRoutes.js | Removed legacy challenge routes |
| server/package.json | Added deps (multer/nodemailer/mammoth/csv-parser) and updated scripts |
| server/middleware/auth.js | Updated User model path; removed super-admin checks |
| server/controllers/userController.js | Removed legacy user controller |
| server/controllers/challengeController.js | Removed legacy challenge controller |
| server/config/socket.js | Added clan room join/leave + emitToRoom |
| server/app.js | Switched to feature routes; disabled helmet CSP; added SPA static serving in prod |
| scratch_test.txt | Removed scratch file |
| refactor_hover.js | Added local refactor script for hover card component |
| README.md | Minor README change |
| package.json | Added root dev script; adjusted build script |
| client/vite.config.js | Set dev server port/strictPort |
| client/src/pages/SubmissionDetails.jsx | Removed mock fetching; minor UI copy tweaks (but still references old review fields) |
| client/src/pages/Resources.jsx | Added Resources page |
| client/src/pages/Register.jsx | Updated branding assets and header layout |
| client/src/pages/PendingAssignment.jsx | Added pending assignment page (notices display) |
| client/src/pages/Missions.jsx | Added submission-status-based filtering and UI changes |
| client/src/pages/Login.jsx | Updated branding assets and header layout |
| client/src/pages/Leaderboard.jsx | Removed mock usage; updated segmented controls; added MemberHoverCard usage |
| client/src/pages/Home.jsx | Removed mock usage; updated branding/footer |
| client/src/pages/ClanChat.jsx | Added clan chat page with socket integration |
| client/src/pages/chief/ChiefReviewTab.jsx | Added chief review UI (grading + feedback) |
| client/src/pages/chief/ChiefNoticeTab.jsx | Added chief clan notice management UI |
| client/src/pages/chief/ChiefMembersTab.jsx | Added chief member management UI (level + warn) |
| client/src/pages/Badges.jsx | Added badges page |
| client/src/pages/admin/ResourcesTab.jsx | Added admin resources UI (folder-based) |
| client/src/pages/admin/ResourcesAdmin.jsx | Added alternate admin resources page (category-based) |
| client/src/pages/admin/NoticesAdmin.jsx | Added alternate notices admin page (title/type-based) |
| client/src/pages/admin/NoticeBoardTab.jsx | Added notice board tab aligned with priority/pin model |
| client/src/pages/admin/MembersTab.jsx | Added admin member directory UI |
| client/src/pages/admin/DashboardTab.jsx | Added admin dashboard summary UI |
| client/src/lib/mockData.js | Disabled mock mode; updated mock IDs/data |
| client/src/lib/api.js | Adjusted base URL handling for production |
| client/src/index.css | Updated theme variables; removed LeetCode description styling block |
| client/src/hooks/useSocket.js | Adjusted socket URL for production |
| client/src/context/AuthContext.jsx | Removed mock auth; added daily XP toast; normalized extra user fields |
| client/src/components/ProfilePopover.jsx | Added profile popover component |
| client/src/components/Navbar.jsx | Updated nav items and branding; adjusted admin logic |
| client/src/components/ClanChiefRoute.jsx | Removed super-admin from chief gate |
| client/src/components/AdminRoute.jsx | Removed super-admin from admin gate |
| client/src/components/ActivityHeatmap.jsx | Added activity heatmap component |
| client/src/App.jsx | Added routes for resources, pending assignment, and profile username route |
| client/package.json | Added CodeMirror language/theme dependencies |
| .gitignore | Reduced ignored files list (env files no longer ignored) |
Files not reviewed (2)
- client/package-lock.json: Language not supported
- server/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)
server/src/features/submissions/submission.controller.js:298
- Points are awarded whenever the request sets
status === 'Accepted', regardless of the submission’s previous status. This allows repeated calls (or toggling status) to increment points/solvedProblems multiple times for the same submission. Ensure XP is only awarded on a transition to Accepted (e.g., fetch prior status first, or use an atomic conditional update).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const submissionUpdateSchema = { | ||
| body: z.object({ | ||
| status: z.enum(['Pending', 'Accepted', 'Rejected']), | ||
| reviewComment: z.string().trim().min(1, { message: 'Comment cannot be empty' }).max(2000).optional(), | ||
| }), | ||
| }; |
| const gradeMutation = useMutation({ | ||
| mutationFn: async ({ id, status, feedback }) => { | ||
| const res = await api.put(`/api/submissions/${id}/grade`, { status, feedback }); | ||
| return res.data; | ||
| }, |
| const submissionsQuery = useQuery({ | ||
| queryKey: ['my-submissions'], | ||
| queryFn: async () => { | ||
| try { | ||
| const res = await api.get('/api/submissions/my'); | ||
| return res.data.data || []; | ||
| } catch { return []; } | ||
| } | ||
| }); |
| <div className="p-3 rounded-xl bg-red-500/5 border border-red-500/10 text-sm text-primary leading-relaxed whitespace-pre-wrap"> | ||
| {submission.reviewComment} | ||
| </div> |
| const { data: resources = [], isLoading } = useQuery({ | ||
| queryKey: ['resources', activeCategory], | ||
| queryFn: async () => { | ||
| const url = activeCategory ? `/api/resources?category=${activeCategory}` : '/api/resources'; | ||
| const res = await api.get(url); | ||
| return res.data.data; |
| const fs = require('fs'); | ||
|
|
||
| let code = fs.readFileSync('scratch_card.jsx', 'utf8'); | ||
|
|
||
| code = code.replace( | ||
| 'import { useQuery } from "@tanstack/react-query";', | ||
| 'import { useQuery } from "@tanstack/react-query";\nimport { useNavigate } from "react-router-dom";' | ||
| ); | ||
|
|
||
| code = code.replace(/\/\* ── Smart Position Hover Tooltip .*?\/\* ══════════════════════════════════════════════════════/s, '/* ══════════════════════════════════════════════════════'); | ||
|
|
||
| let modalStart = code.indexOf('const MemberModal = ({ userId, username, onClose'); |
| const ResourcesAdmin = () => { | ||
| const queryClient = useQueryClient(); | ||
| const [formData, setFormData] = useState({ title: '', category: 'DP', type: 'PDF', url: '' }); | ||
|
|
||
| const { data: resources = [], isLoading } = useQuery({ |
| const [formData, setFormData] = useState({ title: '', content: '', type: 'Standard' }); | ||
|
|
||
| const { data: notices = [], isLoading } = useQuery({ | ||
| queryKey: ['admin-notices'], | ||
| queryFn: async () => { | ||
| const res = await api.get('/api/notices/history'); | ||
| return res.data.data; | ||
| } | ||
| }); | ||
|
|
||
| const uploadMutation = useMutation({ | ||
| mutationFn: async (newNotice) => { | ||
| const res = await api.post('/api/notices', newNotice); | ||
| return res.data; |
| {notices.map(notice => ( | ||
| <BaseCard key={notice._id} className="p-5 border-l-4 border-l-blue-500"> | ||
| <h3 className="font-bold text-primary mb-1">{notice.title}</h3> | ||
| <p className="text-sm text-secondary">{notice.content}</p> |
| const handleFile = (file) => { | ||
| if (file.size > 20 * 1024 * 1024) { | ||
| toast.error('File exceeds 20MB limit'); | ||
| return; | ||
| } | ||
| setFileName(file.name); | ||
| if (!form.title) setForm(p => ({ ...p, title: file.name.replace('.pdf', '') })); | ||
| setForm(p => ({ ...p, type: 'PDF', sizeBytes: file.size, url: URL.createObjectURL(file) })); // Mock URL | ||
| }; |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
No description provided.