[portal][feat] pass isLoading states to typeahead components

pull/519/head
Yangshun Tay 2 years ago
parent be52ecc51b
commit 98465a6128

@ -13,7 +13,7 @@ export type CompanyTypeaheadProps = Omit<
export default function CompanyTypeahead(props: CompanyTypeaheadProps) { export default function CompanyTypeahead(props: CompanyTypeaheadProps) {
const [query, setQuery] = useState(''); const [query, setQuery] = useState('');
const { data: companies } = trpc.useQuery([ const { data: companies, isLoading } = trpc.useQuery([
'companies.list', 'companies.list',
{ {
name: query, name: query,
@ -33,6 +33,7 @@ export default function CompanyTypeahead(props: CompanyTypeaheadProps) {
return ( return (
<ExpandedTypeahead <ExpandedTypeahead
{...(props as ExpandedTypeaheadProps)} {...(props as ExpandedTypeaheadProps)}
isLoading={isLoading}
label="Company" label="Company"
options={companyOptions} options={companyOptions}
onQueryChange={setQuery} onQueryChange={setQuery}

@ -23,7 +23,7 @@ export default function LocationTypeahead({
}: LocationTypeaheadProps) { }: LocationTypeaheadProps) {
const [query, setQuery] = useState(''); const [query, setQuery] = useState('');
const { data: locations } = trpc.useQuery([ const { data: locations, isLoading } = trpc.useQuery([
'locations.cities.list', 'locations.cities.list',
{ {
name: query, name: query,
@ -45,6 +45,7 @@ export default function LocationTypeahead({
return ( return (
<ExpandedTypeahead <ExpandedTypeahead
isLoading={isLoading}
{...({ {...({
onSuggestionClick: onSuggestionClick onSuggestionClick: onSuggestionClick
? (option: TypeaheadOption) => { ? (option: TypeaheadOption) => {

@ -26,7 +26,9 @@ export default function RoleTypeahead(props: RoleTypeaheadProps) {
{...(props as ExpandedTypeaheadProps)} {...(props as ExpandedTypeaheadProps)}
label="Role" label="Role"
options={ROLES.filter((option) => options={ROLES.filter((option) =>
option.label.toLowerCase().includes(query.toLowerCase()), option.label
.toLocaleLowerCase()
.includes(query.trim().toLocaleLowerCase()),
)} )}
onQueryChange={setQuery} onQueryChange={setQuery}
/> />

@ -36,10 +36,11 @@ export default function CitiesTypeahead({
}, },
]); ]);
const { data } = cities; const { data, isLoading } = cities;
return ( return (
<Typeahead <Typeahead
isLoading={isLoading}
label={label} label={label}
minQueryLength={3} minQueryLength={3}
noResultsMessage="No cities found" noResultsMessage="No cities found"

@ -34,10 +34,11 @@ export default function CompaniesTypeahead({
}, },
]); ]);
const { data } = companies; const { data, isLoading } = companies;
return ( return (
<Typeahead <Typeahead
isLoading={isLoading}
label="Company" label="Company"
noResultsMessage="No companies found" noResultsMessage="No companies found"
nullable={true} nullable={true}

@ -48,10 +48,11 @@ export default function CountriesTypeahead({
}, },
]); ]);
const { data } = countries; const { data, isLoading } = countries;
return ( return (
<Typeahead <Typeahead
isLoading={isLoading}
label={label} label={label}
noResultsMessage="No countries found" noResultsMessage="No countries found"
nullable={true} nullable={true}

@ -35,9 +35,8 @@ export default function JobTitlesTypeahead({
value: slug, value: slug,
})) }))
.sort((a, b) => b.ranking - a.ranking) .sort((a, b) => b.ranking - a.ranking)
.filter( .filter(({ label }) =>
({ label }) => label.toLocaleLowerCase().includes(query.trim().toLocaleLowerCase()),
label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) > -1,
); );
return ( return (

Loading…
Cancel
Save