upswyng icon indicating copy to clipboard operation
upswyng copied to clipboard

[web] Fetch categories from the server

Open rhinodavid opened this issue 5 years ago • 1 comments

As it stands today, the web app uses a hard-coded list of categories (https://github.com/CodeForBoulder/upswyng/blob/master/packages/upswyng-web/src/components/Categories.tsx).

However, the database has a Category table, as well as an endpoint to serve them (https://github.com/CodeForBoulder/upswyng/blob/master/packages/upswyng-server/src/routes/api/categories.ts).

Right now we've got a fragile situation because nothing ensures that these two data sources are in sync. We need to remove the dependency on the hard-coded categories and instead fetch them from the server.

A broad overview of the steps:

  • Modify the Category record to contain a field with the icon name
  • Manually (or maybe write a script?) to modify the current database to contain the proper icon names for the categories
  • Modify the web code to fetch the categories from the endpoints
  • Update the setupCategories script (https://github.com/CodeForBoulder/upswyng/blob/master/packages/upswyng-server/src/data-pipeline/setupCategories.ts) to include the icon names

rhinodavid avatar May 05 '20 01:05 rhinodavid

A different option -- we could extract the categories/subcategories in the setupCategories.ts script and put them in core and just have both packages reference them

rhinodavid avatar May 06 '20 03:05 rhinodavid