Delete
In order to implement the delete product functionality, we can implement a DeleteProduct component similar to the DeleteShop component, and add it to the MyProducts component for each product in the list. It can take the product object, shopID, and an onRemove method as a prop from MyProducts, as discussed in the MyProducts component for shop owners section.
The component will function the same as DeleteShop, opening a dialog for confirmation on button-click and then, when the delete intent is confirmed by the user, calling the fetch method for delete, which makes the DELETE request to the server at /api/product/:shopId/:productId. This backend API for deleting a product from the database will be declared as follows with the other ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access