- Run
npm i
- Run
npm start
- The app will be available at http://localhost:3000
- Run
npm run test
- If prompted, pess 'a' to run all tests
Create a React application that loads products from an API and allows the user to manage the inventory by deleting unwanted products from the list.
The basic user journey for this feature should be:
- Display a grid of products with product image, promotion badge, name, current price and previous price.
- Toggle a selection of products.
- User clicks a “Remove selected” button to remove the selected products from the list.
To finish up, create a stock level display by using the quantity and lowOnStock properties and use the available property to hide products that are not valid.
- The available property from this API is a string rather than a boolean so it should be transformed to the correct type after the response from the API is received.
- This API can return conflicting information, due to external dependencies, such as available: “TRUE” and quantity: 0, so make sure to capture these edge cases in the user interface.
App.js is largely concerned with fetching the data, rendering the grid of products and handling state, while the ProductCard component handles the logic of what to display in the card depending on the data.
To keep components simple and file sizes small I extracted into seperate components when there was opportunity to delegate logic for displaying groups of elements, e.g the ProductCard and StockLevel components handling the logic for displaying their children. To further simplify I've kept styled components in separate files.
While a component library has been used for speed, I've tried to demonstrate understanding of styling with a clean, responsive design.
Given more time I'd like to:
- Achieve complete test coverage. While the one test suite provides a good example, I would like to test all the components.
- Better error handling. Rather than just logging errors to the console in App.js I'd like to display a usefull message to the user.