Dashboard Tech Doc - AashnaNarang/SurveyLab GitHub Wiki
APIs
-
Survey API Updates
Viewing all surveys
- Existing GET /api/v1/surveys API to get all the surveys in the system
Closing a survey
- Add a “closedOnDate” field in the database
- Update the PATCH api/v1/surveys/:id API
- Remove the check that doesn’t allow you to call this API if the survey is live
- When isLive was previously true, but now is being updated to false, then update the closedOnDate to right now.
- If closedOnDate ≠ null, then you shouldn’t be able to make the survey isLive = true again
Frontend
-
/ (Home page)
- Add a button at the top to create a new survey. This button routes to the /createSurvey page
- Make a table with a list of surveys. Each survey will show information and have buttons/a drop-down menu of options
- Information to show:
- Survey Title
- If it’s live
- Date it went live
- Date it closed on
- If this is empty, show a little - to show this cell is empty
- Options for each survey
- Respond to it —> this routes to the /survey/:id page
- This option should only be clickable if the survey is live
- View metrics —> This routes to the /surveyResponses/:surveyId page
- This option should only be clickable if the survey is NOT live
- Close survey —> This button calls the PATCH api/v1/surveys/:id API. Send a body with isLive = false Then route the user to the /surveyResponses/:surveyId page (or if that’s too hard then reload the dashboard page)
- This option should only be clickable if the survey is live
- Respond to it —> this routes to the /survey/:id page
- Information to show:
-
/survey/:id page updates
- If the survey is NOT live then show an error message saying “Sorry this survey is now closed.” Then when the user clicks “Ok” on the message, re-route them to the dashboard.