Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#173 apply job post #168

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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