mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-02-03 02:24:47 +08:00
[offers][fix] use upsert to remove id in valuation
This commit is contained in:
@@ -786,26 +786,10 @@ export const offersProfileRouter = createRouter()
|
||||
});
|
||||
|
||||
if (exp.monthlySalary) {
|
||||
if (exp.monthlySalary.id) {
|
||||
await ctx.prisma.offersCurrency.update({
|
||||
data: {
|
||||
baseCurrency: baseCurrencyString,
|
||||
baseValue: await convert(
|
||||
exp.monthlySalary.value,
|
||||
exp.monthlySalary.currency,
|
||||
baseCurrencyString,
|
||||
),
|
||||
currency: exp.monthlySalary.currency,
|
||||
value: exp.monthlySalary.value,
|
||||
},
|
||||
where: {
|
||||
id: exp.monthlySalary.id,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await ctx.prisma.offersExperience.update({
|
||||
data: {
|
||||
monthlySalary: {
|
||||
await ctx.prisma.offersExperience.update({
|
||||
data: {
|
||||
monthlySalary: {
|
||||
upsert: {
|
||||
create: {
|
||||
baseCurrency: baseCurrencyString,
|
||||
baseValue: await convert(
|
||||
@@ -816,36 +800,30 @@ export const offersProfileRouter = createRouter()
|
||||
currency: exp.monthlySalary.currency,
|
||||
value: exp.monthlySalary.value,
|
||||
},
|
||||
},
|
||||
},
|
||||
where: {
|
||||
id: exp.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
update: {
|
||||
baseCurrency: baseCurrencyString,
|
||||
baseValue: await convert(
|
||||
exp.monthlySalary.value,
|
||||
exp.monthlySalary.currency,
|
||||
baseCurrencyString,
|
||||
),
|
||||
currency: exp.monthlySalary.currency,
|
||||
value: exp.monthlySalary.value,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
where: {
|
||||
id: exp.id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (exp.totalCompensation) {
|
||||
if (exp.totalCompensation.id) {
|
||||
await ctx.prisma.offersCurrency.update({
|
||||
data: {
|
||||
baseCurrency: baseCurrencyString,
|
||||
baseValue: await convert(
|
||||
exp.totalCompensation.value,
|
||||
exp.totalCompensation.currency,
|
||||
baseCurrencyString,
|
||||
),
|
||||
currency: exp.totalCompensation.currency,
|
||||
value: exp.totalCompensation.value,
|
||||
},
|
||||
where: {
|
||||
id: exp.totalCompensation.id,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await ctx.prisma.offersExperience.update({
|
||||
data: {
|
||||
totalCompensation: {
|
||||
await ctx.prisma.offersExperience.update({
|
||||
data: {
|
||||
totalCompensation: {
|
||||
upsert: {
|
||||
create: {
|
||||
baseCurrency: baseCurrencyString,
|
||||
baseValue: await convert(
|
||||
@@ -856,13 +834,23 @@ export const offersProfileRouter = createRouter()
|
||||
currency: exp.totalCompensation.currency,
|
||||
value: exp.totalCompensation.value,
|
||||
},
|
||||
},
|
||||
},
|
||||
where: {
|
||||
id: exp.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
update: {
|
||||
baseCurrency: baseCurrencyString,
|
||||
baseValue: await convert(
|
||||
exp.totalCompensation.value,
|
||||
exp.totalCompensation.currency,
|
||||
baseCurrencyString,
|
||||
),
|
||||
currency: exp.totalCompensation.currency,
|
||||
value: exp.totalCompensation.value,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
where: {
|
||||
id: exp.id
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if (!exp.id) {
|
||||
// Create new experience
|
||||
|
||||
Reference in New Issue
Block a user