-
Notifications
You must be signed in to change notification settings - Fork 21
feat(PM-3563): added other industry to work experience form #1421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ const ModalAddWork: FC<ModalAddWorkProps> = (props: ModalAddWorkProps) => { | |
| const [formErrors, setFormErrors] = useState<any>({ | ||
| companyName: undefined, | ||
| endDate: undefined, | ||
| otherIndustry: undefined, | ||
| position: undefined, | ||
| startDate: undefined, | ||
| }) | ||
|
|
@@ -64,6 +65,10 @@ const ModalAddWork: FC<ModalAddWorkProps> = (props: ModalAddWorkProps) => { | |
| errorTmp.endDate = 'Required' | ||
| } | ||
|
|
||
| if (workInfo.industry === 'Other' && !workInfo.otherIndustry?.trim()) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
| errorTmp.otherIndustry = 'Please specify your industry' | ||
| } | ||
|
|
||
| setFormErrors(errorTmp) | ||
| return _.isEmpty(errorTmp) | ||
| } | ||
|
|
@@ -164,6 +169,7 @@ const ModalAddWork: FC<ModalAddWorkProps> = (props: ModalAddWorkProps) => { | |
| setWorkInfo({ | ||
| ...workInfo, | ||
| industry: event.target.value, | ||
| otherIndustry: event.target.value === 'Other' ? workInfo.otherIndustry : undefined, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| }) | ||
| }} | ||
| name='industry' | ||
|
|
@@ -172,6 +178,27 @@ const ModalAddWork: FC<ModalAddWorkProps> = (props: ModalAddWorkProps) => { | |
| dirty | ||
| /> | ||
| </div> | ||
| {workInfo.industry === 'Other' && ( | ||
| <div className='full-width'> | ||
| <InputText | ||
| name='otherIndustry' | ||
| label='Please specify your industry *' | ||
| value={workInfo.otherIndustry || ''} | ||
| onChange={function onChange(event: any) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [💡 |
||
| setWorkInfo({ | ||
| ...workInfo, | ||
| otherIndustry: event.target.value, | ||
| }) | ||
| }} | ||
| placeholder='Enter your industry' | ||
| tabIndex={0} | ||
| type='text' | ||
| dirty | ||
| error={formErrors.otherIndustry} | ||
| maxLength={255} | ||
| /> | ||
| </div> | ||
| )} | ||
| <div className='d-flex gap-16 full-width flex-wrap'> | ||
| <div | ||
| className='flex-1' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -194,6 +194,13 @@ const ModifyWorkExpirenceModal: FC<ModifyWorkExpirenceModalProps> = (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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [💡 |
||
| } | ||
|
|
||
| break | ||
| default: | ||
| value = event.target.value | ||
|
|
@@ -272,6 +279,13 @@ const ModifyWorkExpirenceModal: FC<ModifyWorkExpirenceModalProps> = (props: Modi | |
| } | ||
| } | ||
|
|
||
| if (formValues.industry === 'Other' && !trim(formValues.otherIndustry as string)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| 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<ModifyWorkExpirenceModalProps> = (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<ModifyWorkExpirenceModalProps> = (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<ModifyWorkExpirenceModalProps> = (props: Modi | |
| dirty | ||
| error={formErrors.industry} | ||
| /> | ||
| {formValues.industry === 'Other' && ( | ||
| <InputText | ||
| name='otherIndustry' | ||
| label='Please specify your industry *' | ||
| error={formErrors.otherIndustry} | ||
| placeholder='Enter your industry' | ||
| dirty | ||
| tabIndex={0} | ||
| forceUpdateValue | ||
| type='text' | ||
| onChange={bind(handleFormValueChange, this, 'otherIndustry')} | ||
| value={formValues.otherIndustry as string} | ||
| maxLength={255} | ||
| /> | ||
| )} | ||
| <div className={styles.row}> | ||
| <InputDatePicker | ||
| label='Start Date' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,8 +61,17 @@ const WorkExpirenceCard: FC<WorkExpirenceCardProps> = (props: WorkExpirenceCardP | |
| {position || ''} | ||
| { | ||
| position && industry | ||
| ? `, ${getIndustryOptionLabel(industry)}` | ||
| : (industry ? getIndustryOptionLabel(industry) : '') | ||
| ? `, ${industry === 'Other' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| && props.work.otherIndustry | ||
| ? props.work.otherIndustry | ||
| : getIndustryOptionLabel(industry)}` | ||
| : (industry | ||
| ? (industry === 'Other' | ||
| && props.work.otherIndustry | ||
| ? props.work.otherIndustry | ||
| : getIndustryOptionLabel(industry)) | ||
| : '' | ||
| ) | ||
| } | ||
| </p> | ||
| )} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,4 +9,5 @@ export const INDUSTRIES_OPTIONS: string[] = [ | |
| 'Telecoms', | ||
| 'Public sector', | ||
| 'Travel & hospitality', | ||
| 'Others', | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
| } | ||
|
|
||
| return v | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[⚠️
maintainability]Consider using a more specific type instead of
anyforformErrorsto improve type safety and maintainability.