[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"> <div className="flex flex-row">
<BuildingOffice2Icon className="mr-2.5 h-5" /> <BuildingOffice2Icon className="mr-2.5 h-5" />
<span className="mr-2 font-bold">Current:</span> <span className="mr-2 font-bold">Current:</span>
<span>{`${background?.experiences[0].companyName ?? '-'} ${ <span>
background?.experiences[0].jobLevel {`${background?.experiences[0]?.companyName ?? '-'} ${
} ${background?.experiences[0].jobTitle}`}</span> background?.experiences[0]?.jobLevel || ''
} ${background?.experiences[0]?.jobTitle || ''}`}
</span>
</div> </div>
<div className="flex flex-row"> <div className="flex flex-row">
<CalendarDaysIcon className="mr-2.5 h-5" /> <CalendarDaysIcon className="mr-2.5 h-5" />

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

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

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

Loading…
Cancel
Save