From a879639b531ee2a7a6d6620c450541db067bfd83 Mon Sep 17 00:00:00 2001 From: Stuart Long Chay Boon Date: Wed, 19 Oct 2022 18:47:03 +0800 Subject: [PATCH] [offers][chore] add migration sql and change naming conventions --- .../migration.sql | 14 + apps/portal/prisma/schema.prisma | 6 +- apps/portal/src/mappers/offers-mappers.ts | 142 ++++---- .../src/pages/offers/test/createProfile.tsx | 139 ++++---- .../router/offers/offers-analysis-router.ts | 78 ++--- .../router/offers/offers-profile-router.ts | 318 +++++++++--------- .../portal/src/server/router/offers/offers.ts | 54 +-- 7 files changed, 382 insertions(+), 369 deletions(-) create mode 100644 apps/portal/prisma/migrations/20221019104025_update_offers_remove_optional/migration.sql diff --git a/apps/portal/prisma/migrations/20221019104025_update_offers_remove_optional/migration.sql b/apps/portal/prisma/migrations/20221019104025_update_offers_remove_optional/migration.sql new file mode 100644 index 00000000..ec31acd3 --- /dev/null +++ b/apps/portal/prisma/migrations/20221019104025_update_offers_remove_optional/migration.sql @@ -0,0 +1,14 @@ +/* + Warnings: + + - Made the column `totalYoe` on table `OffersBackground` required. This step will fail if there are existing NULL values in that column. + - Made the column `negotiationStrategy` on table `OffersOffer` required. This step will fail if there are existing NULL values in that column. + - Made the column `comments` on table `OffersOffer` required. This step will fail if there are existing NULL values in that column. + +*/ +-- AlterTable +ALTER TABLE "OffersBackground" ALTER COLUMN "totalYoe" SET NOT NULL; + +-- AlterTable +ALTER TABLE "OffersOffer" ALTER COLUMN "negotiationStrategy" SET NOT NULL, +ALTER COLUMN "comments" SET NOT NULL; diff --git a/apps/portal/prisma/schema.prisma b/apps/portal/prisma/schema.prisma index 45a730a3..2857204b 100644 --- a/apps/portal/prisma/schema.prisma +++ b/apps/portal/prisma/schema.prisma @@ -315,13 +315,13 @@ model OffersOffer { jobType JobType - OffersIntern OffersIntern? @relation(fields: [offersInternId], references: [id], onDelete: Cascade) + offersIntern OffersIntern? @relation(fields: [offersInternId], references: [id], onDelete: Cascade) offersInternId String? @unique - OffersFullTime OffersFullTime? @relation(fields: [offersFullTimeId], references: [id], onDelete: Cascade) + offersFullTime OffersFullTime? @relation(fields: [offersFullTimeId], references: [id], onDelete: Cascade) offersFullTimeId String? @unique - OffersAnalysis OffersAnalysis? @relation("HighestOverallOffer") + OffersAnalysis OffersAnalysis? @relation("HighestOverallOffer") OffersAnalysisTopOverallOffers OffersAnalysis[] @relation("TopOverallOffers") OffersAnalysisTopCompanyOffers OffersAnalysis[] @relation("TopCompanyOffers") } diff --git a/apps/portal/src/mappers/offers-mappers.ts b/apps/portal/src/mappers/offers-mappers.ts index 1a6e415c..82a7a915 100644 --- a/apps/portal/src/mappers/offers-mappers.ts +++ b/apps/portal/src/mappers/offers-mappers.ts @@ -37,11 +37,11 @@ import type { const analysisOfferDtoMapper = ( offer: OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { totalCompensation: OffersCurrency }) | null; - OffersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; + offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; profile: OffersProfile & { background: OffersBackground | null }; }, ) => { @@ -51,7 +51,7 @@ const analysisOfferDtoMapper = ( id: offer.id, income: -1, jobType: offer.jobType, - level: offer.OffersFullTime?.level ?? '', + level: offer.offersFullTime?.level ?? '', location: offer.location, monthYearReceived: offer.monthYearReceived, negotiationStrategy: offer.negotiationStrategy, @@ -59,19 +59,19 @@ const analysisOfferDtoMapper = ( profileName, specialization: offer.jobType === JobType.FULLTIME - ? offer.OffersFullTime?.specialization ?? '' - : offer.OffersIntern?.specialization ?? '', + ? offer.offersFullTime?.specialization ?? '' + : offer.offersIntern?.specialization ?? '', title: offer.jobType === JobType.FULLTIME - ? offer.OffersFullTime?.title ?? '' - : offer.OffersIntern?.title ?? '', + ? offer.offersFullTime?.title ?? '' + : offer.offersIntern?.title ?? '', totalYoe: background?.totalYoe ?? -1, }; - if (offer.OffersFullTime?.totalCompensation) { - analysisOfferDto.income = offer.OffersFullTime.totalCompensation.value; - } else if (offer.OffersIntern?.monthlySalary) { - analysisOfferDto.income = offer.OffersIntern.monthlySalary.value; + if (offer.offersFullTime?.totalCompensation) { + analysisOfferDto.income = offer.offersFullTime.totalCompensation.value; + } else if (offer.offersIntern?.monthlySalary) { + analysisOfferDto.income = offer.offersIntern.monthlySalary.value; } return analysisOfferDto; @@ -82,11 +82,11 @@ const analysisDtoMapper = ( percentile: number, topPercentileOffers: Array< OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { totalCompensation: OffersCurrency }) | null; - OffersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; + offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; profile: OffersProfile & { background: OffersBackground | null }; } >, @@ -103,23 +103,23 @@ const analysisDtoMapper = ( const analysisHighestOfferDtoMapper = ( offer: OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { totalCompensation: OffersCurrency }) | null; - OffersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; + offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; profile: OffersProfile & { background: OffersBackground | null }; }, ) => { const analysisHighestOfferDto: AnalysisHighestOffer = { company: offersCompanyDtoMapper(offer.company), id: offer.id, - level: offer.OffersFullTime?.level ?? '', + level: offer.offersFullTime?.level ?? '', location: offer.location, specialization: offer.jobType === JobType.FULLTIME - ? offer.OffersFullTime?.specialization ?? '' - : offer.OffersIntern?.specialization ?? '', + ? offer.offersFullTime?.specialization ?? '' + : offer.offersIntern?.specialization ?? '', totalYoe: offer.profile.background?.totalYoe ?? -1, }; return analysisHighestOfferDto; @@ -129,24 +129,24 @@ export const profileAnalysisDtoMapper = ( analysis: | (OffersAnalysis & { overallHighestOffer: OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { totalCompensation: OffersCurrency }) | null; - OffersIntern: + offersIntern: | (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; profile: OffersProfile & { background: OffersBackground | null }; }; topCompanyOffers: Array< OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { totalCompensation: OffersCurrency }) | null; - OffersIntern: + offersIntern: | (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; profile: OffersProfile & { background: | (OffersBackground & { @@ -160,13 +160,13 @@ export const profileAnalysisDtoMapper = ( >; topOverallOffers: Array< OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { totalCompensation: OffersCurrency }) | null; - OffersIntern: + offersIntern: | (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; profile: OffersProfile & { background: | (OffersBackground & { @@ -337,7 +337,8 @@ export const backgroundDtoMapper = ( export const profileOfferDtoMapper = ( offer: OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { baseSalary: OffersCurrency; bonus: OffersCurrency; @@ -345,8 +346,7 @@ export const profileOfferDtoMapper = ( totalCompensation: OffersCurrency; }) | null; - OffersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; + offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; }, ) => { const profileOfferDto: ProfileOffer = { @@ -357,31 +357,31 @@ export const profileOfferDtoMapper = ( location: offer.location, monthYearReceived: offer.monthYearReceived, negotiationStrategy: offer.negotiationStrategy, - offersFullTime: offer.OffersFullTime, - offersIntern: offer.OffersIntern, + offersFullTime: offer.offersFullTime, + offersIntern: offer.offersIntern, }; - if (offer.OffersFullTime) { + if (offer.offersFullTime) { profileOfferDto.offersFullTime = { - baseSalary: valuationDtoMapper(offer.OffersFullTime.baseSalary), - bonus: valuationDtoMapper(offer.OffersFullTime.bonus), - id: offer.OffersFullTime.id, - level: offer.OffersFullTime.level, - specialization: offer.OffersFullTime.specialization, - stocks: valuationDtoMapper(offer.OffersFullTime.stocks), - title: offer.OffersFullTime.title, + baseSalary: valuationDtoMapper(offer.offersFullTime.baseSalary), + bonus: valuationDtoMapper(offer.offersFullTime.bonus), + id: offer.offersFullTime.id, + level: offer.offersFullTime.level, + specialization: offer.offersFullTime.specialization, + stocks: valuationDtoMapper(offer.offersFullTime.stocks), + title: offer.offersFullTime.title, totalCompensation: valuationDtoMapper( - offer.OffersFullTime.totalCompensation, + offer.offersFullTime.totalCompensation, ), }; - } else if (offer.OffersIntern) { + } else if (offer.offersIntern) { profileOfferDto.offersIntern = { - id: offer.OffersIntern.id, - internshipCycle: offer.OffersIntern.internshipCycle, - monthlySalary: valuationDtoMapper(offer.OffersIntern.monthlySalary), - specialization: offer.OffersIntern.specialization, - startYear: offer.OffersIntern.startYear, - title: offer.OffersIntern.title, + id: offer.offersIntern.id, + internshipCycle: offer.offersIntern.internshipCycle, + monthlySalary: valuationDtoMapper(offer.offersIntern.monthlySalary), + specialization: offer.offersIntern.specialization, + startYear: offer.offersIntern.startYear, + title: offer.offersIntern.title, }; } @@ -393,24 +393,24 @@ export const profileDtoMapper = ( analysis: | (OffersAnalysis & { overallHighestOffer: OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { totalCompensation: OffersCurrency }) | null; - OffersIntern: + offersIntern: | (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; profile: OffersProfile & { background: OffersBackground | null }; }; topCompanyOffers: Array< OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { totalCompensation: OffersCurrency }) | null; - OffersIntern: + offersIntern: | (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; profile: OffersProfile & { background: | (OffersBackground & { @@ -424,13 +424,13 @@ export const profileDtoMapper = ( >; topOverallOffers: Array< OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { totalCompensation: OffersCurrency }) | null; - OffersIntern: + offersIntern: | (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; profile: OffersProfile & { background: | (OffersBackground & { @@ -466,7 +466,8 @@ export const profileDtoMapper = ( >; offers: Array< OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { baseSalary: OffersCurrency; bonus: OffersCurrency; @@ -474,8 +475,7 @@ export const profileDtoMapper = ( totalCompensation: OffersCurrency; }) | null; - OffersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; + offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; } >; }, @@ -526,7 +526,8 @@ export const addToProfileResponseMapper = (updatedProfile: { export const dashboardOfferDtoMapper = ( offer: OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { baseSalary: OffersCurrency; bonus: OffersCurrency; @@ -534,8 +535,7 @@ export const dashboardOfferDtoMapper = ( totalCompensation: OffersCurrency; }) | null; - OffersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; + offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; profile: OffersProfile & { background: OffersBackground | null }; }, ) => { @@ -545,17 +545,17 @@ export const dashboardOfferDtoMapper = ( income: valuationDtoMapper({ currency: '', value: -1 }), monthYearReceived: offer.monthYearReceived, profileId: offer.profileId, - title: offer.OffersFullTime?.title ?? '', + title: offer.offersFullTime?.title ?? '', totalYoe: offer.profile.background?.totalYoe ?? -1, }; - if (offer.OffersFullTime) { + if (offer.offersFullTime) { dashboardOfferDto.income = valuationDtoMapper( - offer.OffersFullTime.totalCompensation, + offer.offersFullTime.totalCompensation, ); - } else if (offer.OffersIntern) { + } else if (offer.offersIntern) { dashboardOfferDto.income = valuationDtoMapper( - offer.OffersIntern.monthlySalary, + offer.offersIntern.monthlySalary, ); } diff --git a/apps/portal/src/pages/offers/test/createProfile.tsx b/apps/portal/src/pages/offers/test/createProfile.tsx index 6aad538b..93ff8b7e 100644 --- a/apps/portal/src/pages/offers/test/createProfile.tsx +++ b/apps/portal/src/pages/offers/test/createProfile.tsx @@ -130,7 +130,14 @@ function Test() { }, offers: [ { - OffersFullTime: { + comments: 'I am a Raffles Institution almumni', + // Comments: '', + companyId: 'cl98yuqk80007txhgjtjp8fk4', + jobType: 'FULLTIME', + location: 'Singapore, Singapore', + monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), + negotiationStrategy: 'Leveraged having multiple offers', + offersFullTime: { baseSalary: { currency: 'SGD', value: 84000, @@ -151,17 +158,15 @@ function Test() { value: 104100, }, }, - - comments: 'I am a Raffles Institution almumni', - // Comments: '', + }, + { + comments: '', companyId: 'cl98yuqk80007txhgjtjp8fk4', jobType: 'FULLTIME', location: 'Singapore, Singapore', monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), negotiationStrategy: 'Leveraged having multiple offers', - }, - { - OffersFullTime: { + offersFullTime: { baseSalary: { currency: 'SGD', value: 84000, @@ -182,12 +187,6 @@ function Test() { value: 104100, }, }, - comments: '', - companyId: 'cl98yuqk80007txhgjtjp8fk4', - jobType: 'FULLTIME', - location: 'Singapore, Singapore', - monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), - negotiationStrategy: 'Leveraged having multiple offers', }, ], }); @@ -330,7 +329,24 @@ function Test() { isEditable: true, offers: [ { - OffersFullTime: { + comments: 'this IS SO IEUHDAEUIGDI', + 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: 'cl95u79f000007im531ysjg79', + logoUrl: 'https://logo.clearbit.com/meta.com', + name: 'Meta', + slug: 'meta', + updatedAt: new Date('2022-10-12T16:19:05.196Z'), + }, + companyId: 'cl9ec1mgg0000w33hg1a3612r', + id: 'cl976t4de00047iygl0zbce11', + jobType: 'FULLTIME', + location: 'Singapore, Singapore', + monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), + negotiationStrategy: 'Charmed the guy with my face', + offersFullTime: { baseSalary: { currency: 'SGD', id: 'cl976t4de00067iyg3pjir7k9', @@ -360,8 +376,13 @@ function Test() { }, totalCompensationId: 'cl976t4df000c7iyg73ryf5uw', }, - OffersIntern: null, - comments: 'this IS SO IEUHDAEUIGDI', + offersFullTimeId: 'cl976t4de00057iygq3ktce3v', + offersIntern: null, + offersInternId: null, + profileId: 'cl96stky5002ew32gx2kale2x', + }, + { + comments: '', company: { createdAt: new Date('2022-10-12T16:19:05.196Z'), description: @@ -373,17 +394,12 @@ function Test() { updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, companyId: 'cl9ec1mgg0000w33hg1a3612r', - id: 'cl976t4de00047iygl0zbce11', + id: 'cl96stky80031w32gau9mu1gs', jobType: 'FULLTIME', location: 'Singapore, Singapore', monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), - negotiationStrategy: 'Charmed the guy with my face', - offersFullTimeId: 'cl976t4de00057iygq3ktce3v', - offersInternId: null, - profileId: 'cl96stky5002ew32gx2kale2x', - }, - { - OffersFullTime: { + negotiationStrategy: 'Leveraged having million offers', + offersFullTime: { baseSalary: { currency: 'SGD', id: 'cl96stky80033w32gxw5goc4z', @@ -413,7 +429,12 @@ function Test() { }, totalCompensationId: 'cl96stky90039w32glbpktd0o', }, - OffersIntern: null, + offersFullTimeId: 'cl96stky80032w32gep9ovgj3', + offersIntern: null, + offersInternId: null, + profileId: 'cl96stky5002ew32gx2kale2x', + }, + { comments: '', company: { createdAt: new Date('2022-10-12T16:19:05.196Z'), @@ -426,17 +447,12 @@ function Test() { updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, companyId: 'cl9ec1mgg0000w33hg1a3612r', - id: 'cl96stky80031w32gau9mu1gs', + id: 'cl96stky9003bw32gc3l955vr', jobType: 'FULLTIME', location: 'Singapore, Singapore', monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), - negotiationStrategy: 'Leveraged having million offers', - offersFullTimeId: 'cl96stky80032w32gep9ovgj3', - offersInternId: null, - profileId: 'cl96stky5002ew32gx2kale2x', - }, - { - OffersFullTime: { + negotiationStrategy: 'LOst out having multiple offers', + offersFullTime: { baseSalary: { currency: 'SGD', id: 'cl96stky9003dw32gcvqbijlo', @@ -466,8 +482,13 @@ function Test() { }, totalCompensationId: 'cl96stky9003jw32gzumcoi7v', }, - OffersIntern: null, - comments: '', + offersFullTimeId: 'cl96stky9003cw32g5v10izfu', + offersIntern: null, + offersInternId: null, + profileId: 'cl96stky5002ew32gx2kale2x', + }, + { + comments: 'this IS SO COOL', company: { createdAt: new Date('2022-10-12T16:19:05.196Z'), description: @@ -479,17 +500,12 @@ function Test() { updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, companyId: 'cl9ec1mgg0000w33hg1a3612r', - id: 'cl96stky9003bw32gc3l955vr', + id: 'cl976wf28000t7iyga4noyz7s', jobType: 'FULLTIME', location: 'Singapore, Singapore', monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), - negotiationStrategy: 'LOst out having multiple offers', - offersFullTimeId: 'cl96stky9003cw32g5v10izfu', - offersInternId: null, - profileId: 'cl96stky5002ew32gx2kale2x', - }, - { - OffersFullTime: { + negotiationStrategy: 'Charmed the guy with my face', + offersFullTime: { baseSalary: { currency: 'SGD', id: 'cl976wf28000v7iygmk1b7qaq', @@ -519,8 +535,13 @@ function Test() { }, totalCompensationId: 'cl976wf2800117iygmzsc0xit', }, - OffersIntern: null, - comments: 'this IS SO COOL', + offersFullTimeId: 'cl976wf28000u7iyg6euei8e9', + offersIntern: null, + offersInternId: null, + profileId: 'cl96stky5002ew32gx2kale2x', + }, + { + comments: 'this rocks', company: { createdAt: new Date('2022-10-12T16:19:05.196Z'), description: @@ -532,17 +553,12 @@ function Test() { updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, companyId: 'cl9ec1mgg0000w33hg1a3612r', - id: 'cl976wf28000t7iyga4noyz7s', + id: 'cl96tbb3o0051w32gjrpaiiit', jobType: 'FULLTIME', location: 'Singapore, Singapore', monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), negotiationStrategy: 'Charmed the guy with my face', - offersFullTimeId: 'cl976wf28000u7iyg6euei8e9', - offersInternId: null, - profileId: 'cl96stky5002ew32gx2kale2x', - }, - { - OffersFullTime: { + offersFullTime: { baseSalary: { currency: 'SGD', id: 'cl96tbb3o0053w32gz11paaxu', @@ -572,25 +588,8 @@ function Test() { }, totalCompensationId: 'cl96tbb3o0059w32gm3iy1zk4', }, - OffersIntern: null, - comments: 'this rocks', - 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: 'cl95u79f000007im531ysjg79', - logoUrl: 'https://logo.clearbit.com/meta.com', - name: 'Meta', - slug: 'meta', - updatedAt: new Date('2022-10-12T16:19:05.196Z'), - }, - companyId: 'cl9ec1mgg0000w33hg1a3612r', - id: 'cl96tbb3o0051w32gjrpaiiit', - jobType: 'FULLTIME', - location: 'Singapore, Singapore', - monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), - negotiationStrategy: 'Charmed the guy with my face', offersFullTimeId: 'cl96tbb3o0052w32guguajzin', + offersIntern: null, offersInternId: null, profileId: 'cl96stky5002ew32gx2kale2x', }, diff --git a/apps/portal/src/server/router/offers/offers-analysis-router.ts b/apps/portal/src/server/router/offers/offers-analysis-router.ts index de92b546..a7d68ac5 100644 --- a/apps/portal/src/server/router/offers/offers-analysis-router.ts +++ b/apps/portal/src/server/router/offers/offers-analysis-router.ts @@ -16,7 +16,8 @@ import { createRouter } from '../context'; const searchOfferPercentile = ( offer: OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { baseSalary: OffersCurrency; bonus: OffersCurrency; @@ -24,19 +25,18 @@ const searchOfferPercentile = ( totalCompensation: OffersCurrency; }) | null; - OffersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; + offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; profile: OffersProfile & { background: OffersBackground | null }; }, similarOffers: Array< OffersOffer & { - OffersFullTime: + company: Company; + offersFullTime: | (OffersFullTime & { totalCompensation: OffersCurrency; }) | null; - OffersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; - company: Company; + offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null; profile: OffersProfile & { background: OffersBackground | null }; } >, @@ -64,7 +64,8 @@ export const offersAnalysisRouter = createRouter() const offers = await ctx.prisma.offersOffer.findMany({ include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { baseSalary: true, bonus: true, @@ -72,12 +73,11 @@ export const offersAnalysisRouter = createRouter() totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: true, @@ -86,14 +86,14 @@ export const offersAnalysisRouter = createRouter() }, orderBy: [ { - OffersFullTime: { + offersFullTime: { totalCompensation: { value: 'desc', }, }, }, { - OffersIntern: { + offersIntern: { monthlySalary: { value: 'desc', }, @@ -129,17 +129,17 @@ export const offersAnalysisRouter = createRouter() let similarOffers = await ctx.prisma.offersOffer.findMany({ include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: { @@ -156,14 +156,14 @@ export const offersAnalysisRouter = createRouter() }, orderBy: [ { - OffersFullTime: { + offersFullTime: { totalCompensation: { value: 'desc', }, }, }, { - OffersIntern: { + offersIntern: { monthlySalary: { value: 'desc', }, @@ -178,14 +178,14 @@ export const offersAnalysisRouter = createRouter() { OR: [ { - OffersFullTime: { - level: overallHighestOffer.OffersFullTime?.level, + offersFullTime: { + level: overallHighestOffer.offersFullTime?.level, specialization: - overallHighestOffer.OffersFullTime?.specialization, + overallHighestOffer.offersFullTime?.specialization, }, - OffersIntern: { + offersIntern: { specialization: - overallHighestOffer.OffersIntern?.specialization, + overallHighestOffer.offersIntern?.specialization, }, }, ], @@ -289,17 +289,17 @@ export const offersAnalysisRouter = createRouter() include: { overallHighestOffer: { include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: true, @@ -309,17 +309,17 @@ export const offersAnalysisRouter = createRouter() }, topCompanyOffers: { include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: { @@ -337,17 +337,17 @@ export const offersAnalysisRouter = createRouter() }, topOverallOffers: { include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: { @@ -378,17 +378,17 @@ export const offersAnalysisRouter = createRouter() include: { overallHighestOffer: { include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: true, @@ -398,17 +398,17 @@ export const offersAnalysisRouter = createRouter() }, topCompanyOffers: { include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: { @@ -426,17 +426,17 @@ export const offersAnalysisRouter = createRouter() }, topOverallOffers: { include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: { diff --git a/apps/portal/src/server/router/offers/offers-profile-router.ts b/apps/portal/src/server/router/offers/offers-profile-router.ts index 11f74c3e..b17f3f3c 100644 --- a/apps/portal/src/server/router/offers/offers-profile-router.ts +++ b/apps/portal/src/server/router/offers/offers-profile-router.ts @@ -27,7 +27,15 @@ const company = z.object({ }); const offer = z.object({ - OffersFullTime: z + comments: z.string(), + company: company.nullish(), + companyId: z.string(), + id: z.string().optional(), + jobType: z.string(), + location: z.string(), + monthYearReceived: z.date(), + negotiationStrategy: z.string(), + offersFullTime: z .object({ baseSalary: valuation.nullish(), baseSalaryId: z.string().nullish(), @@ -43,7 +51,8 @@ const offer = z.object({ totalCompensationId: z.string().nullish(), }) .nullish(), - OffersIntern: z + offersFullTimeId: z.string().nullish(), + offersIntern: z .object({ id: z.string().optional(), internshipCycle: z.string().nullish(), @@ -54,15 +63,6 @@ const offer = z.object({ totalCompensation: valuation.nullish(), // Full time }) .nullish(), - comments: z.string(), - company: company.nullish(), - companyId: z.string(), - id: z.string().optional(), - jobType: z.string(), - location: z.string(), - monthYearReceived: z.date(), - negotiationStrategy: z.string(), - offersFullTimeId: z.string().nullish(), offersInternId: z.string().nullish(), profileId: z.string().nullish(), }); @@ -115,17 +115,17 @@ export const offersProfileRouter = createRouter() include: { overallHighestOffer: { include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: true, @@ -135,17 +135,17 @@ export const offersProfileRouter = createRouter() }, topCompanyOffers: { include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: { @@ -163,17 +163,17 @@ export const offersProfileRouter = createRouter() }, topOverallOffers: { include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: { @@ -213,7 +213,8 @@ export const offersProfileRouter = createRouter() }, offers: { include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { baseSalary: true, bonus: true, @@ -221,12 +222,11 @@ export const offersProfileRouter = createRouter() totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, }, }, }, @@ -381,27 +381,53 @@ export const offersProfileRouter = createRouter() create: input.offers.map((x) => { if ( x.jobType === 'INTERN' && - x.OffersIntern && - x.OffersIntern.internshipCycle && - x.OffersIntern.monthlySalary?.currency && - x.OffersIntern.monthlySalary.value && - x.OffersIntern.startYear + x.offersIntern && + x.offersIntern.internshipCycle && + x.offersIntern.monthlySalary?.currency && + x.offersIntern.monthlySalary.value && + x.offersIntern.startYear ) { return { - OffersIntern: { + comments: x.comments, + company: { + connect: { + id: x.companyId, + }, + }, + jobType: x.jobType, + location: x.location, + monthYearReceived: x.monthYearReceived, + negotiationStrategy: x.negotiationStrategy, + offersIntern: { create: { - internshipCycle: x.OffersIntern.internshipCycle, + internshipCycle: x.offersIntern.internshipCycle, monthlySalary: { create: { - currency: x.OffersIntern.monthlySalary?.currency, - value: x.OffersIntern.monthlySalary?.value, + currency: x.offersIntern.monthlySalary?.currency, + value: x.offersIntern.monthlySalary?.value, }, }, - specialization: x.OffersIntern.specialization, - startYear: x.OffersIntern.startYear, - title: x.OffersIntern.title, + specialization: x.offersIntern.specialization, + startYear: x.offersIntern.startYear, + title: x.offersIntern.title, }, }, + }; + } + if ( + x.jobType === 'FULLTIME' && + x.offersFullTime && + x.offersFullTime.baseSalary?.currency && + x.offersFullTime.baseSalary?.value && + x.offersFullTime.bonus?.currency && + x.offersFullTime.bonus?.value && + x.offersFullTime.stocks?.currency && + x.offersFullTime.stocks?.value && + x.offersFullTime.totalCompensation?.currency && + x.offersFullTime.totalCompensation?.value && + x.offersFullTime.level + ) { + return { comments: x.comments, company: { connect: { @@ -412,64 +438,38 @@ export const offersProfileRouter = createRouter() location: x.location, monthYearReceived: x.monthYearReceived, negotiationStrategy: x.negotiationStrategy, - }; - } - if ( - x.jobType === 'FULLTIME' && - x.OffersFullTime && - x.OffersFullTime.baseSalary?.currency && - x.OffersFullTime.baseSalary?.value && - x.OffersFullTime.bonus?.currency && - x.OffersFullTime.bonus?.value && - x.OffersFullTime.stocks?.currency && - x.OffersFullTime.stocks?.value && - x.OffersFullTime.totalCompensation?.currency && - x.OffersFullTime.totalCompensation?.value && - x.OffersFullTime.level - ) { - return { - OffersFullTime: { + offersFullTime: { create: { baseSalary: { create: { - currency: x.OffersFullTime.baseSalary?.currency, - value: x.OffersFullTime.baseSalary?.value, + currency: x.offersFullTime.baseSalary?.currency, + value: x.offersFullTime.baseSalary?.value, }, }, bonus: { create: { - currency: x.OffersFullTime.bonus?.currency, - value: x.OffersFullTime.bonus?.value, + currency: x.offersFullTime.bonus?.currency, + value: x.offersFullTime.bonus?.value, }, }, - level: x.OffersFullTime.level, - specialization: x.OffersFullTime.specialization, + level: x.offersFullTime.level, + specialization: x.offersFullTime.specialization, stocks: { create: { - currency: x.OffersFullTime.stocks?.currency, - value: x.OffersFullTime.stocks?.value, + currency: x.offersFullTime.stocks?.currency, + value: x.offersFullTime.stocks?.value, }, }, - title: x.OffersFullTime.title, + title: x.offersFullTime.title, totalCompensation: { create: { currency: - x.OffersFullTime.totalCompensation?.currency, - value: x.OffersFullTime.totalCompensation?.value, + x.offersFullTime.totalCompensation?.currency, + value: x.offersFullTime.totalCompensation?.value, }, }, }, }, - comments: x.comments, - company: { - connect: { - id: x.companyId, - }, - }, - jobType: x.jobType, - location: x.location, - monthYearReceived: x.monthYearReceived, - negotiationStrategy: x.negotiationStrategy, }; } @@ -813,127 +813,127 @@ export const offersProfileRouter = createRouter() }); } - if (offerToUpdate.OffersIntern?.monthlySalary) { + if (offerToUpdate.offersIntern?.monthlySalary) { await ctx.prisma.offersIntern.update({ data: { internshipCycle: - offerToUpdate.OffersIntern.internshipCycle ?? undefined, - specialization: offerToUpdate.OffersIntern.specialization, - startYear: offerToUpdate.OffersIntern.startYear ?? undefined, - title: offerToUpdate.OffersIntern.title, + offerToUpdate.offersIntern.internshipCycle ?? undefined, + specialization: offerToUpdate.offersIntern.specialization, + startYear: offerToUpdate.offersIntern.startYear ?? undefined, + title: offerToUpdate.offersIntern.title, }, where: { - id: offerToUpdate.OffersIntern.id, + id: offerToUpdate.offersIntern.id, }, }); await ctx.prisma.offersCurrency.update({ data: { - currency: offerToUpdate.OffersIntern.monthlySalary.currency, - value: offerToUpdate.OffersIntern.monthlySalary.value, + currency: offerToUpdate.offersIntern.monthlySalary.currency, + value: offerToUpdate.offersIntern.monthlySalary.value, }, where: { - id: offerToUpdate.OffersIntern.monthlySalary.id, + id: offerToUpdate.offersIntern.monthlySalary.id, }, }); } - if (offerToUpdate.OffersFullTime?.totalCompensation) { + if (offerToUpdate.offersFullTime?.totalCompensation) { await ctx.prisma.offersFullTime.update({ data: { - level: offerToUpdate.OffersFullTime.level ?? undefined, - specialization: offerToUpdate.OffersFullTime.specialization, - title: offerToUpdate.OffersFullTime.title, + level: offerToUpdate.offersFullTime.level ?? undefined, + specialization: offerToUpdate.offersFullTime.specialization, + title: offerToUpdate.offersFullTime.title, }, where: { - id: offerToUpdate.OffersFullTime.id, + id: offerToUpdate.offersFullTime.id, }, }); - if (offerToUpdate.OffersFullTime.baseSalary) { + if (offerToUpdate.offersFullTime.baseSalary) { await ctx.prisma.offersCurrency.update({ data: { - currency: offerToUpdate.OffersFullTime.baseSalary.currency, - value: offerToUpdate.OffersFullTime.baseSalary.value, + currency: offerToUpdate.offersFullTime.baseSalary.currency, + value: offerToUpdate.offersFullTime.baseSalary.value, }, where: { - id: offerToUpdate.OffersFullTime.baseSalary.id, + id: offerToUpdate.offersFullTime.baseSalary.id, }, }); } - if (offerToUpdate.OffersFullTime.bonus) { + if (offerToUpdate.offersFullTime.bonus) { await ctx.prisma.offersCurrency.update({ data: { - currency: offerToUpdate.OffersFullTime.bonus.currency, - value: offerToUpdate.OffersFullTime.bonus.value, + currency: offerToUpdate.offersFullTime.bonus.currency, + value: offerToUpdate.offersFullTime.bonus.value, }, where: { - id: offerToUpdate.OffersFullTime.bonus.id, + id: offerToUpdate.offersFullTime.bonus.id, }, }); } - if (offerToUpdate.OffersFullTime.stocks) { + if (offerToUpdate.offersFullTime.stocks) { await ctx.prisma.offersCurrency.update({ data: { - currency: offerToUpdate.OffersFullTime.stocks.currency, - value: offerToUpdate.OffersFullTime.stocks.value, + currency: offerToUpdate.offersFullTime.stocks.currency, + value: offerToUpdate.offersFullTime.stocks.value, }, where: { - id: offerToUpdate.OffersFullTime.stocks.id, + id: offerToUpdate.offersFullTime.stocks.id, }, }); } await ctx.prisma.offersCurrency.update({ data: { currency: - offerToUpdate.OffersFullTime.totalCompensation.currency, - value: offerToUpdate.OffersFullTime.totalCompensation.value, + offerToUpdate.offersFullTime.totalCompensation.currency, + value: offerToUpdate.offersFullTime.totalCompensation.value, }, where: { - id: offerToUpdate.OffersFullTime.totalCompensation.id, + id: offerToUpdate.offersFullTime.totalCompensation.id, }, }); } } else { if ( offerToUpdate.jobType === 'INTERN' && - offerToUpdate.OffersIntern && - offerToUpdate.OffersIntern.internshipCycle && - offerToUpdate.OffersIntern.monthlySalary?.currency && - offerToUpdate.OffersIntern.monthlySalary.value && - offerToUpdate.OffersIntern.startYear + offerToUpdate.offersIntern && + offerToUpdate.offersIntern.internshipCycle && + offerToUpdate.offersIntern.monthlySalary?.currency && + offerToUpdate.offersIntern.monthlySalary.value && + offerToUpdate.offersIntern.startYear ) { await ctx.prisma.offersProfile.update({ data: { offers: { create: { - OffersIntern: { + comments: offerToUpdate.comments, + company: { + connect: { + id: offerToUpdate.companyId, + }, + }, + jobType: offerToUpdate.jobType, + location: offerToUpdate.location, + monthYearReceived: offerToUpdate.monthYearReceived, + negotiationStrategy: offerToUpdate.negotiationStrategy, + offersIntern: { create: { internshipCycle: - offerToUpdate.OffersIntern.internshipCycle, + offerToUpdate.offersIntern.internshipCycle, monthlySalary: { create: { currency: - offerToUpdate.OffersIntern.monthlySalary + offerToUpdate.offersIntern.monthlySalary ?.currency, value: - offerToUpdate.OffersIntern.monthlySalary?.value, + offerToUpdate.offersIntern.monthlySalary?.value, }, }, specialization: - offerToUpdate.OffersIntern.specialization, - startYear: offerToUpdate.OffersIntern.startYear, - title: offerToUpdate.OffersIntern.title, - }, - }, - comments: offerToUpdate.comments, - company: { - connect: { - id: offerToUpdate.companyId, + offerToUpdate.offersIntern.specialization, + startYear: offerToUpdate.offersIntern.startYear, + title: offerToUpdate.offersIntern.title, }, }, - jobType: offerToUpdate.jobType, - location: offerToUpdate.location, - monthYearReceived: offerToUpdate.monthYearReceived, - negotiationStrategy: offerToUpdate.negotiationStrategy, }, }, }, @@ -944,72 +944,72 @@ export const offersProfileRouter = createRouter() } if ( offerToUpdate.jobType === 'FULLTIME' && - offerToUpdate.OffersFullTime && - offerToUpdate.OffersFullTime.baseSalary?.currency && - offerToUpdate.OffersFullTime.baseSalary?.value && - offerToUpdate.OffersFullTime.bonus?.currency && - offerToUpdate.OffersFullTime.bonus?.value && - offerToUpdate.OffersFullTime.stocks?.currency && - offerToUpdate.OffersFullTime.stocks?.value && - offerToUpdate.OffersFullTime.totalCompensation?.currency && - offerToUpdate.OffersFullTime.totalCompensation?.value && - offerToUpdate.OffersFullTime.level + offerToUpdate.offersFullTime && + offerToUpdate.offersFullTime.baseSalary?.currency && + offerToUpdate.offersFullTime.baseSalary?.value && + offerToUpdate.offersFullTime.bonus?.currency && + offerToUpdate.offersFullTime.bonus?.value && + offerToUpdate.offersFullTime.stocks?.currency && + offerToUpdate.offersFullTime.stocks?.value && + offerToUpdate.offersFullTime.totalCompensation?.currency && + offerToUpdate.offersFullTime.totalCompensation?.value && + offerToUpdate.offersFullTime.level ) { await ctx.prisma.offersProfile.update({ data: { offers: { create: { - OffersFullTime: { + comments: offerToUpdate.comments, + company: { + connect: { + id: offerToUpdate.companyId, + }, + }, + jobType: offerToUpdate.jobType, + location: offerToUpdate.location, + monthYearReceived: offerToUpdate.monthYearReceived, + negotiationStrategy: offerToUpdate.negotiationStrategy, + offersFullTime: { create: { baseSalary: { create: { currency: - offerToUpdate.OffersFullTime.baseSalary + offerToUpdate.offersFullTime.baseSalary ?.currency, value: - offerToUpdate.OffersFullTime.baseSalary?.value, + offerToUpdate.offersFullTime.baseSalary?.value, }, }, bonus: { create: { currency: - offerToUpdate.OffersFullTime.bonus?.currency, - value: offerToUpdate.OffersFullTime.bonus?.value, + offerToUpdate.offersFullTime.bonus?.currency, + value: offerToUpdate.offersFullTime.bonus?.value, }, }, - level: offerToUpdate.OffersFullTime.level, + level: offerToUpdate.offersFullTime.level, specialization: - offerToUpdate.OffersFullTime.specialization, + offerToUpdate.offersFullTime.specialization, stocks: { create: { currency: - offerToUpdate.OffersFullTime.stocks?.currency, - value: offerToUpdate.OffersFullTime.stocks?.value, + offerToUpdate.offersFullTime.stocks?.currency, + value: offerToUpdate.offersFullTime.stocks?.value, }, }, - title: offerToUpdate.OffersFullTime.title, + title: offerToUpdate.offersFullTime.title, totalCompensation: { create: { currency: - offerToUpdate.OffersFullTime.totalCompensation + offerToUpdate.offersFullTime.totalCompensation ?.currency, value: - offerToUpdate.OffersFullTime.totalCompensation + offerToUpdate.offersFullTime.totalCompensation ?.value, }, }, }, }, - comments: offerToUpdate.comments, - company: { - connect: { - id: offerToUpdate.companyId, - }, - }, - jobType: offerToUpdate.jobType, - location: offerToUpdate.location, - monthYearReceived: offerToUpdate.monthYearReceived, - negotiationStrategy: offerToUpdate.negotiationStrategy, }, }, }, @@ -1045,7 +1045,8 @@ export const offersProfileRouter = createRouter() }, offers: { include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { baseSalary: true, bonus: true, @@ -1053,12 +1054,11 @@ export const offersProfileRouter = createRouter() totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, }, }, }, diff --git a/apps/portal/src/server/router/offers/offers.ts b/apps/portal/src/server/router/offers/offers.ts index a35e2d2e..539085fd 100644 --- a/apps/portal/src/server/router/offers/offers.ts +++ b/apps/portal/src/server/router/offers/offers.ts @@ -60,7 +60,8 @@ export const offersRouter = createRouter().query('list', { ? await ctx.prisma.offersOffer.findMany({ // Internship include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { baseSalary: true, bonus: true, @@ -68,12 +69,11 @@ export const offersRouter = createRouter().query('list', { totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: true, @@ -86,12 +86,12 @@ export const offersRouter = createRouter().query('list', { location: input.location, }, { - OffersIntern: { + offersIntern: { isNot: null, }, }, { - OffersFullTime: { + offersFullTime: { is: null, }, }, @@ -101,7 +101,8 @@ export const offersRouter = createRouter().query('list', { : await ctx.prisma.offersOffer.findMany({ // Junior, Mid, Senior include: { - OffersFullTime: { + company: true, + offersFullTime: { include: { baseSalary: true, bonus: true, @@ -109,12 +110,11 @@ export const offersRouter = createRouter().query('list', { totalCompensation: true, }, }, - OffersIntern: { + offersIntern: { include: { monthlySalary: true, }, }, - company: true, profile: { include: { background: true, @@ -127,12 +127,12 @@ export const offersRouter = createRouter().query('list', { location: input.location, }, { - OffersIntern: { + offersIntern: { is: null, }, }, { - OffersFullTime: { + offersFullTime: { isNot: null, }, }, @@ -161,8 +161,8 @@ export const offersRouter = createRouter().query('list', { if (input.title) { validRecord = validRecord && - (offer.OffersFullTime?.title === input.title || - offer.OffersIntern?.title === input.title); + (offer.offersFullTime?.title === input.title || + offer.offersIntern?.title === input.title); } if (input.dateStart && input.dateEnd) { @@ -173,9 +173,9 @@ export const offersRouter = createRouter().query('list', { } if (input.salaryMin && input.salaryMax) { - const salary = offer.OffersFullTime?.totalCompensation.value - ? offer.OffersFullTime?.totalCompensation.value - : offer.OffersIntern?.monthlySalary.value; + const salary = offer.offersFullTime?.totalCompensation.value + ? offer.offersFullTime?.totalCompensation.value + : offer.offersIntern?.monthlySalary.value; if (!salary) { throw new TRPCError({ @@ -213,13 +213,13 @@ export const offersRouter = createRouter().query('list', { } if (sortingKey === 'totalCompensation') { - const salary1 = offer1.OffersFullTime?.totalCompensation.value - ? offer1.OffersFullTime?.totalCompensation.value - : offer1.OffersIntern?.monthlySalary.value; + const salary1 = offer1.offersFullTime?.totalCompensation.value + ? offer1.offersFullTime?.totalCompensation.value + : offer1.offersIntern?.monthlySalary.value; - const salary2 = offer2.OffersFullTime?.totalCompensation.value - ? offer2.OffersFullTime?.totalCompensation.value - : offer2.OffersIntern?.monthlySalary.value; + const salary2 = offer2.offersFullTime?.totalCompensation.value + ? offer2.offersFullTime?.totalCompensation.value + : offer2.offersIntern?.monthlySalary.value; if (!salary1 || !salary2) { throw new TRPCError({ @@ -259,13 +259,13 @@ export const offersRouter = createRouter().query('list', { } if (sortingKey === 'totalCompensation') { - const salary1 = offer1.OffersFullTime?.totalCompensation.value - ? offer1.OffersFullTime?.totalCompensation.value - : offer1.OffersIntern?.monthlySalary.value; + const salary1 = offer1.offersFullTime?.totalCompensation.value + ? offer1.offersFullTime?.totalCompensation.value + : offer1.offersIntern?.monthlySalary.value; - const salary2 = offer2.OffersFullTime?.totalCompensation.value - ? offer2.OffersFullTime?.totalCompensation.value - : offer2.OffersIntern?.monthlySalary.value; + const salary2 = offer2.offersFullTime?.totalCompensation.value + ? offer2.offersFullTime?.totalCompensation.value + : offer2.offersIntern?.monthlySalary.value; if (!salary1 || !salary2) { throw new TRPCError({