Skip to content

complete all tasks for assignment (#5, #10, #4, #14, #169, #30) - #327

Open
Awanish9230 wants to merge 2 commits into
modelsuite-ai:masterfrom
Awanish9230:169-30-14-10-5-4-awanish-kumar-verma
Open

complete all tasks for assignment (#5, #10, #4, #14, #169, #30)#327
Awanish9230 wants to merge 2 commits into
modelsuite-ai:masterfrom
Awanish9230:169-30-14-10-5-4-awanish-kumar-verma

Conversation

@Awanish9230

@Awanish9230 Awanish9230 commented Jul 21, 2026

Copy link
Copy Markdown

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

Required before opening this PR: Complete these checks locally to ensure the code is ready for review. PRs opened without these checks passing may be closed.

  • I ran cd client && npm run lint && npm run build and cd server && npm run lint && npm run build locally
  • All checks passed (lint, build)
  • No errors or warnings remain

Note: This is a pre-PR checklist completed before submission. Additional checklists below are completed after the PR is opened.

Short Demo Video (required)


Required Checklist

Task & Workflow

  • Create a new Branch exactly matching your assigned name (e.g. 27-26-22-7-5-pranav-test)
  • PR title is exactly your assigned branch name
  • Latest target branch (master) was pulled immediately before opening this PR

Quality & Safety

  • Change tested locally
  • Full diff reviewed before submitting (no blind copy/paste)
  • No secrets, keys, or personal data included

Copilot AI review requested due to automatic review settings July 21, 2026 05:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread server/models/Task.js
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;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants