complete all tasks for assignment (#5, #10, #4, #14, #169, #30) - #327
Open
Awanish9230 wants to merge 2 commits into
Open
complete all tasks for assignment (#5, #10, #4, #14, #169, #30)#327Awanish9230 wants to merge 2 commits into
Awanish9230 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses several assignment issues across the server and client, including safer task claiming/deletion behavior, tighter file upload validation/error handling, and UI improvements (theme toggle + due-date badges + password visibility).
Changes:
- Server: add upload file-type filtering + JSON error responses for invalid uploads; add atomic task-claim update; add task→submission cascade delete hook.
- Client: introduce light/dark theme context + CSS variable theme system, replace inline styles with theme classes, add due-date “Overdue/Due Soon” badges, and add reusable password input with show/hide toggle.
- Housekeeping: update app layout wrappers, page titles, and dependencies (lucide-react).
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| server/routes/submissionRoutes.js | Wraps multer upload to return JSON errors for invalid uploads. |
| server/models/Task.js | Adds a pre-delete hook to cascade-delete related submissions. |
| server/middleware/upload.js | Adds multer fileFilter restricting uploads to PDF and common image MIME types. |
| server/controllers/taskController.js | Updates comment to reflect cascade delete behavior. |
| server/controllers/talentController.js | Makes task claiming atomic via findOneAndUpdate on { _id, status: 'Open' }. |
| client/src/utils/dateUtils.js | Adds due-date status helper for overdue/due-soon badges. |
| client/src/pages/talent/TalentDashboard.jsx | Switches to theme-based Tailwind classes instead of inline colors. |
| client/src/pages/RegisterPage.jsx | Uses PasswordInput and updates theme-based styling in the visual panel. |
| client/src/pages/LoginPage.jsx | Uses PasswordInput and updates theme-based styling in the visual panel. |
| client/src/pages/admin/AdminDashboard.jsx | Refactors stat card styling to use theme classes. |
| client/src/index.css | Introduces CSS variables for light/dark and maps them into Tailwind theme tokens; adds badge styles. |
| client/src/context/ThemeContext.jsx | Adds theme provider with persisted theme + system preference defaulting. |
| client/src/components/talent/TaskCard.jsx | Adds due-date badges using getTaskDueStatus. |
| client/src/components/talent/TalentSidebar.jsx | Adds theme toggle button to the talent sidebar. |
| client/src/components/talent/SubmitTaskModal.jsx | Updates placeholder color class to theme token. |
| client/src/components/talent/MyTasksList.jsx | Adds due-date badges and refactors styles to theme classes. |
| client/src/components/common/PasswordInput.jsx | New reusable password input with show/hide toggle. |
| client/src/components/admin/TasksTable.jsx | Adds due-date badges and refactors styles to theme classes. |
| client/src/components/admin/Sidebar.jsx | Adds theme toggle button to the admin sidebar. |
| client/src/components/admin/EditTaskModal.jsx | Updates placeholder color class to theme token. |
| client/src/components/admin/CreateTaskModal.jsx | Updates placeholder color class to theme token. |
| client/src/App.jsx | Wraps app with ThemeProvider. |
| client/package.json | Adds lucide-react dependency. |
| client/package-lock.json | Locks dependency changes for lucide-react and related package graph. |
| client/index.html | Updates title and comments out the favicon link. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+29
to
+37
| // Middleware to cascade delete submissions related to the task to prevent orphaned records (Issue #5) | ||
| taskSchema.pre('findOneAndDelete', async function (next) { | ||
| const taskId = this.getQuery()['_id']; | ||
| if (taskId) { | ||
| const Submission = mongoose.model('Submission'); | ||
| await Submission.deleteMany({ taskId: taskId }); | ||
| } | ||
| next(); | ||
| }); |
Comment on lines
+8
to
+28
| const [theme, setTheme] = useState(() => { | ||
| const savedTheme = localStorage.getItem('theme'); | ||
| if (savedTheme) { | ||
| return savedTheme; | ||
| } | ||
| // Check system preference | ||
| if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { | ||
| return 'dark'; | ||
| } | ||
| return 'light'; | ||
| }); | ||
|
|
||
| useEffect(() => { | ||
| const root = document.documentElement; | ||
| if (theme === 'dark') { | ||
| root.classList.add('dark'); | ||
| } else { | ||
| root.classList.remove('dark'); | ||
| } | ||
| localStorage.setItem('theme', theme); | ||
| }, [theme]); |
Comment on lines
+1
to
+25
| /** | ||
| * Determines the due status of a task based on its due date. | ||
| * @param {string | Date} dueDateStr - The due date of the task. | ||
| * @returns {'overdue' | 'due-soon' | null} - The status of the due date. | ||
| */ | ||
| export const getTaskDueStatus = (dueDateStr, status) => { | ||
| if (['Submitted', 'Approved', 'Rejected'].includes(status)) return null; | ||
| if (!dueDateStr) return null; | ||
|
|
||
| const dueDate = new Date(dueDateStr); | ||
| if (isNaN(dueDate.getTime())) return null; | ||
|
|
||
| const now = new Date(); | ||
|
|
||
| const timeDiff = dueDate.getTime() - now.getTime(); | ||
| const hoursDiff = timeDiff / (1000 * 60 * 60); | ||
|
|
||
| if (hoursDiff < 0) { | ||
| return 'overdue'; | ||
| } else if (hoursDiff <= 24) { | ||
| return 'due-soon'; | ||
| } | ||
|
|
||
| return null; | ||
| }; |
…s, and due date utc shifting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary (max 3 sentences)
This PR resolves all 6 assigned bugs and feature requests in the intern qualification assessment. Key improvements include implementing Mongoose middleware for cascading deletion, resolving a race condition with atomic MongoDB updates, restricting uploads via Multer MIME filtering, and calculating 'Due Soon' and 'Overdue' dates. Additionally, a premium dark mode system with CSS micro-animations and password visibility toggles have been integrated to drastically improve the UI/UX.
Checklist
cd client && npm run lint && npm run buildandcd server && npm run lint && npm run buildlocallyShort Demo Video (required)
Required Checklist
Task & Workflow
27-26-22-7-5-pranav-test)master) was pulled immediately before opening this PRQuality & Safety