Mission
Extend your first browser page with an editable one-item order. The person can change the customer name/type, active status, item name, price and quantity, then calculate. The quote still uses Course 02's pricing function unchanged.
Before implementing, write an acceptance table. A premium active customer buying one 150-unit item should see 162.00 total. At 100 units there is no discount and the total is 120.00. A standard customer buying two 150-unit items pays 360.00. Zero quantity is rejected.
Build in stages
- Add real labels and native form controls with stable names.
- Implement readOrderForm using the parser and issue strategy from the previous lessons.
- Keep an in-memory draft and a dirty/ready/error phase.
- Register a single submit handler in main.js.
- On input, mark the quote outdated and hide the previous breakdown.
- On submit, parse, validate, calculate and render the outcome.
- Add Restore example as a type=button action that replaces the draft with a fresh copy of your initial data.
Keep values in cents inside the domain. Restoring must copy the nested items too, so editing the restored draft does not mutate the original example.
Demonstrate one complete flow
Start at 162.00. Change quantity to 2: the previous result must no longer appear current. Submit: expect 324.00 for premium or 360.00 for standard. Clear price and submit: show a price issue, not zero. Restore: return to the baseline values and calculate 162.00 again.
Do not rely exclusively on visual inspection. Call your parsing and state functions with equivalent values in a test file and compare the outcomes. Keep Course 02's domain tests as regression checks.
Counterexample
A developer adds a 10% discount directly in the form handler because it is only one line. Set the subtotal exactly at 100 units: this often exposes a missing threshold condition. Remove the duplicated calculation and use the existing quote result instead.
Independent change request
"Now add a second item." Identify the affected model, controls and rendering. A permanent item id should identify which quantity changes; an array index alone becomes unreliable after removal. Implement this extension only after the one-item flow passes. Do not rewrite pricing: it already sums valid items.
Review criteria
Customer text resembling HTML stays literal. Keyboard submission works. Error correction preserves input. Restore does not submit twice. A removed or invalid item does not leave its amount behind. No action claims to save or purchase anything yet.
Deliverable
Submit your source, acceptance table and a short recording of the ready -> dirty -> error -> ready sequence. Explain one defect your counterexample revealed. The goal is a reliable interaction, not a large number of controls.