From 3bcb5b851d2a2cb4ef38b4c9774ee9f2c7f8f1a5 Mon Sep 17 00:00:00 2001 From: Mohak Jaiswal Date: Sat, 3 Jan 2026 19:29:52 +0530 Subject: [PATCH 1/3] Fix deadline handling and prevent invalid job application modal access --- .../components/job-application-modal.tsx | 54 ++++++++++++++----- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/apps/student/components/job-application-modal.tsx b/apps/student/components/job-application-modal.tsx index 6d38e6d..cd9f91f 100644 --- a/apps/student/components/job-application-modal.tsx +++ b/apps/student/components/job-application-modal.tsx @@ -40,6 +40,9 @@ export default function JobApplicationModal({ job, studentId, resumes, isApplied const [isPending, startTransition] = useTransition(); const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null); + const deadline = new Date(job.applicationDeadline); + const isDeadlinePassed = new Date() > deadline; + const handleApply = async () => { if (!selectedResume) { setMessage({ type: 'error', text: 'Please select a resume' }); @@ -63,12 +66,14 @@ export default function JobApplicationModal({ job, studentId, resumes, isApplied setMessage({ type: 'error', text: result.error || 'Failed to submit application' }); } } catch (error) { - setMessage({ type: 'error', text: 'An error occurred while submitting your application' }); + setMessage({ + type: 'error', + text: error instanceof Error ? error.message : 'An error occurred while submitting your application' + }); } }); }; - const isDeadlinePassed = new Date() > new Date(job.applicationDeadline as any); const cannotApplyReason = isApplied ? 'You have already applied to this job' : resumes.length === 0 @@ -78,21 +83,33 @@ export default function JobApplicationModal({ job, studentId, resumes, isApplied : null; return ( - - + !isPending && setIsOpen(open)}> + {!cannotApplyReason && ( + +
+ +
+
+ )} + + {cannotApplyReason && (
- {cannotApplyReason && ( - {cannotApplyReason} - )} + {cannotApplyReason}
-
+ )} + @@ -127,7 +144,7 @@ export default function JobApplicationModal({ job, studentId, resumes, isApplied
- Deadline: {job.applicationDeadline.toLocaleDateString()} + Deadline: {deadline.toLocaleDateString()}
@@ -162,6 +179,18 @@ export default function JobApplicationModal({ job, studentId, resumes, isApplied ))} + + {selectedResume && ( + r.id.toString() === selectedResume)?.fileUrl} + target="_blank" + rel="noopener noreferrer" + className="text-sm text-blue-600 underline mt-2 inline-block" + > + Preview selected resume + + )} + {resumes.length === 0 && (

No resumes found. Please upload a resume first. @@ -171,11 +200,10 @@ export default function JobApplicationModal({ job, studentId, resumes, isApplied {/* Message Display */} {message && ( -

+ }`}>
{message.type === 'success' ? ( From 441ae8169b25e5b9d4bea044963fd38811bdb917 Mon Sep 17 00:00:00 2001 From: Mohak Jaiswal Date: Sat, 3 Jan 2026 19:33:00 +0530 Subject: [PATCH 2/3] Fix deadline handling and prevent invalid job application modal access --- apps/student/components/job-application-modal.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/student/components/job-application-modal.tsx b/apps/student/components/job-application-modal.tsx index cd9f91f..814d4d2 100644 --- a/apps/student/components/job-application-modal.tsx +++ b/apps/student/components/job-application-modal.tsx @@ -21,6 +21,7 @@ import { applyForJob } from "../app/(main)/actions" import { type InferSelectModel } from '@workspace/db/drizzle'; import { jobs, companies, resumes } from '@workspace/db/schema'; + export type Job = InferSelectModel & { company: typeof companies.$inferSelect; }; @@ -201,8 +202,8 @@ export default function JobApplicationModal({ job, studentId, resumes, isApplied {/* Message Display */} {message && (
{message.type === 'success' ? ( From 3a1deddb8c4175c0d8c388a4198b153d319168fa Mon Sep 17 00:00:00 2001 From: Mohak Jaiswal Date: Sat, 3 Jan 2026 19:45:34 +0530 Subject: [PATCH 3/3] Fix deadline handling and prevent invalid job application modal access --- apps/student/components/job-application-modal.tsx | 5 ++--- nextplacement | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) create mode 160000 nextplacement diff --git a/apps/student/components/job-application-modal.tsx b/apps/student/components/job-application-modal.tsx index 814d4d2..cd9f91f 100644 --- a/apps/student/components/job-application-modal.tsx +++ b/apps/student/components/job-application-modal.tsx @@ -21,7 +21,6 @@ import { applyForJob } from "../app/(main)/actions" import { type InferSelectModel } from '@workspace/db/drizzle'; import { jobs, companies, resumes } from '@workspace/db/schema'; - export type Job = InferSelectModel & { company: typeof companies.$inferSelect; }; @@ -202,8 +201,8 @@ export default function JobApplicationModal({ job, studentId, resumes, isApplied {/* Message Display */} {message && (
{message.type === 'success' ? ( diff --git a/nextplacement b/nextplacement new file mode 160000 index 0000000..1648a56 --- /dev/null +++ b/nextplacement @@ -0,0 +1 @@ +Subproject commit 1648a56680c70863e79265c536c4f89f5b0302a4