[offers][fix] Fix profile view page

pull/403/head
Ai Ling 3 years ago
parent fc06de187c
commit 1bbb91e3c9

@ -119,9 +119,11 @@ export default function ProfileHeader({
<div className="flex flex-row">
<BuildingOffice2Icon className="mr-2.5 h-5" />
<span className="mr-2 font-bold">Current:</span>
<span>{`${background?.experiences[0].companyName ?? '-'} ${
background?.experiences[0].jobLevel
} ${background?.experiences[0].jobTitle}`}</span>
<span>
{`${background?.experiences[0]?.companyName ?? '-'} ${
background?.experiences[0]?.jobLevel || ''
} ${background?.experiences[0]?.jobTitle || ''}`}
</span>
</div>
<div className="flex flex-row">
<CalendarDaysIcon className="mr-2.5 h-5" />

@ -1,6 +1,6 @@
import Link from 'next/link';
import { convertCurrencyToString } from '~/utils/offers/currency';
import { convertMoneyToString } from '~/utils/offers/currency';
import { formatDate } from '~/utils/offers/time';
import type { DashboardOffer } from '~/types/offers';
@ -21,7 +21,7 @@ export default function OfferTableRow({
</th>
<td className="py-4 px-6">{title}</td>
<td className="py-4 px-6">{totalYoe}</td>
<td className="py-4 px-6">{convertCurrencyToString(income)}</td>
<td className="py-4 px-6">{convertMoneyToString(income)}</td>
<td className="py-4 px-6">{formatDate(monthYearReceived)}</td>
<td className="space-x-4 py-4 px-6">
<Link

@ -7,7 +7,7 @@ import ProfileDetails from '~/components/offers/profile/ProfileDetails';
import ProfileHeader from '~/components/offers/profile/ProfileHeader';
import type { BackgroundCard, OfferEntity } from '~/components/offers/types';
import { convertCurrencyToString } from '~/utils/offers/currency';
import { convertMoneyToString } from '~/utils/offers/currency';
import { getProfilePath } from '~/utils/offers/link';
import { formatDate } from '~/utils/offers/time';
import { trpc } from '~/utils/trpc';
@ -49,10 +49,8 @@ export default function OfferProfile() {
? data?.offers.map((res: ProfileOffer) => {
if (res.offersFullTime) {
const filteredOffer: OfferEntity = {
base: convertCurrencyToString(
res.offersFullTime.baseSalary,
),
bonus: convertCurrencyToString(res.offersFullTime.bonus),
base: convertMoneyToString(res.offersFullTime.baseSalary),
bonus: convertMoneyToString(res.offersFullTime.bonus),
companyName: res.company.name,
id: res.offersFullTime.id,
jobLevel: res.offersFullTime.level,
@ -61,12 +59,11 @@ export default function OfferProfile() {
negotiationStrategy: res.negotiationStrategy || '',
otherComment: res.comments || '',
receivedMonth: formatDate(res.monthYearReceived),
stocks: convertCurrencyToString(res.offersFullTime.stocks),
totalCompensation: convertCurrencyToString(
stocks: convertMoneyToString(res.offersFullTime.stocks),
totalCompensation: convertMoneyToString(
res.offersFullTime.totalCompensation,
),
};
return filteredOffer;
}
const filteredOffer: OfferEntity = {
@ -74,7 +71,7 @@ export default function OfferProfile() {
id: res.offersIntern!.id,
jobTitle: res.offersIntern!.title,
location: res.location,
monthlySalary: convertCurrencyToString(
monthlySalary: convertMoneyToString(
res.offersIntern!.monthlySalary,
),
negotiationStrategy: res.negotiationStrategy || '',
@ -89,46 +86,29 @@ export default function OfferProfile() {
if (data?.background) {
const transformedBackground = {
educations: [
{
endDate: data?.background.educations[0].endDate
? formatDate(data.background.educations[0].endDate)
: '-',
field: data.background.educations[0].field || '-',
school: data.background.educations[0].school || '-',
startDate: data.background.educations[0].startDate
? formatDate(data.background.educations[0].startDate)
: '-',
type: data.background.educations[0].type || '-',
},
],
experiences: [
data.background.experiences &&
data.background.experiences.length > 0
? {
companyName:
data.background.experiences[0].company?.name ?? '-',
duration:
String(data.background.experiences[0].durationInMonths) ??
'-',
jobLevel: data.background.experiences[0].level ?? '',
jobTitle: data.background.experiences[0].title ?? '-',
monthlySalary: data.background.experiences[0].monthlySalary
? convertCurrencyToString(
data.background.experiences[0].monthlySalary,
)
: '-',
totalCompensation: data.background.experiences[0]
.totalCompensation
? convertCurrencyToString(
data.background.experiences[0].totalCompensation,
)
: '-',
}
: {},
],
educations: data.background.educations.map((education) => ({
endDate: education.endDate ? formatDate(education.endDate) : '-',
field: education.field || '-',
school: education.school || '-',
startDate: education.startDate
? formatDate(education.startDate)
: '-',
type: education.type || '-',
})),
experiences: data.background.experiences.map((experience) => ({
companyName: experience.company?.name ?? '-',
duration: String(experience.durationInMonths) ?? '-',
jobLevel: experience.level ?? '',
jobTitle: experience.title ?? '-',
monthlySalary: experience.monthlySalary
? convertMoneyToString(experience.monthlySalary)
: '-',
totalCompensation: experience.totalCompensation
? convertMoneyToString(experience.totalCompensation)
: '-',
})),
profileName: data.profileName,
specificYoes: data.background.specificYoes ?? [],
specificYoes: data.background.specificYoes,
totalYoe: String(data.background.totalYoe) || '-',
};
setBackground(transformedBackground);

@ -1,6 +1,6 @@
import type { Money } from '~/components/offers/types';
export function convertCurrencyToString({ currency, value }: Money) {
export function convertMoneyToString({ currency, value }: Money) {
if (!value) {
return '-';
}

Loading…
Cancel
Save