diff --git a/apps/portal/src/components/resumes/shared/ResumeLocationTypeahead.tsx b/apps/portal/src/components/resumes/shared/ResumeLocationTypeahead.tsx new file mode 100644 index 00000000..8464a8dc --- /dev/null +++ b/apps/portal/src/components/resumes/shared/ResumeLocationTypeahead.tsx @@ -0,0 +1,57 @@ +import type { ComponentProps } from 'react'; +import { useState } from 'react'; +import type { TypeaheadOption } from '@tih/ui'; +import { Typeahead } from '@tih/ui'; + +import { trpc } from '~/utils/trpc'; + +type BaseProps = Pick< + ComponentProps, + | 'disabled' + | 'errorMessage' + | 'isLabelHidden' + | 'placeholder' + | 'required' + | 'textSize' +>; + +type Props = BaseProps & + Readonly<{ + onSelect: (option: TypeaheadOption | null) => void; + value?: TypeaheadOption | null; + }>; + +export default function ResumeLocationTypeahead({ + onSelect, + value, + ...props +}: Props) { + const [query, setQuery] = useState(''); + const countries = trpc.useQuery([ + 'locations.countries.list', + { + name: query, + }, + ]); + + const { data } = countries; + + return ( + ({ + id, + label: name, + value: id, + })) ?? [] + } + value={value} + onQueryChange={setQuery} + onSelect={onSelect} + {...props} + /> + ); +} diff --git a/apps/portal/src/components/resumes/shared/ResumeRoleTypeahead.tsx b/apps/portal/src/components/resumes/shared/ResumeRoleTypeahead.tsx new file mode 100644 index 00000000..47ebb8a9 --- /dev/null +++ b/apps/portal/src/components/resumes/shared/ResumeRoleTypeahead.tsx @@ -0,0 +1,53 @@ +import type { ComponentProps } from 'react'; +import { useState } from 'react'; +import type { TypeaheadOption } from '@tih/ui'; +import { Typeahead } from '@tih/ui'; + +import { JobTitleLabels } from '../../shared/JobTitles'; + +type BaseProps = Pick< + ComponentProps, + | 'disabled' + | 'errorMessage' + | 'isLabelHidden' + | 'placeholder' + | 'required' + | 'textSize' +>; + +type Props = BaseProps & + Readonly<{ + onSelect: (option: TypeaheadOption | null) => void; + value?: TypeaheadOption | null; + }>; + +export default function ResumeRoleTypeahead({ + onSelect, + value, + ...props +}: Props) { + const [query, setQuery] = useState(''); + const options = Object.entries(JobTitleLabels) + .map(([slug, label]) => ({ + id: slug, + label, + value: slug, + })) + .filter( + ({ label }) => + label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) > -1, + ); + + return ( + + ); +}