CartContext.tsx
[Vulnerable Target View]
// VULNERABLE: We trusted the local React state as the single
// source of truth. If the server updated (e.g., checkout success)
// but the client-side event didn't fire, the user remained
// 'stuck' in an old cart state indefinitely.
const handleCheckout = async () => {
const response = await api.post('/checkout');
// LOGIC GAP: No re-sync mechanism. We manually clear
// local state, but if a network hiccup occurs, the UI
// and Server drift apart permanently.
setCart([]);
};