π¨βπΌ The muffin shop wants a simple dashboard for a single order so the team can
double-check totals before handing it off.
π This example uses React + Vite, but everything React-related is already done
for you. You only need the workshop skills: numbers, strings, booleans,
variables, functions, if/else, switch statements, loops, and
never.π¨ Open
and implement the exported
helpers. Function signatures are already in the file.
Business rules
- Money display:
formatMoneyformats an amount with a leading$(for example4.5displays as$4.5). - Line items:
buildLineItemTextshowsquantity x name, and appends(GF)(leading space) when the item is gluten-free. Examples:2 x Blueberry Muffin,1 x Oatberry Muffin (GF). - Subtotal: sum of each itemβs price Γ quantity (use a loop).
- Member discount: status
'member'gets 10% off when the subtotal is at least$20; otherwise$0. - Tax / tip: tax uses the taxable amount and rate; tip uses the amount before tip and the tip percent.
- Total: subtotal, minus discount, plus tax, tip, and pickup fee.
- Pickup fee (switch):
counterβ$0,curbsideβ$3,deliveryβ$7. - Pickup label (switch):
Counter pickup,Curbside pickup, orDelivery dropoff. UseassertNeverfor impossible cases. - Notes:
nullor an empty string becomesNo special notes; otherwise keep the note. - Ready log:
logOrderReadyis avoidfunction that logsOrder ready for <customer>. assertNever: throw so TypeScript knows that branch cannot continue (include the unexpected value in the error).
Success criteria
- The dashboard in renders without runtime errors once the helpers are implemented
- With the default app fixtures (
member,curbside, gluten-free items, empty note), you should see:- Line items including a
(GF)suffix where appropriate - Pickup label
Curbside pickupand a pickup fee of$3 - Special note text
No special notes - Console log:
Order ready for Avery
- Line items including a
- Toggle
memberStatusorpickupMethodinand confirm labels/fees/discounts update
Run the example
npm run dev --workspace extra_muffin-shop-dashboard
Try next
- π¨ Add another
OrderItemand watch the totals change. - π¨ Add a
rushOrderboolean and increase the tip when it is true. - π¨ Add a
itemCounthelper that uses a loop to count total quantity. - π¨ Add a
happyHourboolean and reduce the muffin price when true. - π¨ Add a
memberMessagestring inapp.tsxusing anifcheck. - π° Change
specialNoteto a real note and confirm the fallback logic.