mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-28 04:33:42 +08:00
Return currency with income in analysis top offers
This commit is contained in:
@ -14,6 +14,7 @@ import type {
|
|||||||
User,
|
User,
|
||||||
} from '@prisma/client';
|
} from '@prisma/client';
|
||||||
import { JobType } from '@prisma/client';
|
import { JobType } from '@prisma/client';
|
||||||
|
import { TRPCError } from '@trpc/server';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
AddToProfileResponse,
|
AddToProfileResponse,
|
||||||
@ -49,7 +50,7 @@ const analysisOfferDtoMapper = (
|
|||||||
const analysisOfferDto: AnalysisOffer = {
|
const analysisOfferDto: AnalysisOffer = {
|
||||||
company: offersCompanyDtoMapper(offer.company),
|
company: offersCompanyDtoMapper(offer.company),
|
||||||
id: offer.id,
|
id: offer.id,
|
||||||
income: -1,
|
income: { currency: '', value: -1 },
|
||||||
jobType: offer.jobType,
|
jobType: offer.jobType,
|
||||||
level: offer.offersFullTime?.level ?? '',
|
level: offer.offersFullTime?.level ?? '',
|
||||||
location: offer.location,
|
location: offer.location,
|
||||||
@ -69,9 +70,19 @@ const analysisOfferDtoMapper = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (offer.offersFullTime?.totalCompensation) {
|
if (offer.offersFullTime?.totalCompensation) {
|
||||||
analysisOfferDto.income = offer.offersFullTime.totalCompensation.value;
|
analysisOfferDto.income.value =
|
||||||
|
offer.offersFullTime.totalCompensation.value;
|
||||||
|
analysisOfferDto.income.currency =
|
||||||
|
offer.offersFullTime.totalCompensation.currency;
|
||||||
} else if (offer.offersIntern?.monthlySalary) {
|
} else if (offer.offersIntern?.monthlySalary) {
|
||||||
analysisOfferDto.income = offer.offersIntern.monthlySalary.value;
|
analysisOfferDto.income.value = offer.offersIntern.monthlySalary.value;
|
||||||
|
analysisOfferDto.income.currency =
|
||||||
|
offer.offersIntern.monthlySalary.currency;
|
||||||
|
} else {
|
||||||
|
throw new TRPCError({
|
||||||
|
code: 'NOT_FOUND',
|
||||||
|
message: 'Total Compensation or Salary not found',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return analysisOfferDto;
|
return analysisOfferDto;
|
||||||
|
@ -8,7 +8,7 @@ function GenerateAnalysis() {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{JSON.stringify(
|
{JSON.stringify(
|
||||||
analysisMutation.mutate({ profileId: 'cl9gvjn8b004di96vd1hhh9c4' }),
|
analysisMutation.mutate({ profileId: 'cl9h23fb1002ftxysli5iziu2' }),
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -5,7 +5,7 @@ import { trpc } from '~/utils/trpc';
|
|||||||
function GetAnalysis() {
|
function GetAnalysis() {
|
||||||
const analysis = trpc.useQuery([
|
const analysis = trpc.useQuery([
|
||||||
'offers.analysis.get',
|
'offers.analysis.get',
|
||||||
{ profileId: 'cl98ywtbv0000tx1s4p18eol1' },
|
{ profileId: 'cl9h23fb1002ftxysli5iziu2' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return <div>{JSON.stringify(analysis.data)}</div>;
|
return <div>{JSON.stringify(analysis.data)}</div>;
|
||||||
|
2
apps/portal/src/types/offers.d.ts
vendored
2
apps/portal/src/types/offers.d.ts
vendored
@ -167,7 +167,7 @@ export type AnalysisHighestOffer = {
|
|||||||
export type AnalysisOffer = {
|
export type AnalysisOffer = {
|
||||||
company: OffersCompany;
|
company: OffersCompany;
|
||||||
id: string;
|
id: string;
|
||||||
income: number;
|
income: Valuation;
|
||||||
jobType: JobType;
|
jobType: JobType;
|
||||||
level: string;
|
level: string;
|
||||||
location: string;
|
location: string;
|
||||||
|
Reference in New Issue
Block a user