Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/apps/onboarding/src/components/modal-add-work/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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<ModalAddWorkProps> = (props: ModalAddWorkProps) => {
const [workInfo, setWorkInfo] = useState(emptyWorkInfo())
Expand Down
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -13,8 +13,7 @@ import {
} from '~/libs/core'
import {
FieldHtmlEditor,
getIndustryOptionLabel,
getIndustryOptionValue,
getIndustryOptionsWithOthersLast,
INDUSTRIES_OPTIONS,
InputSkillSelector,
} from '~/libs/shared'
Expand Down Expand Up @@ -143,11 +142,7 @@ const ModifyWorkExpirenceModal: FC<ModifyWorkExpirenceModalProps> = (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) {
Expand Down
15 changes: 15 additions & 0 deletions src/libs/shared/lib/utils/industry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}))
}
Loading