Objective
- After reordering charges / services in Edit charges and saving, the Charges table on the inspection workorder should show the same order, so office staff see the sequence they configured (not only the original scheduling / add order).
Background
- On the workorder, charges & payment rows have appeared in scheduling / add order; staff can drag to reorder inside Edit charges, save, and still see the old order on the workorder. Slack thread
- Save path today:
EditChargesModalbuilds achargeIdslist fromfinalServicesorder, thenPATCHesinspectionwithcharges: chargeIds(attik-frontend/.../EditChargesModal.tsx,callServerActionwithrevalidatePath/inspections/:idviacallServerAction.ts). - Render path today:
ServicesPaymentsdraws the charges table withinspection.charges.mapin array order—no extra sort—so the UI should match the persisted charge order once props/state reflect the saved inspection. - After save,
handleChargesSavedonly closes the modal; it does not callrouter.refresh(), unlike other toggles on the same page—decision needed whether stale client state vs populate order vsrevalidatePathscope explains the mismatch in production.
Scope
Frontend
attik-frontend/src/app/tools/inspections/[id]/components/EditChargesModal.tsx—handleConfirmedSave,servicesToCharges/chargesToServices(attik-frontend/src/util/functions/chargeConversions.ts),PATCH inspectionpayloadcharges.attik-frontend/src/util/functions/fetching/callServerAction.ts—revalidatePathwhen the third argument is set.attik-frontend/src/app/tools/inspections/[id]/components/ServicesPayments.tsx—handleChargesSaved, charges table mapping; compare with other actions thatrouter.refresh()afterPATCH.attik-frontend/src/app/tools/inspections/[id]/components/WorkorderPage.tsx—inspectionstate vsinitialInspectionafter revalidation.
Backend
attik-backend/src/routes/inspection.ts—PATCHwhenbody.chargesupdatesinspection.charges;GETpopulate('charges')ordering relative to the stored id array—confirm behavior if the UI still looks wrong after a hard refresh.attik-backend/src/models/inspectionSchema.ts—chargesas an ordered array of refs.
Product / architecture
- Decision needed: If the fix is client-only (refresh after save), vs server populate order guarantee—verify with one inspection in Mongo (raw
chargesarray order vs UI).
References
- Slack — workorder charge order
- Primary-service / primary charge UX: ATT-1664 (split from same intake).
attik-frontend/src/app/tools/inspections/[id]/components/EditChargesModal.tsxattik-frontend/src/app/tools/inspections/[id]/components/ServicesPayments.tsxattik-frontend/src/util/functions/fetching/callServerAction.tsattik-backend/src/routes/inspection.tsattik-backend/src/models/inspectionSchema.ts