From 0c9dfd7658df7b9e6e606f6c6a826156d8b94709 Mon Sep 17 00:00:00 2001 From: Stuart Long <77237808+s7u4rt99@users.noreply.github.com> Date: Thu, 3 Nov 2022 01:09:50 +0800 Subject: [PATCH] [offers][feat] return base bonus stocks for dashboard --- apps/portal/src/mappers/offers-mappers.ts | 23 ++++++++++++++++++- .../portal/src/server/router/offers/offers.ts | 2 ++ apps/portal/src/types/offers.d.ts | 4 ++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/apps/portal/src/mappers/offers-mappers.ts b/apps/portal/src/mappers/offers-mappers.ts index e0cea797..504e9400 100644 --- a/apps/portal/src/mappers/offers-mappers.ts +++ b/apps/portal/src/mappers/offers-mappers.ts @@ -700,6 +700,25 @@ export const dashboardOfferDtoMapper = ( dashboardOfferDto.income = valuationDtoMapper( offer.offersFullTime.totalCompensation, ); + + if (offer.offersFullTime.baseSalary) { + dashboardOfferDto.baseSalary = valuationDtoMapper( + offer.offersFullTime.baseSalary + ); + } + + if (offer.offersFullTime.bonus) { + dashboardOfferDto.bonus = valuationDtoMapper( + offer.offersFullTime.bonus + ); + + } + + if (offer.offersFullTime.stocks) { + dashboardOfferDto.stocks = valuationDtoMapper( + offer.offersFullTime.stocks + ); + } } else if (offer.offersIntern) { dashboardOfferDto.income = valuationDtoMapper( offer.offersIntern.monthlySalary, @@ -712,10 +731,12 @@ export const dashboardOfferDtoMapper = ( export const getOffersResponseMapper = ( data: Array, paging: Paging, + jobType: JobType ) => { const getOffersResponse: GetOffersResponse = { data, - paging, + jobType, + paging }; return getOffersResponse; }; diff --git a/apps/portal/src/server/router/offers/offers.ts b/apps/portal/src/server/router/offers/offers.ts index 490180f0..fbf958b4 100644 --- a/apps/portal/src/server/router/offers/offers.ts +++ b/apps/portal/src/server/router/offers/offers.ts @@ -1,4 +1,5 @@ import { z } from 'zod'; +import { JobType } from '@prisma/client'; import { TRPCError } from '@trpc/server'; import { @@ -393,6 +394,7 @@ export const offersRouter = createRouter().query('list', { numOfPages: Math.ceil(data.length / input.limit), totalItems: data.length, }, + !yoeRange ? JobType.INTERN : JobType.FULLTIME ); }, }); diff --git a/apps/portal/src/types/offers.d.ts b/apps/portal/src/types/offers.d.ts index 3dcba938..425d654d 100644 --- a/apps/portal/src/types/offers.d.ts +++ b/apps/portal/src/types/offers.d.ts @@ -65,11 +65,14 @@ export type SpecificYoe = { }; export type DashboardOffer = { + baseSalary?: Valuation; + bonus?: Valuation; company: OffersCompany; id: string; income: Valuation; monthYearReceived: Date; profileId: string; + stocks?: Valuation; title: string; totalYoe: number; }; @@ -123,6 +126,7 @@ export type User = { export type GetOffersResponse = { data: Array; + jobType: JobType; paging: Paging; };