Implement answering checks interface - the part of Verification Tool
After reading the assignment I decided to use external libraries like react-query
and final-form
to help me manage form state and async data fetching.
- Initially user will be shown a loader while checks are being fetched.
- If fetching checks fails user will see error message with button to try and get checks again
- Once checks are fetched user can fill out checks interface and click "Submit"
- If submitting checks fails user will see error toast and can attempt to submit again
- When checks are successfully submitted user will see success screen
- Fetching data - Instead of using
react-query
it could be done via window.fetch which is built in to browsers and managing loading/error state manually inside a try catch block. - Managing state - Form could be wrapped in context and field changes would update form state accordingly (focus, blur, change etc...)
- Currently, all components are together inside components folder. In a bigger application it would make sense to separate presentational and container components
- Not sure if all checked values after no should also be removed on submit.
- Not checking case of check value (yes/no) because CheckResult type accepts only lowercase value
- In real applications api calls would be mocked by
msw
or mock api
Used for fetching checks from fetchChecks
and submitting checks to submitCheckResults
.
Also takes care of async error handling and error-boundary state.
Used to display error boundary if fetchChecks
fails.
Used to display error toast if submitCheckResults
fails.
Used to manage checks form state, enabling/disabling fields and submit button.
This library was chosen out of convenience and familiarity.
Other form state management libraries like formik
or react-hook-form
would work also.
Used to analyse and format code
Installs the required dependencies.
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
Launches the test runner in watch mode.
Launches the test runner and displays coverage. Is not running in watch mode.
Builds the app for production to the build
folder.