[offers][feat] integrate cityId into create profile endpoint

pull/501/head^2
Stuart Long Chay Boon 3 years ago
parent 02a90d2736
commit 89644e8c2b

@ -34,12 +34,12 @@ const company = z.object({
}); });
const offer = z.object({ const offer = z.object({
cityId: z.string(),
comments: z.string(), comments: z.string(),
company: company.nullish(), company: company.nullish(),
companyId: z.string(), companyId: z.string(),
id: z.string().optional(), id: z.string().optional(),
jobType: z.string().regex(createValidationRegex(Object.keys(JobType), null)), jobType: z.string().regex(createValidationRegex(Object.keys(JobType), null)),
location: z.string(),
monthYearReceived: z.date(), monthYearReceived: z.date(),
negotiationStrategy: z.string(), negotiationStrategy: z.string(),
offersFullTime: z offersFullTime: z
@ -74,6 +74,7 @@ const offer = z.object({
const experience = z.object({ const experience = z.object({
backgroundId: z.string().nullish(), backgroundId: z.string().nullish(),
cityId: z.string().nullish(),
company: company.nullish(), company: company.nullish(),
companyId: z.string().nullish(), companyId: z.string().nullish(),
durationInMonths: z.number().nullish(), durationInMonths: z.number().nullish(),
@ -83,7 +84,6 @@ const experience = z.object({
.regex(createValidationRegex(Object.keys(JobType), null)) .regex(createValidationRegex(Object.keys(JobType), null))
.nullish(), .nullish(),
level: z.string().nullish(), level: z.string().nullish(),
location: z.string().nullish(),
monthlySalary: valuation.nullish(), monthlySalary: valuation.nullish(),
monthlySalaryId: z.string().nullish(), monthlySalaryId: z.string().nullish(),
title: z.string().nullish(), title: z.string().nullish(),
@ -375,6 +375,39 @@ export const offersProfileRouter = createRouter()
input.background.experiences.map(async (x) => { input.background.experiences.map(async (x) => {
if (x.jobType === JobType.FULLTIME) { if (x.jobType === JobType.FULLTIME) {
if (x.companyId) { if (x.companyId) {
if (x.cityId) {
return {
company: {
connect: {
id: x.companyId,
},
},
durationInMonths: x.durationInMonths,
jobType: x.jobType,
level: x.level,
location: {
connect: {
id: x.cityId
}
},
title: x.title,
totalCompensation:
x.totalCompensation != null
? {
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
x.totalCompensation.value,
x.totalCompensation.currency,
baseCurrencyString,
),
currency: x.totalCompensation.currency,
value: x.totalCompensation.value,
},
}
: undefined,
};
}
return { return {
company: { company: {
connect: { connect: {
@ -402,11 +435,40 @@ export const offersProfileRouter = createRouter()
: undefined, : undefined,
}; };
} }
if (x.cityId) {
return {
durationInMonths: x.durationInMonths,
jobType: x.jobType,
level: x.level,
location: {
connect: {
where: {
id: x.cityId
}
}
},
title: x.title,
totalCompensation:
x.totalCompensation != null
? {
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
x.totalCompensation.value,
x.totalCompensation.currency,
baseCurrencyString,
),
currency: x.totalCompensation.currency,
value: x.totalCompensation.value,
},
}
: undefined,
};
}
return { return {
durationInMonths: x.durationInMonths, durationInMonths: x.durationInMonths,
jobType: x.jobType, jobType: x.jobType,
level: x.level, level: x.level,
location: x.location,
title: x.title, title: x.title,
totalCompensation: totalCompensation:
x.totalCompensation != null x.totalCompensation != null
@ -427,6 +489,40 @@ export const offersProfileRouter = createRouter()
} }
if (x.jobType === JobType.INTERN) { if (x.jobType === JobType.INTERN) {
if (x.companyId) { if (x.companyId) {
if (x.cityId) {
return {
company: {
connect: {
id: x.companyId,
},
},
durationInMonths: x.durationInMonths,
jobType: x.jobType,
location: {
connect: {
where: {
id: x.cityId
}
}
},
monthlySalary:
x.monthlySalary != null
? {
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
x.monthlySalary.value,
x.monthlySalary.currency,
baseCurrencyString,
),
currency: x.monthlySalary.currency,
value: x.monthlySalary.value,
},
}
: undefined,
title: x.title,
};
}
return { return {
company: { company: {
connect: { connect: {
@ -453,6 +549,37 @@ export const offersProfileRouter = createRouter()
title: x.title, title: x.title,
}; };
} }
if (x.cityId) {
return {
durationInMonths: x.durationInMonths,
jobType: x.jobType,
location: {
connect: {
where: {
id: x.cityId
}
}
},
monthlySalary:
x.monthlySalary != null
? {
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
x.monthlySalary.value,
x.monthlySalary.currency,
baseCurrencyString,
),
currency: x.monthlySalary.currency,
value: x.monthlySalary.value,
},
}
: undefined,
title: x.title,
};
}
return { return {
durationInMonths: x.durationInMonths, durationInMonths: x.durationInMonths,
jobType: x.jobType, jobType: x.jobType,
@ -513,7 +640,13 @@ export const offersProfileRouter = createRouter()
}, },
}, },
jobType: x.jobType, jobType: x.jobType,
location: x.location, location: {
connect: {
where: {
id: x.cityId
}
}
},
monthYearReceived: x.monthYearReceived, monthYearReceived: x.monthYearReceived,
negotiationStrategy: x.negotiationStrategy, negotiationStrategy: x.negotiationStrategy,
offersIntern: { offersIntern: {
@ -553,7 +686,13 @@ export const offersProfileRouter = createRouter()
}, },
}, },
jobType: x.jobType, jobType: x.jobType,
location: x.location, location: {
connect: {
where: {
id: x.cityId
}
}
},
monthYearReceived: x.monthYearReceived, monthYearReceived: x.monthYearReceived,
negotiationStrategy: x.negotiationStrategy, negotiationStrategy: x.negotiationStrategy,
offersFullTime: { offersFullTime: {

Loading…
Cancel
Save