|
|
|
@ -33,8 +33,9 @@ import type {
|
|
|
|
|
ProfileAnalysis,
|
|
|
|
|
ProfileOffer,
|
|
|
|
|
SpecificYoe,
|
|
|
|
|
Valuation,
|
|
|
|
|
} from '~/types/offers';
|
|
|
|
|
UserProfile,
|
|
|
|
|
UserProfileOffer,
|
|
|
|
|
Valuation} from '~/types/offers';
|
|
|
|
|
|
|
|
|
|
const analysisOfferDtoMapper = (
|
|
|
|
|
offer: OffersOffer & {
|
|
|
|
@ -626,3 +627,84 @@ export const getOffersResponseMapper = (
|
|
|
|
|
};
|
|
|
|
|
return getOffersResponse;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getUserProfileResponeMapper = (res: User & {
|
|
|
|
|
OffersProfile: Array<OffersProfile & {
|
|
|
|
|
offers: Array<OffersOffer & {
|
|
|
|
|
company: Company;
|
|
|
|
|
offersFullTime: (OffersFullTime & { totalCompensation: OffersCurrency }) | null;
|
|
|
|
|
offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null;
|
|
|
|
|
}>;
|
|
|
|
|
}>;
|
|
|
|
|
} | null): Array<UserProfile> => {
|
|
|
|
|
if (res) {
|
|
|
|
|
return res.OffersProfile.map((profile) => {
|
|
|
|
|
return {
|
|
|
|
|
createdAt: profile.createdAt,
|
|
|
|
|
id: profile.id,
|
|
|
|
|
offers: profile.offers.map((offer) => {
|
|
|
|
|
return userProfileOfferDtoMapper(offer)
|
|
|
|
|
}),
|
|
|
|
|
profileName: profile.profileName,
|
|
|
|
|
token: profile.editToken
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const userProfileOfferDtoMapper = (
|
|
|
|
|
offer: OffersOffer & {
|
|
|
|
|
company: Company;
|
|
|
|
|
offersFullTime: (OffersFullTime & { totalCompensation: OffersCurrency }) | null;
|
|
|
|
|
offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null;
|
|
|
|
|
}): UserProfileOffer => {
|
|
|
|
|
const mappedOffer: UserProfileOffer = {
|
|
|
|
|
company: offersCompanyDtoMapper(offer.company),
|
|
|
|
|
id: offer.id,
|
|
|
|
|
income: {
|
|
|
|
|
baseCurrency: '',
|
|
|
|
|
baseValue: -1,
|
|
|
|
|
currency: '',
|
|
|
|
|
id: '',
|
|
|
|
|
value: -1,
|
|
|
|
|
},
|
|
|
|
|
jobType: offer.jobType,
|
|
|
|
|
level: offer.offersFullTime?.level ?? '',
|
|
|
|
|
location: offer.location,
|
|
|
|
|
monthYearReceived: offer.monthYearReceived,
|
|
|
|
|
title:
|
|
|
|
|
offer.jobType === JobType.FULLTIME
|
|
|
|
|
? offer.offersFullTime?.title ?? ''
|
|
|
|
|
: offer.offersIntern?.title ?? '',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (offer.offersFullTime?.totalCompensation) {
|
|
|
|
|
mappedOffer.income.value =
|
|
|
|
|
offer.offersFullTime.totalCompensation.value;
|
|
|
|
|
mappedOffer.income.currency =
|
|
|
|
|
offer.offersFullTime.totalCompensation.currency;
|
|
|
|
|
mappedOffer.income.id = offer.offersFullTime.totalCompensation.id;
|
|
|
|
|
mappedOffer.income.baseValue =
|
|
|
|
|
offer.offersFullTime.totalCompensation.baseValue;
|
|
|
|
|
mappedOffer.income.baseCurrency =
|
|
|
|
|
offer.offersFullTime.totalCompensation.baseCurrency;
|
|
|
|
|
} else if (offer.offersIntern?.monthlySalary) {
|
|
|
|
|
mappedOffer.income.value = offer.offersIntern.monthlySalary.value;
|
|
|
|
|
mappedOffer.income.currency =
|
|
|
|
|
offer.offersIntern.monthlySalary.currency;
|
|
|
|
|
mappedOffer.income.id = offer.offersIntern.monthlySalary.id;
|
|
|
|
|
mappedOffer.income.baseValue =
|
|
|
|
|
offer.offersIntern.monthlySalary.baseValue;
|
|
|
|
|
mappedOffer.income.baseCurrency =
|
|
|
|
|
offer.offersIntern.monthlySalary.baseCurrency;
|
|
|
|
|
} else {
|
|
|
|
|
throw new TRPCError({
|
|
|
|
|
code: 'NOT_FOUND',
|
|
|
|
|
message: 'Total Compensation or Salary not found',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return mappedOffer
|
|
|
|
|
}
|