upswyng
upswyng copied to clipboard
[web] Fetch categories from the server
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
Categoryrecord 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
setupCategoriesscript (https://github.com/CodeForBoulder/upswyng/blob/master/packages/upswyng-server/src/data-pipeline/setupCategories.ts) to include the icon names
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