diff --git a/src/apps/onboarding/src/components/modal-add-work/index.tsx b/src/apps/onboarding/src/components/modal-add-work/index.tsx index dea6de722..6e64d4cf2 100644 --- a/src/apps/onboarding/src/components/modal-add-work/index.tsx +++ b/src/apps/onboarding/src/components/modal-add-work/index.tsx @@ -32,6 +32,7 @@ const ModalAddWork: FC = (props: ModalAddWorkProps) => { const [formErrors, setFormErrors] = useState({ companyName: undefined, endDate: undefined, + otherIndustry: undefined, position: undefined, startDate: undefined, }) @@ -64,6 +65,10 @@ const ModalAddWork: FC = (props: ModalAddWorkProps) => { errorTmp.endDate = 'Required' } + if (workInfo.industry === 'Other' && !workInfo.otherIndustry?.trim()) { + errorTmp.otherIndustry = 'Please specify your industry' + } + setFormErrors(errorTmp) return _.isEmpty(errorTmp) } @@ -164,6 +169,7 @@ const ModalAddWork: FC = (props: ModalAddWorkProps) => { setWorkInfo({ ...workInfo, industry: event.target.value, + otherIndustry: event.target.value === 'Other' ? workInfo.otherIndustry : undefined, }) }} name='industry' @@ -172,6 +178,27 @@ const ModalAddWork: FC = (props: ModalAddWorkProps) => { dirty /> + {workInfo.industry === 'Other' && ( +
+ +
+ )}
WorkInfo = () => ({ endDate: undefined, id: 0, industry: '', + otherIndustry: '', position: '', startDate: undefined, }) diff --git a/src/apps/profiles/src/member-profile/work-expirence/ModifyWorkExpirenceModal/ModifyWorkExpirenceModal.tsx b/src/apps/profiles/src/member-profile/work-expirence/ModifyWorkExpirenceModal/ModifyWorkExpirenceModal.tsx index be3f71c74..2b32f40b6 100644 --- a/src/apps/profiles/src/member-profile/work-expirence/ModifyWorkExpirenceModal/ModifyWorkExpirenceModal.tsx +++ b/src/apps/profiles/src/member-profile/work-expirence/ModifyWorkExpirenceModal/ModifyWorkExpirenceModal.tsx @@ -194,6 +194,13 @@ const ModifyWorkExpirenceModal: FC = (props: Modi case 'startDate': case 'endDate': value = event as unknown as Date + break + case 'industry': + value = event.target.value + if (value !== 'Other') { + oldFormValues.otherIndustry = undefined + } + break default: value = event.target.value @@ -272,6 +279,13 @@ const ModifyWorkExpirenceModal: FC = (props: Modi } } + if (formValues.industry === 'Other' && !trim(formValues.otherIndustry as string)) { + setFormErrors({ + otherIndustry: 'Please specify your industry', + }) + return + } + const companyName: string | undefined = formValues.company as string | undefined const startDateIso: string | undefined = formValues.startDate ? (formValues.startDate as Date).toISOString() @@ -287,6 +301,7 @@ const ModifyWorkExpirenceModal: FC = (props: Modi description: (formValues.description as string) || undefined, endDate: endDateIso, industry: formValues.industry, + otherIndustry: formValues.industry === 'Other' ? (formValues.otherIndustry as string) : undefined, position: formValues.position, startDate: startDateIso, timePeriodFrom: startDateIso, @@ -343,6 +358,7 @@ const ModifyWorkExpirenceModal: FC = (props: Modi ? new Date(work.timePeriodTo) : (work.endDate ? new Date(work.endDate) : undefined), industry: work.industry || '', + otherIndustry: work.otherIndustry || '', position: (work.position || '') as string, startDate: work.timePeriodFrom ? new Date(work.timePeriodFrom) @@ -483,6 +499,21 @@ const ModifyWorkExpirenceModal: FC = (props: Modi dirty error={formErrors.industry} /> + {formValues.industry === 'Other' && ( + + )}
= (props: WorkExpirenceCardP {position || ''} { position && industry - ? `, ${getIndustryOptionLabel(industry)}` - : (industry ? getIndustryOptionLabel(industry) : '') + ? `, ${industry === 'Other' + && props.work.otherIndustry + ? props.work.otherIndustry + : getIndustryOptionLabel(industry)}` + : (industry + ? (industry === 'Other' + && props.work.otherIndustry + ? props.work.otherIndustry + : getIndustryOptionLabel(industry)) + : '' + ) }

)} diff --git a/src/libs/shared/lib/constants/index.ts b/src/libs/shared/lib/constants/index.ts index 5e34190ad..270aaf371 100644 --- a/src/libs/shared/lib/constants/index.ts +++ b/src/libs/shared/lib/constants/index.ts @@ -9,4 +9,5 @@ export const INDUSTRIES_OPTIONS: string[] = [ 'Telecoms', 'Public sector', 'Travel & hospitality', + 'Others', ] diff --git a/src/libs/shared/lib/utils/industry.ts b/src/libs/shared/lib/utils/industry.ts index edd716b36..82f3fc9d8 100644 --- a/src/libs/shared/lib/utils/industry.ts +++ b/src/libs/shared/lib/utils/industry.ts @@ -2,6 +2,7 @@ export const IndustryEnumToLabel: { [key: string]: string } = { ConsumerGoods: 'Consumer goods', + Other: 'Others', PublicSector: 'Public sector', TechAndTechnologyService: 'Tech & technology services', TravelAndHospitality: 'Travel & hospitality', @@ -11,6 +12,7 @@ export const IndustryLabelToEnum: { [key: string]: string } = { 'Consumer goods': 'ConsumerGoods', + Others: 'Other', 'Public sector': 'PublicSector', 'Tech & technology services': 'TechAndTechnologyService', 'Travel & hospitality': 'TravelAndHospitality', @@ -24,7 +26,7 @@ export const getIndustryOptionValue = (v: string): string => { } if (keys.includes(v)) { - return IndustryEnumToLabel[v] + return v } return v