From 7b960a0b87c6f82a247697fa96872e9174d14c71 Mon Sep 17 00:00:00 2001 From: Bryann Yeap Kok Keong Date: Mon, 31 Oct 2022 14:09:57 +0800 Subject: [PATCH] [offers][chore] Change location in schema --- apps/portal/prisma/schema.prisma | 8 +- .../router/offers/offers-profile-router.ts | 73 +++++++++++++++++-- 2 files changed, 74 insertions(+), 7 deletions(-) diff --git a/apps/portal/prisma/schema.prisma b/apps/portal/prisma/schema.prisma index b2820c3c..b6873fde 100644 --- a/apps/portal/prisma/schema.prisma +++ b/apps/portal/prisma/schema.prisma @@ -131,6 +131,8 @@ model City { stateId String state State @relation(fields: [stateId], references: [id]) questionsQuestionEncounters QuestionsQuestionEncounter[] + OffersExperience OffersExperience[] + OffersOffer OffersOffer[] @@unique([name, stateId]) } @@ -265,7 +267,8 @@ model OffersExperience { // Add more fields durationInMonths Int? - location String? + location City? @relation(fields: [cityId], references: [id]) + cityId String? // FULLTIME fields level String? @@ -348,8 +351,9 @@ model OffersOffer { company Company @relation(fields: [companyId], references: [id]) companyId String + location City @relation(fields: [cityId], references: [id]) + cityId String monthYearReceived DateTime - location String negotiationStrategy String comments String 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 48c8fb74..7e4ed3c5 100644 --- a/apps/portal/src/server/router/offers/offers-profile-router.ts +++ b/apps/portal/src/server/router/offers/offers-profile-router.ts @@ -110,12 +110,12 @@ export const offersProfileRouter = createRouter() async resolve({ ctx, input }) { const profile = await ctx.prisma.offersProfile.findFirst({ where: { - id: input.profileId - } - }) + id: input.profileId, + }, + }); - return profile?.editToken === input.token - } + return profile?.editToken === input.token; + }, }) .query('listOne', { input: z.object({ @@ -133,6 +133,15 @@ export const offersProfileRouter = createRouter() topSimilarOffers: { include: { company: true, + location: { + include: { + state: { + include: { + country: true, + }, + }, + }, + }, offersFullTime: { include: { totalCompensation: true, @@ -150,6 +159,15 @@ export const offersProfileRouter = createRouter() experiences: { include: { company: true, + location: { + include: { + state: { + include: { + country: true, + }, + }, + }, + }, }, }, }, @@ -165,6 +183,15 @@ export const offersProfileRouter = createRouter() topSimilarOffers: { include: { company: true, + location: { + include: { + state: { + include: { + country: true, + }, + }, + }, + }, offersFullTime: { include: { totalCompensation: true, @@ -182,6 +209,15 @@ export const offersProfileRouter = createRouter() experiences: { include: { company: true, + location: { + include: { + state: { + include: { + country: true, + }, + }, + }, + }, }, }, }, @@ -195,6 +231,15 @@ export const offersProfileRouter = createRouter() overallHighestOffer: { include: { company: true, + location: { + include: { + state: { + include: { + country: true, + }, + }, + }, + }, offersFullTime: { include: { totalCompensation: true, @@ -220,6 +265,15 @@ export const offersProfileRouter = createRouter() experiences: { include: { company: true, + location: { + include: { + state: { + include: { + country: true, + }, + }, + }, + }, monthlySalary: true, totalCompensation: true, }, @@ -237,6 +291,15 @@ export const offersProfileRouter = createRouter() offers: { include: { company: true, + location: { + include: { + state: { + include: { + country: true, + }, + }, + }, + }, offersFullTime: { include: { baseSalary: true,