Sobes.tech
Senior

Refactor the given React code to improve its structure and readability. The code includes a product list with search functionality, a cart count, and a sum of prices. Implement the fetchProducts function to simulate fetching products with a delay and possible error. Use React hooks such as useState, useEffect, and useCallback appropriately. Ensure the UI updates correctly when adding products to the cart and clearing the cart.