Skip to content

Enhance typeahead, ignore "tildes" #88

@brauliodiez

Description

@brauliodiez

Right now it's using mock data, so only need to launch the front project (en sure docker desktop is installed, up and running)

clone the project.

Execute

npm install

Execute

npm start

Then take a look to the following pod:

front/src/pods/embalse-search

I would add there a file called

front/src/pods/embalse-search/embalse-search.business.ts

And there include a function with the following signature

//This function replaces accented vowels with unaccented vowels in a text string and place everything lowercase
// Rember to add unit tests here :)
export const normalizeSearchString=  (input : string) :string => {
 // Do your thing
 // Convert to lower
 // Replace accented vowels
}

And in this method:

  const getFilteredEmbalses = (inputValue: string): EmbalseSearchModel[] => {
-    const lower = inputValue.toLowerCase();
+    const normalizedInputValue = normalizeSearchString(intpuValue);

    return embalses
      .filter(
        (e) =>            
-          e.name.toLowerCase().includes(lower) ||
-          e.province.toLowerCase().includes(lower),
+          normalizeSearchString(e.name).includes(normalizedInputValue.) ||   
+          normalizeSearchString(e.province).includes(normalizedInputValue),

      )
      .map(mapEmbalseToSearch);
  };

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions