Switch market pricing without losing the cart
Reprice stable cart lines for a selected market while preserving quantities and rolling back failed market changes.Description
Requirements
Export MarketCartSwitcher from src/App.tsx.
Request prices for the next market and unique merchandise IDs before committing the switch.
Preserve every cart line ID, merchandise ID, quantity, and caller order.
Replace amount and currency from the returned price for each merchandise item.
Keep the prior market and lines when repricing rejects or omits an item.
Expose visible status and interactive controls with native semantics, accessible names, and keyboard operation appropriate to the workflow.
Do not mutate props, nested caller-owned values, or arrays supplied to the component.
US to CA
Two lines are repriced in CAD
The same line IDs and quantities receive CAD amounts
Request prices for the next market and unique merchandise IDs before committing the switch.
Missing price
One merchandise ID has no CA price
The original market and cart remain active
Preserve every cart line ID, merchandise ID, quantity, and caller order.
Constraints
Use React state and effects only where the observable component contract requires themUse injected adapters instead of accessing network, storage, timers, or browser globals directlyKeep one authoritative state transition for each user or adapter event
Hints
Hint 1
Start with the requests-market-prices behavior and make its observable result deterministic.
Hint 2
Model retains-line-identities independently before combining it with the remaining states.
Hint 3
Verify the boundary described by rolls-back-failure without changing caller-owned input.