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 6e64d4cf2..f90ca7086 100644 --- a/src/apps/onboarding/src/components/modal-add-work/index.tsx +++ b/src/apps/onboarding/src/components/modal-add-work/index.tsx @@ -4,7 +4,7 @@ import classNames from 'classnames' import moment from 'moment' import { Button, IconSolid, InputDatePicker, InputSelect, InputText, Tooltip } from '~/libs/ui' -import { getIndustryOptionLabel, getIndustryOptionValue, INDUSTRIES_OPTIONS } from '~/libs/shared' +import { getIndustryOptionsWithOthersLast, INDUSTRIES_OPTIONS } from '~/libs/shared' import FormInputCheckbox from '../form-input-checkbox' import OnboardingBaseModal from '../onboarding-base-modal' @@ -21,11 +21,7 @@ interface ModalAddWorkProps { onEdit?: (workInfo: WorkInfo) => void } -const industryOptions: any = _.sortBy(INDUSTRIES_OPTIONS) - .map(v => ({ - label: getIndustryOptionLabel(v), - value: getIndustryOptionValue(v), - })) +const industryOptions: any = getIndustryOptionsWithOthersLast(INDUSTRIES_OPTIONS) const ModalAddWork: FC = (props: ModalAddWorkProps) => { const [workInfo, setWorkInfo] = useState(emptyWorkInfo()) 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 2b32f40b6..519b6f616 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 @@ -1,6 +1,6 @@ /* eslint-disable complexity */ import { ChangeEvent, Dispatch, FC, MutableRefObject, SetStateAction, useEffect, useRef, useState } from 'react' -import { bind, sortBy, trim } from 'lodash' +import { bind, trim } from 'lodash' import { toast } from 'react-toastify' import classNames from 'classnames' @@ -13,8 +13,7 @@ import { } from '~/libs/core' import { FieldHtmlEditor, - getIndustryOptionLabel, - getIndustryOptionValue, + getIndustryOptionsWithOthersLast, INDUSTRIES_OPTIONS, InputSkillSelector, } from '~/libs/shared' @@ -143,11 +142,7 @@ const ModifyWorkExpirenceModal: FC = (props: Modi }) } - const industryOptions: any = sortBy(INDUSTRIES_OPTIONS) - .map(v => ({ - label: getIndustryOptionLabel(v), - value: getIndustryOptionValue(v), - })) + const industryOptions: any = getIndustryOptionsWithOthersLast(INDUSTRIES_OPTIONS) function handleModifyWorkExpirenceSave(): void { if (addingNewItem || editedItemIndex !== undefined) { diff --git a/src/libs/shared/lib/utils/industry.ts b/src/libs/shared/lib/utils/industry.ts index 82f3fc9d8..ae6f823c9 100644 --- a/src/libs/shared/lib/utils/industry.ts +++ b/src/libs/shared/lib/utils/industry.ts @@ -40,3 +40,18 @@ export const getIndustryOptionLabel = (v: string): string => { return v } + +export const getIndustryOptionsWithOthersLast = ( + industries: string[], +): Array<{ label: string; value: string }> => { + const industriesWithoutOthers = industries.filter(v => v !== 'Others') + const sortedIndustries = [...industriesWithoutOthers].sort() + + // Always append 'Others' at the end + const finalIndustries = [...sortedIndustries, 'Others'] + + return finalIndustries.map(v => ({ + label: getIndustryOptionLabel(v), + value: getIndustryOptionValue(v), + })) +}