wevisdemo / parliament-watch

Citizens are watching 👀
https://parliamentwatch.wevis.info
47 stars 26 forks source link

Refactor search function to support flexible category #66

Closed Th1nkK1D closed 9 months ago

Th1nkK1D commented 9 months ago

Current situation

The search functionality was implemented in #39 for the NavigationBar. Our search strategy is to create a SearchIndexes data that provides minimum data which will be filtered and shown in SearchResults. However, it only works with 3 fixed types of categories: politicians (นักการเมือง), bills (กฏหมาย), and votings (การลงมติ) as defined in src/models/search.ts

The corresponding UI looks like this:

image

What we want

Search functionality must be refactored in order to be able to be used in 2 more places

  1. Bills Page: search for bills and proposers (view Figma) image
  2. Home Page: has 3 separate search inputs, each search for politicians, bills, and votings only one category per input. (view Figma) image

I think the solution is to add support for the new category in SearchIndexes and SearchResults, and make it optional so each search input doesn't need to have the same category.

Starting point

  1. Model defined in src/models/search.ts
  2. Search function in src/libs/search.ts
  3. SearchItem, SearchResult, SearchResultGroup components in src/components
  4. Since the input UI for Bills and Home Page is the same, I suggest you create a new SearchInput component (with yarn gen:component) based on Carbon's TextInput which received flexible SearchIndexes props. You can just mock it as a const for now.
  5. No need to add to the Bill and Home Page route. You can work fully on the Histoire notebook with yarn story:dev
  6. Don't forget to update documentation (story file) and test to cover new use cases if necessary.

Important Please feel free to raise an issue if something is not making sense, or you found a better way to do it.

Th1nkK1D commented 9 months ago

@svnnynior Let me know if you're interested or have any questions.

svnnynior commented 9 months ago

@Th1nkK1D, sorry. it was a busy week.

yes, i am interested. but this month is quite packed for me, so it might need to take me a few weeks to finish it. feel free to assign it to me if that time frame is acceptable. thank you~

mixth commented 9 months ago

Our timeline is a bit tight, so I'll take a look at this now.

mixth commented 9 months ago

This is addressed in 2d960aef5657bdd5ee74cbffd47191ff8f7aede9 306670a92c1004f4a2d06711988875ace4630a0d 1d7b7b9298f1d543b1089749cd9fbd3a6925d974 5dffab206786688dce014398fe0fbc9731694fd7 f205ecbf8bc2db6f07e5c056d3909203e0fa367d cbc3cae761727258d7e8b5e38d5bcf55a7dc4ce0. (Internal issue tracking number WEV-64 was used instead of this issue number)

Consider this closed. Thanks all :)

Th1nkK1D commented 9 months ago

I made some updates.