[offers][chore] add remove offers/experience/education/specificyoe in editprofile

This commit is contained in:
Stuart Long Chay Boon
2022-10-21 16:28:24 +08:00
parent 35494dc7ea
commit 817f1d5705
2 changed files with 127 additions and 82 deletions

View File

@ -244,7 +244,7 @@ function Test() {
backgroundId: 'cl9i68fv60001tthj23g9tuv4',
endDate: new Date('2018-09-30T07:58:54.000Z'),
field: 'Computer Science',
id: 'cl9i68fv60002tthjq4eux7kn',
id: 'cl9i87y7z004otthjmpsd48wo',
school: 'National University of Singapore',
startDate: new Date('2014-09-30T07:58:54.000Z'),
type: 'Bachelors',
@ -265,7 +265,7 @@ function Test() {
},
companyId: 'cl9h0bqug0003txxwgkac0x40',
durationInMonths: 24,
id: 'cl9i68fvc0004tthjo5jbr0yg',
// Id: 'cl9h0bqug0003txxwgkac0x40',
jobType: 'FULLTIME',
level: 'Junior',
monthlySalary: null,
@ -287,40 +287,16 @@ function Test() {
backgroundId: 'cl9i68fv60001tthj23g9tuv4',
domain: 'Backend',
id: 'cl9i68fvc0008tthjlxslzfo4',
yoe: 2,
yoe: 5,
},
{
backgroundId: 'cl9i68fv60001tthj23g9tuv4',
domain: 'Backend',
id: 'cl9i68fvc0009tthjwol3285l',
yoe: 2,
},
{
// BackgroundId: 'cl9i68fv60001tthj23g9tuv4',
domain: 'Backend',
// Id: 'cl976t39z00007iygt3np3cgo',
yoe: 2,
},
{
// BackgroundId: 'cl96stky6002fw32g6vj4meyr',
domain: 'Front End',
// Id: 'cl96stky7002mw32gn4jc7uml',
yoe: 2,
},
{
// BackgroundId: 'cl96stky6002fw32g6vj4meyr',
domain: 'Full Stack',
// Id: 'cl96stky7002nw32gpprghtxr',
yoe: 2,
},
{
// BackgroundId: 'cl96stky6002fw32g6vj4meyr',
domain: 'Backend',
// Id: 'cl976we5h000p7iygiomdo9fh',
yoe: 2,
yoe: 4,
},
],
totalYoe: 6,
totalYoe: 1,
},
createdAt: '2022-10-13T08:28:13.518Z',
// Discussion: [],
@ -380,59 +356,59 @@ function Test() {
offersInternId: null,
profileId: 'cl9i68fv60000tthj8t3zkox0',
},
{
comments: '',
company: {
createdAt: new Date('2022-10-12T16:19:05.196Z'),
description:
'Meta Platforms, Inc., doing business as Meta and formerly named Facebook, Inc., and TheFacebook, Inc., is an American multinational technology conglomerate based in Menlo Park, California. The company owns Facebook, Instagram, and WhatsApp, among other products and services.',
id: 'cl9h0bqug0003txxwgkac0x40',
logoUrl: 'https://logo.clearbit.com/meta.com',
name: 'Meta',
slug: 'meta',
updatedAt: new Date('2022-10-12T16:19:05.196Z'),
},
companyId: 'cl9h0bqug0003txxwgkac0x40',
id: 'cl9i68fvf000ytthj0ltsqt1d',
jobType: 'FULLTIME',
location: 'Singapore, Singapore',
monthYearReceived: new Date('2022-09-30T07:58:54.000Z'),
negotiationStrategy: 'Leveraged having million offers',
offersFullTime: {
baseSalary: {
currency: 'SGD',
id: 'cl9i68fvf0010tthj0iym6woh',
value: 84000,
},
baseSalaryId: 'cl9i68fvf0010tthj0iym6woh',
bonus: {
currency: 'SGD',
id: 'cl9i68fvf0012tthjioltnspk',
value: 123456789,
},
bonusId: 'cl9i68fvf0012tthjioltnspk',
id: 'cl9i68fvf000ztthjcovbiehc',
level: 'Junior',
specialization: 'Front End',
stocks: {
currency: 'SGD',
id: 'cl9i68fvf0014tthjz2gff3hs',
value: 100,
},
stocksId: 'cl9i68fvf0014tthjz2gff3hs',
title: 'Software Engineer',
totalCompensation: {
currency: 'SGD',
id: 'cl9i68fvf0016tthjrtb7iuvj',
value: 104100,
},
totalCompensationId: 'cl9i68fvf0016tthjrtb7iuvj',
},
offersFullTimeId: 'cl9i68fvf000ztthjcovbiehc',
offersIntern: null,
offersInternId: null,
profileId: 'cl9i68fv60000tthj8t3zkox0',
},
// {
// comments: '',
// company: {
// createdAt: new Date('2022-10-12T16:19:05.196Z'),
// description:
// 'Meta Platforms, Inc., doing business as Meta and formerly named Facebook, Inc., and TheFacebook, Inc., is an American multinational technology conglomerate based in Menlo Park, California. The company owns Facebook, Instagram, and WhatsApp, among other products and services.',
// id: 'cl9h0bqug0003txxwgkac0x40',
// logoUrl: 'https://logo.clearbit.com/meta.com',
// name: 'Meta',
// slug: 'meta',
// updatedAt: new Date('2022-10-12T16:19:05.196Z'),
// },
// companyId: 'cl9h0bqug0003txxwgkac0x40',
// id: 'cl9i68fvf000ytthj0ltsqt1d',
// jobType: 'FULLTIME',
// location: 'Singapore, Singapore',
// monthYearReceived: new Date('2022-09-30T07:58:54.000Z'),
// negotiationStrategy: 'Leveraged having million offers',
// offersFullTime: {
// baseSalary: {
// currency: 'SGD',
// id: 'cl9i68fvf0010tthj0iym6woh',
// value: 84000,
// },
// baseSalaryId: 'cl9i68fvf0010tthj0iym6woh',
// bonus: {
// currency: 'SGD',
// id: 'cl9i68fvf0012tthjioltnspk',
// value: 123456789,
// },
// bonusId: 'cl9i68fvf0012tthjioltnspk',
// id: 'cl9i68fvf000ztthjcovbiehc',
// level: 'Junior',
// specialization: 'Front End',
// stocks: {
// currency: 'SGD',
// id: 'cl9i68fvf0014tthjz2gff3hs',
// value: 100,
// },
// stocksId: 'cl9i68fvf0014tthjz2gff3hs',
// title: 'Software Engineer',
// totalCompensation: {
// currency: 'SGD',
// id: 'cl9i68fvf0016tthjrtb7iuvj',
// value: 104100,
// },
// totalCompensationId: 'cl9i68fvf0016tthjrtb7iuvj',
// },
// offersFullTimeId: 'cl9i68fvf000ztthjcovbiehc',
// offersIntern: null,
// offersInternId: null,
// profileId: 'cl9i68fv60000tthj8t3zkox0',
// },
// {
// comments: '',
// company: {

View File

@ -572,6 +572,23 @@ export const offersProfileRouter = createRouter()
},
});
// Delete educations
const educationsId = (await ctx.prisma.offersEducation.findMany({
where: {
backgroundId: input.background.id
}
})).map((x) => x.id)
for (const id of educationsId) {
if (!input.background.educations.map((x) => x.id).includes(id)) {
await ctx.prisma.offersEducation.delete({
where: {
id
}
})
}
}
for (const edu of input.background.educations) {
if (edu.id) {
// Update existing education
@ -608,6 +625,23 @@ export const offersProfileRouter = createRouter()
}
}
// Delete experiences
const experiencesId = (await ctx.prisma.offersExperience.findMany({
where: {
backgroundId: input.background.id
}
})).map((x) => x.id)
for (const id of experiencesId) {
if (!input.background.experiences.map((x) => x.id).includes(id)) {
await ctx.prisma.offersExperience.delete({
where: {
id
}
})
}
}
for (const exp of input.background.experiences) {
if (exp.id) {
// Update existing experience
@ -764,6 +798,23 @@ export const offersProfileRouter = createRouter()
}
}
// Delete specific yoes
const yoesId = (await ctx.prisma.offersSpecificYoe.findMany({
where: {
backgroundId: input.background.id
}
})).map((x) => x.id)
for (const id of yoesId) {
if (!input.background.specificYoes.map((x) => x.id).includes(id)) {
await ctx.prisma.offersSpecificYoe.delete({
where: {
id
}
})
}
}
for (const yoe of input.background.specificYoes) {
if (yoe.id) {
// Update existing yoe
@ -793,6 +844,24 @@ export const offersProfileRouter = createRouter()
}
}
// Delete specific offers
const offers = (await ctx.prisma.offersOffer.findMany({
where: {
profileId: input.id
}
})).map((x) => x.id)
for (const id of offers) {
if (!input.offers.map((x) => x.id).includes(id)) {
await ctx.prisma.offersOffer.delete({
where: {
id
}
})
}
}
// Update remaining offers
for (const offerToUpdate of input.offers) {
if (offerToUpdate.id) {
// Update existing offer