diff --git a/apps/portal/src/components/offers/offerAnalysis/OfferProfileCard.tsx b/apps/portal/src/components/offers/offerAnalysis/OfferProfileCard.tsx index 5e6aa74b..4c7ecca3 100644 --- a/apps/portal/src/components/offers/offerAnalysis/OfferProfileCard.tsx +++ b/apps/portal/src/components/offers/offerAnalysis/OfferProfileCard.tsx @@ -9,6 +9,7 @@ import { getLabelForJobTitleType } from '~/components/shared/JobTitles'; import { HorizontalDivider } from '~/../../../packages/ui/dist'; import { convertMoneyToString } from '~/utils/offers/currency'; +import { getCompanyDisplayText } from '~/utils/offers/string'; import { formatDate } from '~/utils/offers/time'; import { JobTypeLabel } from '../constants'; @@ -69,7 +70,7 @@ export default function OfferProfileCard({ {getLabelForJobTitleType(title as JobTitleType)}{' '} {`(${JobTypeLabel[jobType]})`}

-

{`Company: ${company.name}, ${location}`}

+

{`Company: ${getCompanyDisplayText(company.name, location)}`}

{level &&

Level: {level}

}
diff --git a/apps/portal/src/components/offers/offersSubmission/OffersProfileSave.tsx b/apps/portal/src/components/offers/offersSubmission/OffersProfileSave.tsx index b72641d8..d494912e 100644 --- a/apps/portal/src/components/offers/offersSubmission/OffersProfileSave.tsx +++ b/apps/portal/src/components/offers/offersSubmission/OffersProfileSave.tsx @@ -93,7 +93,6 @@ export default function OffersProfileSave({
{steps[step]} -
{JSON.stringify(formMethods.watch(), null, 2)}
{step === 0 && (
)}
-

- {joinWithComma(jobTitle, jobLevel)}{' '} - {jobType && `(${JobTypeLabel[jobType]})`} -

+

{getJobDisplayText(jobTitle, jobLevel, jobType)}

{!duration && receivedMonth && ( diff --git a/apps/portal/src/utils/offers/string.tsx b/apps/portal/src/utils/offers/string.tsx index 603b934c..dbf7bd44 100644 --- a/apps/portal/src/utils/offers/string.tsx +++ b/apps/portal/src/utils/offers/string.tsx @@ -1,3 +1,37 @@ -export function joinWithComma(...strings: Array) { +import type { JobType } from '@prisma/client'; + +import { JobTypeLabel } from '~/components/offers/constants'; + +import type { Location } from '~/types/offers'; + +function joinWithComma(...strings: Array) { return strings.filter((value) => !!value).join(', '); } + +function getLocationDisplayText({ cityName, countryName }: Location) { + return cityName === countryName + ? cityName + : joinWithComma(cityName, countryName); +} + +export function getCompanyDisplayText( + companyName?: string | null, + location?: Location | null, +) { + if (!location) { + return companyName; + } + return joinWithComma(companyName, getLocationDisplayText(location)); +} + +export function getJobDisplayText( + jobTitle?: string | null, + jobLevel?: string | null, + jobType?: JobType | null, +) { + let jobDisplay = joinWithComma(jobTitle, jobLevel); + if (jobType) { + jobDisplay = jobDisplay.concat(` (${JobTypeLabel[jobType]})`); + } + return jobDisplay; +}