Skip to content

Commit

Permalink
chore: testing autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Dec 2, 2024
1 parent 1296912 commit 01f9417
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions frontend/src/components/AutocompleteClientLocation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,16 @@ export interface AutocompleteComponentRefProps {
// Defines when the fetch should be skipped for a specific key
export const skipConditions = {
// Skip when the query value matches the selected text by the user on the dropdown
clients: (query: string) => {
const regex = /^[a-zA-Z\s]*,\s[a-zA-Z\s]*,*/;
return regex.exec(query) !== null;
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
clients: (query: string) => false,
// Never skips for locations
// eslint-disable-next-line @typescript-eslint/no-unused-vars
locations: (query: string) => false
};

// Fetch options for the Autocomplete component
export const fetchValues = async (query: string, key: string) => {

console.log(`fetchValues: query=${query}, key=${key}`);
// If there is no query, return an empty array
if(!key || !query) return [];

Expand Down Expand Up @@ -110,7 +108,7 @@ const AutocompleteClientLocation: React.ForwardRefExoticComponent<AutocompleteCo
className="flex-fill"
allowCustomValue={false}
selectedItem={client}
onInputChange={(value: string) => fetchOptions(value, "clients")}
onInputChange={(value: string) => fetchOptions(encodeURIComponent(value), "clients")}
onChange={handleClientChange}
itemToElement={(item: AutocompleteProps) => item.label}
helperText="Search by client name, number or acronym"
Expand Down

0 comments on commit 01f9417

Please sign in to comment.