From e7f3474dc2c918bc77375e09b1d5ad4e6093bd1a Mon Sep 17 00:00:00 2001 From: Joslyn Manzi Karenzi Date: Tue, 3 Dec 2024 15:35:44 +0200 Subject: [PATCH] fix(apply-jobpost): incorporate feedback (#168) - remove 'submitted' status - add comments for 'rejected status' --- src/models/JobApplication.ts | 8 +++++-- src/resolvers/jobApplicationResolver.ts | 28 +++++++++++++++++++++---- src/schema/jobApplicationSchema.ts | 2 ++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/models/JobApplication.ts b/src/models/JobApplication.ts index 4cd9c6b..234f970 100644 --- a/src/models/JobApplication.ts +++ b/src/models/JobApplication.ts @@ -21,8 +21,12 @@ const jobApplicationSchema = new mongoose.Schema({ }, status:{ type:String, - enum:['submitted','under-review','accepted','rejected'], - default:'submitted' + enum:['under-review','accepted','rejected'], + default:'under-review' + }, + comment: { + type:String, + required: false } },{timestamps:true}) diff --git a/src/resolvers/jobApplicationResolver.ts b/src/resolvers/jobApplicationResolver.ts index e436271..88f1c0b 100644 --- a/src/resolvers/jobApplicationResolver.ts +++ b/src/resolvers/jobApplicationResolver.ts @@ -18,7 +18,8 @@ interface getOneFormData { interface statusData { applicationId: string, - status: string + status: string, + comment: string } const formatDate = (date:Date) => { @@ -114,6 +115,7 @@ export const jobApplicationResolver = { essay: application.essay, resume: application.resume, status: application.status, + comment: application.comment, jobId: application.jobId, createdAt: formatDate(application.createdAt) } @@ -175,10 +177,28 @@ export const jobApplicationResolver = { ); } - const { status, applicationId } = input - await JobApplication.findByIdAndUpdate(applicationId, {status}) + const { status, applicationId, comment } = input + if(comment){ + await JobApplication.findByIdAndUpdate(applicationId, {status, comment}) + }else{ + await JobApplication.findByIdAndUpdate(applicationId, {status}) + } + const application = await JobApplication.findOne({_id:applicationId}).populate('userId').populate('jobId') - return application + if(!application){ + throw new Error('Application not found'); + } + + return { + _id: application._id, + userId: application.userId, + essay: application.essay, + resume: application.resume, + status: application.status, + comment: application.comment, + jobId: application.jobId, + createdAt: formatDate(application.createdAt) + } } }, }; \ No newline at end of file diff --git a/src/schema/jobApplicationSchema.ts b/src/schema/jobApplicationSchema.ts index 3c72674..8374e12 100644 --- a/src/schema/jobApplicationSchema.ts +++ b/src/schema/jobApplicationSchema.ts @@ -23,6 +23,7 @@ export const jobApplicationTypeDefs = gql` essay: String! resume: String! status: String! + comment: String createdAt: String! } @@ -39,6 +40,7 @@ export const jobApplicationTypeDefs = gql` input StatusInput { applicationId: ID! status: String! + comment: String } type checkIfUserAppliedOutput {