diff --git a/apps/portal/src/components/resumes/shared/ResumeRoleTypeahead.tsx b/apps/portal/src/components/resumes/shared/ResumeRoleTypeahead.tsx deleted file mode 100644 index b5459200..00000000 --- a/apps/portal/src/components/resumes/shared/ResumeRoleTypeahead.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import type { ComponentProps } from 'react'; -import { useState } from 'react'; -import type { TypeaheadOption } from '@tih/ui'; -import { Typeahead } from '@tih/ui'; - -import { JobTitleLabels } from '~/components/shared/JobTitles'; - -type BaseProps = Pick< - ComponentProps, - | 'disabled' - | 'errorMessage' - | 'isLabelHidden' - | 'placeholder' - | 'required' - | 'textSize' ->; - -type Props = BaseProps & - Readonly<{ - onSelect: (option: TypeaheadOption | null) => void; - selectedValues?: Set; - value?: TypeaheadOption | null; - }>; - -export default function ResumeRoleTypeahead({ - onSelect, - selectedValues = new Set(), - value, - ...props -}: Props) { - const [query, setQuery] = useState(''); - const options = Object.entries(JobTitleLabels) - .map(([slug, { label }]) => ({ - id: slug, - label, - value: slug, - })) - .filter((option) => !selectedValues.has(option.value)) - .filter( - ({ label }) => - label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) > -1, - ); - - return ( - - ); -} diff --git a/apps/portal/src/components/shared/JobTitlesTypeahead.tsx b/apps/portal/src/components/shared/JobTitlesTypeahead.tsx index ab0b0404..9f560fce 100644 --- a/apps/portal/src/components/shared/JobTitlesTypeahead.tsx +++ b/apps/portal/src/components/shared/JobTitlesTypeahead.tsx @@ -17,11 +17,17 @@ type BaseProps = Pick< type Props = BaseProps & Readonly<{ + excludedValues?: Set; + label?: string; + noResultsMessage?: string; onSelect: (option: TypeaheadOption | null) => void; value?: TypeaheadOption | null; }>; export default function JobTitlesTypeahead({ + excludedValues, + label: labelProp = 'Job Title', + noResultsMessage = 'No available job titles.', onSelect, value, ...props @@ -34,15 +40,16 @@ export default function JobTitlesTypeahead({ ranking, value: slug, })) - .sort((a, b) => b.ranking - a.ranking) .filter(({ label }) => label.toLocaleLowerCase().includes(query.trim().toLocaleLowerCase()), - ); + ) + .filter((option) => !excludedValues?.has(option.value)) + .sort((a, b) => b.ranking - a.ranking); return ( value)) } + isLabelHidden={true} + label="Role" + noResultsMessage="No available roles." + placeholder="Select roles" onSelect={onSelect} /> ); diff --git a/apps/portal/src/pages/resumes/submit.tsx b/apps/portal/src/pages/resumes/submit.tsx index c6721931..802b0107 100644 --- a/apps/portal/src/pages/resumes/submit.tsx +++ b/apps/portal/src/pages/resumes/submit.tsx @@ -21,10 +21,10 @@ import { } from '@tih/ui'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; -import ResumeRoleTypeahead from '~/components/resumes/shared/ResumeRoleTypeahead'; import ResumeSubmissionGuidelines from '~/components/resumes/submit-form/ResumeSubmissionGuidelines'; import Container from '~/components/shared/Container'; import CountriesTypeahead from '~/components/shared/CountriesTypeahead'; +import JobTitlesTypeahead from '~/components/shared/JobTitlesTypeahead'; import loginPageHref from '~/components/shared/loginPageHref'; import { RESUME_STORAGE_KEY } from '~/constants/file-storage-keys'; @@ -333,8 +333,10 @@ export default function SubmitResumeForm({ control={control} name="role" render={({ field: { value } }) => ( -