codeforboston / urban-league-heat-pump-accelerator

Urban League Heat Pump Accelerator Project
MIT License
33 stars 22 forks source link

Add back-end endpoints to rtk-query setup, mocked with jsonserver #252

Closed mattdelsordo closed 1 year ago

mattdelsordo commented 1 year ago

Regardless of how they get used, we need to connect the back-end endpoints up to RTK query. Part of this is already done but we're missing a bunch. Having all this done up front will save us time when we have to hook it up to whatever components.

If you're familiar with Rails you can just look at the back-end code in /backend for reference. The API controllers live in /backend/app/controllers. Here are some other docs that might help:

For endpoints we currently have:

and we need:

*to be honest I'm not sure what the utility of these guys is, I kind of thought these would be covered by survey_visits

A wrinkle is that we have three instances of createApi for some reason. Per the RTK Query docs:

In most cases, you should use this once per app, with "one API slice per base URL" as a rule of thumb.

so we should probably consolidate src/api/apiSlice.js, src/redux/adminViewApiSlice.js, and src/redux/apiSlice.js into a single file.

Additionally, you're going to have to add new "tables" to the jsonserver config in frontend/front/src/dummyData/jsonServerData. Each rails controller needs an equivalent .js file here that is referenced in db.js. /backend/db/schema.rb defines the shape of the data as it is in the database. For now don't worry about getting fancy with json-server, just focus on the CRUD endpoints.

mattdelsordo commented 1 year ago

Done