From 32302e33a53e90cddea2a083350d649eb51c040b Mon Sep 17 00:00:00 2001 From: Bryann Yeap Kok Keong Date: Fri, 4 Nov 2022 12:54:32 +0800 Subject: [PATCH] [offers][chore] Provide more information to frontend in AnalysisUnit --- apps/portal/src/mappers/offers-mappers.ts | 42 +++++++++++++++++++++-- apps/portal/src/types/offers.d.ts | 5 +++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/apps/portal/src/mappers/offers-mappers.ts b/apps/portal/src/mappers/offers-mappers.ts index b12eed1e..1d1d2f76 100644 --- a/apps/portal/src/mappers/offers-mappers.ts +++ b/apps/portal/src/mappers/offers-mappers.ts @@ -167,15 +167,51 @@ const analysisUnitDtoMapper = ( >; }, ) => { - const analysisDto: AnalysisUnit = { - companyName: analysisUnit.analysedOffer.company.name, + const { analysedOffer } = analysisUnit; + const { jobType } = analysedOffer; + + const analysisUnitDto: AnalysisUnit = { + companyId: analysedOffer.companyId, + companyName: analysedOffer.company.name, + income: valuationDtoMapper({ + baseCurrency: '', + baseValue: -1, + currency: '', + id: '', + value: -1, + }), + jobType, noOfOffers: analysisUnit.noOfSimilarOffers, percentile: analysisUnit.percentile, + title: + jobType === JobType.FULLTIME && analysedOffer.offersFullTime != null + ? analysedOffer.offersFullTime.title + : jobType === JobType.INTERN && analysedOffer.offersIntern != null + ? analysedOffer.offersIntern.title + : '', topPercentileOffers: analysisUnit.topSimilarOffers.map((offer) => analysisOfferDtoMapper(offer), ), + totalYoe: analysisUnit.analysedOffer.profile.background?.totalYoe ?? 0, }; - return analysisDto; + + if ( + analysedOffer.offersFullTime && + analysedOffer.jobType === JobType.FULLTIME + ) { + analysisUnitDto.income = valuationDtoMapper( + analysedOffer.offersFullTime.totalCompensation, + ); + } else if ( + analysedOffer.offersIntern && + analysedOffer.jobType === JobType.INTERN + ) { + analysisUnitDto.income = valuationDtoMapper( + analysedOffer.offersIntern.monthlySalary, + ); + } + + return analysisUnitDto; }; const analysisHighestOfferDtoMapper = ( diff --git a/apps/portal/src/types/offers.d.ts b/apps/portal/src/types/offers.d.ts index 559c9f31..534c8d5f 100644 --- a/apps/portal/src/types/offers.d.ts +++ b/apps/portal/src/types/offers.d.ts @@ -157,10 +157,15 @@ export type ProfileAnalysis = { }; export type AnalysisUnit = { + companyId: string; companyName: string; + income: Valuation; + jobType: JobType; noOfOffers: number; percentile: number; + title: string; topPercentileOffers: Array; + totalYoe: number; }; export type AnalysisHighestOffer = {