Apply and verify multiple discount codes
Normalize multiple discount codes, verify them together, and apply only the valid results without duplicate submissions.Description
Requirements
Export DiscountCodeManager from src/App.tsx.
Trim codes, compare case-insensitively, and keep one entry per normalized code.
Call verifyCodes with the complete normalized list before invoking onApply.
Show a named valid or invalid result beside every submitted code.
Disable verification while the current request is pending.
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.
Mixed codes
Enter save10 and expired
Both are verified and only save10 is applied
Trim codes, compare case-insensitively, and keep one entry per normalized code.
Duplicate spelling
Enter SAVE10 then save10
One normalized code is verified
Call verifyCodes with the complete normalized list before invoking onApply.
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 normalized-unique-codes behavior and make its observable result deterministic.
Hint 2
Model verifies-before-apply independently before combining it with the remaining states.
Hint 3
Verify the boundary described by prevents-duplicate-submit without changing caller-owned input.