Skip to content

Commit

Permalink
fix(apply-jobpost): incorporate feedback (#168)
Browse files Browse the repository at this point in the history
- remove 'submitted' status
- add comments for 'rejected status'
  • Loading branch information
jkarenzi authored Dec 3, 2024
1 parent 1bd4ffc commit e7f3474
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/models/JobApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
28 changes: 24 additions & 4 deletions src/resolvers/jobApplicationResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ interface getOneFormData {

interface statusData {
applicationId: string,
status: string
status: string,
comment: string
}

const formatDate = (date:Date) => {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
}
},
};
2 changes: 2 additions & 0 deletions src/schema/jobApplicationSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const jobApplicationTypeDefs = gql`
essay: String!
resume: String!
status: String!
comment: String
createdAt: String!
}
Expand All @@ -39,6 +40,7 @@ export const jobApplicationTypeDefs = gql`
input StatusInput {
applicationId: ID!
status: String!
comment: String
}
type checkIfUserAppliedOutput {
Expand Down

0 comments on commit e7f3474

Please sign in to comment.