[offers][fix] Added more robust checks to distinguish full time and interns

pull/500/head
Bryann Yeap Kok Keong 2 years ago
parent d708b42970
commit 4b327b5132

@ -96,7 +96,10 @@ const analysisOfferDtoMapper = (
totalYoe: background?.totalYoe ?? -1, totalYoe: background?.totalYoe ?? -1,
}; };
if (offer.offersFullTime?.totalCompensation) { if (
offer.offersFullTime?.totalCompensation &&
offer.jobType === JobType.FULLTIME
) {
analysisOfferDto.income.value = analysisOfferDto.income.value =
offer.offersFullTime.totalCompensation.value; offer.offersFullTime.totalCompensation.value;
analysisOfferDto.income.currency = analysisOfferDto.income.currency =
@ -106,7 +109,10 @@ const analysisOfferDtoMapper = (
offer.offersFullTime.totalCompensation.baseValue; offer.offersFullTime.totalCompensation.baseValue;
analysisOfferDto.income.baseCurrency = analysisOfferDto.income.baseCurrency =
offer.offersFullTime.totalCompensation.baseCurrency; offer.offersFullTime.totalCompensation.baseCurrency;
} else if (offer.offersIntern?.monthlySalary) { } else if (
offer.offersIntern?.monthlySalary &&
offer.jobType === JobType.INTERN
) {
analysisOfferDto.income.value = offer.offersIntern.monthlySalary.value; analysisOfferDto.income.value = offer.offersIntern.monthlySalary.value;
analysisOfferDto.income.currency = analysisOfferDto.income.currency =
offer.offersIntern.monthlySalary.currency; offer.offersIntern.monthlySalary.currency;
@ -370,13 +376,15 @@ export const experienceDtoMapper = (
experience.location != null experience.location != null
? locationDtoMapper(experience.location) ? locationDtoMapper(experience.location)
: null, : null,
monthlySalary: experience.monthlySalary monthlySalary:
? valuationDtoMapper(experience.monthlySalary) experience.monthlySalary && experience.jobType === JobType.INTERN
: null, ? valuationDtoMapper(experience.monthlySalary)
: null,
title: experience.title, title: experience.title,
totalCompensation: experience.totalCompensation totalCompensation:
? valuationDtoMapper(experience.totalCompensation) experience.totalCompensation && experience.jobType === JobType.FULLTIME
: null, ? valuationDtoMapper(experience.totalCompensation)
: null,
}; };
return experienceDto; return experienceDto;
}; };
@ -702,7 +710,7 @@ export const dashboardOfferDtoMapper = (
totalYoe: offer.profile.background?.totalYoe ?? -1, totalYoe: offer.profile.background?.totalYoe ?? -1,
}; };
if (offer.offersFullTime) { if (offer.offersFullTime && offer.jobType === JobType.FULLTIME) {
dashboardOfferDto.income = valuationDtoMapper( dashboardOfferDto.income = valuationDtoMapper(
offer.offersFullTime.totalCompensation, offer.offersFullTime.totalCompensation,
); );
@ -722,7 +730,7 @@ export const dashboardOfferDtoMapper = (
offer.offersFullTime.stocks, offer.offersFullTime.stocks,
); );
} }
} else if (offer.offersIntern) { } else if (offer.offersIntern && offer.jobType === JobType.INTERN) {
dashboardOfferDto.income = valuationDtoMapper( dashboardOfferDto.income = valuationDtoMapper(
offer.offersIntern.monthlySalary, offer.offersIntern.monthlySalary,
); );
@ -815,7 +823,10 @@ const userProfileOfferDtoMapper = (
: offer.offersIntern?.title ?? '', : offer.offersIntern?.title ?? '',
}; };
if (offer.offersFullTime?.totalCompensation) { if (
offer.offersFullTime?.totalCompensation &&
offer.jobType === JobType.FULLTIME
) {
mappedOffer.income.value = offer.offersFullTime.totalCompensation.value; mappedOffer.income.value = offer.offersFullTime.totalCompensation.value;
mappedOffer.income.currency = mappedOffer.income.currency =
offer.offersFullTime.totalCompensation.currency; offer.offersFullTime.totalCompensation.currency;
@ -824,7 +835,10 @@ const userProfileOfferDtoMapper = (
offer.offersFullTime.totalCompensation.baseValue; offer.offersFullTime.totalCompensation.baseValue;
mappedOffer.income.baseCurrency = mappedOffer.income.baseCurrency =
offer.offersFullTime.totalCompensation.baseCurrency; offer.offersFullTime.totalCompensation.baseCurrency;
} else if (offer.offersIntern?.monthlySalary) { } else if (
offer.offersIntern?.monthlySalary &&
offer.jobType === JobType.INTERN
) {
mappedOffer.income.value = offer.offersIntern.monthlySalary.value; mappedOffer.income.value = offer.offersIntern.monthlySalary.value;
mappedOffer.income.currency = offer.offersIntern.monthlySalary.currency; mappedOffer.income.currency = offer.offersIntern.monthlySalary.currency;
mappedOffer.income.id = offer.offersIntern.monthlySalary.id; mappedOffer.income.id = offer.offersIntern.monthlySalary.id;

Loading…
Cancel
Save