|
|
|
@ -22,6 +22,7 @@ type Props = BaseProps &
|
|
|
|
|
value?: TypeaheadOption | null;
|
|
|
|
|
}>;
|
|
|
|
|
|
|
|
|
|
// TODO: Merge with CountriesTypeahead instead.
|
|
|
|
|
export default function ResumeLocationTypeahead({
|
|
|
|
|
onSelect,
|
|
|
|
|
selectedValues = new Set(),
|
|
|
|
@ -42,18 +43,24 @@ export default function ResumeLocationTypeahead({
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
.map(({ id, name }) => ({
|
|
|
|
|
id,
|
|
|
|
|
label: name,
|
|
|
|
|
value: id,
|
|
|
|
|
}))
|
|
|
|
|
.filter((option) => !selectedValues.has(option.value));
|
|
|
|
|
}, [countries, selectedValues]);
|
|
|
|
|
return (
|
|
|
|
|
data
|
|
|
|
|
// Client-side sorting by position of query string appearing
|
|
|
|
|
// in the country name since we can't do that in Prisma.
|
|
|
|
|
.sort((a, b) => a.name.indexOf(query) - b.name.indexOf(query))
|
|
|
|
|
.map(({ id, name }) => ({
|
|
|
|
|
id,
|
|
|
|
|
label: name,
|
|
|
|
|
value: id,
|
|
|
|
|
}))
|
|
|
|
|
.filter((option) => !selectedValues.has(option.value))
|
|
|
|
|
);
|
|
|
|
|
}, [countries, query, selectedValues]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Typeahead
|
|
|
|
|
label="Location"
|
|
|
|
|
minQueryLength={2}
|
|
|
|
|
noResultsMessage="No location found"
|
|
|
|
|
nullable={true}
|
|
|
|
|
options={options}
|
|
|
|
|