[offers][fix] display intern cycle in offer card (#547)

pull/549/head
Zhang Ziqing 2 years ago committed by GitHub
parent 3b965cc173
commit bd21b93df2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,3 +16,13 @@ export const InternshipCycleOptions = [emptyOption].concat(
value: label.replace(/\s+/g, '-').toLowerCase(), value: label.replace(/\s+/g, '-').toLowerCase(),
})), })),
); );
export const InternshipCycleValuesToLabels: Record<string, string> = {
fall: 'Fall',
'full-year': 'Full year',
'half-year': 'Half year',
others: 'Others',
spring: 'Spring',
summer: 'Summer',
winter: 'Winter',
};

@ -1,11 +1,13 @@
import { import {
ArrowTrendingUpIcon, ArrowTrendingUpIcon,
BuildingOfficeIcon, BuildingOfficeIcon,
CalendarIcon,
MapPinIcon, MapPinIcon,
} from '@heroicons/react/20/solid'; } from '@heroicons/react/20/solid';
import { JobType } from '@prisma/client'; import { JobType } from '@prisma/client';
import { JobTypeLabel } from '~/components/offers/constants'; import { JobTypeLabel } from '~/components/offers/constants';
import { InternshipCycleValuesToLabels } from '~/components/offers/InternshipCycles';
import type { OfferDisplayData } from '~/components/offers/types'; import type { OfferDisplayData } from '~/components/offers/types';
import { getLocationDisplayText } from '~/utils/offers/string'; import { getLocationDisplayText } from '~/utils/offers/string';
@ -21,12 +23,14 @@ export default function OfferCard({
bonus, bonus,
companyName, companyName,
duration, duration,
internshipCycle,
jobTitle, jobTitle,
jobLevel, jobLevel,
jobType, jobType,
location, location,
receivedMonth, receivedMonth,
totalCompensation, totalCompensation,
startYear,
stocks, stocks,
monthlySalary, monthlySalary,
negotiationStrategy, negotiationStrategy,
@ -41,9 +45,9 @@ export default function OfferCard({
<h3 className="text-lg font-medium leading-6 text-slate-900"> <h3 className="text-lg font-medium leading-6 text-slate-900">
{jobTitle} {jobType && <>({JobTypeLabel[jobType]})</>} {jobTitle} {jobType && <>({JobTypeLabel[jobType]})</>}
</h3> </h3>
<div className="mt-1 flex flex-row flex-wrap space-x-4 sm:mt-0"> <div className="mt-1 flex flex-row flex-wrap sm:mt-0">
{companyName && ( {companyName && (
<div className="mt-2 flex items-center text-sm text-slate-500"> <div className="mr-4 mt-2 flex items-center text-sm text-slate-500">
<BuildingOfficeIcon <BuildingOfficeIcon
aria-hidden="true" aria-hidden="true"
className="mr-1.5 h-5 w-5 flex-shrink-0 text-slate-400" className="mr-1.5 h-5 w-5 flex-shrink-0 text-slate-400"
@ -52,7 +56,7 @@ export default function OfferCard({
</div> </div>
)} )}
{location && ( {location && (
<div className="mt-2 flex items-center text-sm text-slate-500"> <div className="mr-4 mt-2 flex items-center text-sm text-slate-500">
<MapPinIcon <MapPinIcon
aria-hidden="true" aria-hidden="true"
className="mr-1.5 h-5 w-5 flex-shrink-0 text-slate-400" className="mr-1.5 h-5 w-5 flex-shrink-0 text-slate-400"
@ -60,6 +64,17 @@ export default function OfferCard({
{getLocationDisplayText(location)} {getLocationDisplayText(location)}
</div> </div>
)} )}
{(internshipCycle || startYear) && (
<div className="mt-2 flex items-center text-sm text-slate-500">
<CalendarIcon
aria-hidden="true"
className="mr-1.5 h-5 w-5 flex-shrink-0 text-slate-400"
/>
{internshipCycle && startYear
? `${startYear} ${InternshipCycleValuesToLabels[internshipCycle]}`
: internshipCycle || startYear}
</div>
)}
{jobLevel && ( {jobLevel && (
<div className="mt-2 flex items-center text-sm text-slate-500"> <div className="mt-2 flex items-center text-sm text-slate-500">
<ArrowTrendingUpIcon <ArrowTrendingUpIcon
@ -169,4 +184,4 @@ export default function OfferCard({
<BottomSection /> <BottomSection />
</div> </div>
); );
} }

@ -180,6 +180,7 @@ export type OfferDisplayData = {
companyName?: string | null; companyName?: string | null;
duration?: number | null; duration?: number | null;
id?: string; id?: string;
internshipCycle?: string;
jobLevel?: string | null; jobLevel?: string | null;
jobTitle?: string | null; jobTitle?: string | null;
jobType?: JobType; jobType?: JobType;
@ -188,6 +189,7 @@ export type OfferDisplayData = {
negotiationStrategy?: string | null; negotiationStrategy?: string | null;
otherComment?: string | null; otherComment?: string | null;
receivedMonth?: string | null; receivedMonth?: string | null;
startYear?: number;
stocks?: string | null; stocks?: string | null;
totalCompensation?: string | null; totalCompensation?: string | null;
}; };
@ -209,4 +211,4 @@ export type CommentEntity = {
replyingToId: string; replyingToId: string;
userId: string; userId: string;
username: string; username: string;
}; };

@ -98,6 +98,7 @@ export default function OfferProfile() {
const filteredOffer: OfferDisplayData = { const filteredOffer: OfferDisplayData = {
companyName: res.company.name, companyName: res.company.name,
id: res.offersIntern!.id, id: res.offersIntern!.id,
internshipCycle: res.offersIntern!.internshipCycle,
jobTitle: getLabelForJobTitleType( jobTitle: getLabelForJobTitleType(
res.offersIntern!.title as JobTitleType, res.offersIntern!.title as JobTitleType,
), ),
@ -109,6 +110,7 @@ export default function OfferProfile() {
negotiationStrategy: res.negotiationStrategy, negotiationStrategy: res.negotiationStrategy,
otherComment: res.comments, otherComment: res.comments,
receivedMonth: formatDate(res.monthYearReceived), receivedMonth: formatDate(res.monthYearReceived),
startYear: res.offersIntern!.startYear,
}; };
return filteredOffer; return filteredOffer;
}) })

Loading…
Cancel
Save