mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-05-16 14:02:51 +08:00
[portal][feat] pass isLoading states to typeahead components
This commit is contained in:
@@ -13,7 +13,7 @@ export type CompanyTypeaheadProps = Omit<
|
||||
export default function CompanyTypeahead(props: CompanyTypeaheadProps) {
|
||||
const [query, setQuery] = useState('');
|
||||
|
||||
const { data: companies } = trpc.useQuery([
|
||||
const { data: companies, isLoading } = trpc.useQuery([
|
||||
'companies.list',
|
||||
{
|
||||
name: query,
|
||||
@@ -33,6 +33,7 @@ export default function CompanyTypeahead(props: CompanyTypeaheadProps) {
|
||||
return (
|
||||
<ExpandedTypeahead
|
||||
{...(props as ExpandedTypeaheadProps)}
|
||||
isLoading={isLoading}
|
||||
label="Company"
|
||||
options={companyOptions}
|
||||
onQueryChange={setQuery}
|
||||
|
||||
@@ -23,7 +23,7 @@ export default function LocationTypeahead({
|
||||
}: LocationTypeaheadProps) {
|
||||
const [query, setQuery] = useState('');
|
||||
|
||||
const { data: locations } = trpc.useQuery([
|
||||
const { data: locations, isLoading } = trpc.useQuery([
|
||||
'locations.cities.list',
|
||||
{
|
||||
name: query,
|
||||
@@ -45,6 +45,7 @@ export default function LocationTypeahead({
|
||||
|
||||
return (
|
||||
<ExpandedTypeahead
|
||||
isLoading={isLoading}
|
||||
{...({
|
||||
onSuggestionClick: onSuggestionClick
|
||||
? (option: TypeaheadOption) => {
|
||||
|
||||
@@ -26,7 +26,9 @@ export default function RoleTypeahead(props: RoleTypeaheadProps) {
|
||||
{...(props as ExpandedTypeaheadProps)}
|
||||
label="Role"
|
||||
options={ROLES.filter((option) =>
|
||||
option.label.toLowerCase().includes(query.toLowerCase()),
|
||||
option.label
|
||||
.toLocaleLowerCase()
|
||||
.includes(query.trim().toLocaleLowerCase()),
|
||||
)}
|
||||
onQueryChange={setQuery}
|
||||
/>
|
||||
|
||||
@@ -36,10 +36,11 @@ export default function CitiesTypeahead({
|
||||
},
|
||||
]);
|
||||
|
||||
const { data } = cities;
|
||||
const { data, isLoading } = cities;
|
||||
|
||||
return (
|
||||
<Typeahead
|
||||
isLoading={isLoading}
|
||||
label={label}
|
||||
minQueryLength={3}
|
||||
noResultsMessage="No cities found"
|
||||
|
||||
@@ -34,10 +34,11 @@ export default function CompaniesTypeahead({
|
||||
},
|
||||
]);
|
||||
|
||||
const { data } = companies;
|
||||
const { data, isLoading } = companies;
|
||||
|
||||
return (
|
||||
<Typeahead
|
||||
isLoading={isLoading}
|
||||
label="Company"
|
||||
noResultsMessage="No companies found"
|
||||
nullable={true}
|
||||
|
||||
@@ -48,10 +48,11 @@ export default function CountriesTypeahead({
|
||||
},
|
||||
]);
|
||||
|
||||
const { data } = countries;
|
||||
const { data, isLoading } = countries;
|
||||
|
||||
return (
|
||||
<Typeahead
|
||||
isLoading={isLoading}
|
||||
label={label}
|
||||
noResultsMessage="No countries found"
|
||||
nullable={true}
|
||||
|
||||
@@ -35,9 +35,8 @@ export default function JobTitlesTypeahead({
|
||||
value: slug,
|
||||
}))
|
||||
.sort((a, b) => b.ranking - a.ranking)
|
||||
.filter(
|
||||
({ label }) =>
|
||||
label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) > -1,
|
||||
.filter(({ label }) =>
|
||||
label.toLocaleLowerCase().includes(query.trim().toLocaleLowerCase()),
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user