- Hits Site Controller, which calls the index action and fires App Component of React
- Upon Component did mount, fires off AJAX call to API/V1/DataController
- Instantiates RachioService
- calls store_data
- retrieves user_id info
- retrieves devices
- retreives device_zones
- After data is loaded into the database, promises call getZones and getDevices and sets State
- App: Contains all state and handles all AJAX calls
- Device: Preloader until database is loaded and app receives device in state
- All Zones: Once state has a zones object, it maps and passes a single zone to the zone component
- Zone: Displays zone data including name, previous watering duration and date
- WateringForm:
- sets initial state specific to the form
- captures zoneData from form
- fires waterZone and passes zoneData to the AJAX call at the App level
- changes state of watering to true, renders "Watering Zone for X minutes" instead
- WateringForm:
- Zone: Displays zone data including name, previous watering duration and date
- All Zones: Once state has a zones object, it maps and passes a single zone to the zone component
- Device: Preloader until database is loaded and app receives device in state
- Striking the balance between a scalable design and overdesigning
- Example - No need for users in the database at this point, but it would be beneficial to have ActiveRecord Relations in the future, ie: current_user.devices.zones.all
- Could make an AJAX call with headers and save everything in state from React without a Rails backend
- no testing
- not as scalable
- Tracing the flow of the application is fairly complex, and I think it could be more simple.
- Data doesn't persist, but Firebase / local storage seemed overkill considering the intent was only to water
- Return data from the API seems finicky, especially the wateringDuration. Also, no way to check if the sprinkler is actually firing.
- Loading data at the appropriate time.
- Solutions for to hold off mapping until data loads into state
- Not entirely sure how to format time of last watering. It seems like others may have been hitting the API with their duration formatted in minutes. I just want to prove that I hit Zone 3 on 5/18 at 2:15PM for 10 minutes (600 seconds).