Workorder service order does not update after reordering

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: EditChargesModal builds a chargeIds list from finalServices order, then PATCHes inspection with charges: chargeIds (attik-frontend/.../EditChargesModal.tsx, callServerAction with revalidatePath /inspections/:id via callServerAction.ts).
  • Render path today: ServicesPayments draws the charges table with inspection.charges.map in array order—no extra sort—so the UI should match the persisted charge order once props/state reflect the saved inspection.
  • After save, handleChargesSaved only closes the modal; it does not call router.refresh(), unlike other toggles on the same page—decision needed whether stale client state vs populate order vs revalidatePath scope explains the mismatch in production.

Scope

Frontend

  • attik-frontend/src/app/tools/inspections/[id]/components/EditChargesModal.tsxhandleConfirmedSave, servicesToCharges / chargesToServices (attik-frontend/src/util/functions/chargeConversions.ts), PATCH inspection payload charges.
  • attik-frontend/src/util/functions/fetching/callServerAction.tsrevalidatePath when the third argument is set.
  • attik-frontend/src/app/tools/inspections/[id]/components/ServicesPayments.tsxhandleChargesSaved, charges table mapping; compare with other actions that router.refresh() after PATCH.
  • attik-frontend/src/app/tools/inspections/[id]/components/WorkorderPage.tsxinspection state vs initialInspection after revalidation.

Backend

  • attik-backend/src/routes/inspection.tsPATCH when body.charges updates inspection.charges; GET populate('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.tscharges as 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 charges array 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.tsx
  • attik-frontend/src/app/tools/inspections/[id]/components/ServicesPayments.tsx
  • attik-frontend/src/util/functions/fetching/callServerAction.ts
  • attik-backend/src/routes/inspection.ts
  • attik-backend/src/models/inspectionSchema.ts

Please authenticate to join the conversation.

Upvoters
Status

Planned

Board
🏠

Main App

Date

16 days ago

Author

Linear

Subscribe to post

Get notified by email when there are changes.