[offers][fix] fix create endpoint no company bug

This commit is contained in:
Stuart Long Chay Boon
2022-10-11 15:25:42 +08:00
parent 4330fb5448
commit 6a6c939953

View File

@ -161,6 +161,7 @@ export const offersProfileRouter = createRouter()
x.totalCompensation?.currency !== undefined && x.totalCompensation?.currency !== undefined &&
x.totalCompensation.value !== undefined x.totalCompensation.value !== undefined
) { ) {
if (x.companyId) {
return { return {
company: { company: {
connect: { connect: {
@ -179,12 +180,28 @@ export const offersProfileRouter = createRouter()
}, },
}, },
}; };
}
return {
durationInMonths: x.durationInMonths,
jobType: x.jobType,
level: x.level,
specialization: x.specialization,
title: x.title,
totalCompensation: {
create: {
currency: x.totalCompensation?.currency,
value: x.totalCompensation?.value,
},
},
};
} }
if ( if (
x.jobType === 'INTERN' && x.jobType === 'INTERN' &&
x.monthlySalary?.currency !== undefined && x.monthlySalary?.currency !== undefined &&
x.monthlySalary.value !== undefined x.monthlySalary.value !== undefined
) { ) {
if (x.companyId) {
return { return {
company: { company: {
connect: { connect: {
@ -203,6 +220,20 @@ export const offersProfileRouter = createRouter()
title: x.title, title: x.title,
}; };
} }
return {
durationInMonths: x.durationInMonths,
jobType: x.jobType,
monthlySalary: {
create: {
currency: x.monthlySalary?.currency,
value: x.monthlySalary?.value,
},
},
specialization: x.specialization,
title: x.title,
};
}
throw Prisma.PrismaClientKnownRequestError; throw Prisma.PrismaClientKnownRequestError;
}), }),