fix:allow item quantity changes only for pending orders #19

Open
aziz_28002 wants to merge 1 commits from fix/dg-3-pending-only-quantity-changes into master
Collaborator

Summary

Item quantities can now only be changed on pending orders status

Ticket / Assignment

What changed

  • packages/shared/src/order-status.ts: added canEditOrderItems(status), which returns true only for "pending".
  • apps/api/src/orders/order-status.ts: now re-exports the shared canEditOrderItems instead of its own copy, which also allowed "processing".
  • apps/web/src/orders/order-items-panel.tsx: uses canEditOrderItems(order.status) to disable the quantity input and Save button and to show the pending-only note.
  • apps/web/public/app.css: regenerated Tailwind build. It adds the new disabled: utilities, plus resize-none

How to test

List exact commands and manual checks.

bun test apps/api/src/orders/order-quantity-assignment-3.test.ts
bun run test
bun run build:web

Manual checks:

  • UI, pending order order_1: the quantity is editable and saving shows "Quantity saved."
  • UI, processing order order_2 and shipped order order_3: the input and Save are disabled and the pending-only note is shown.
  • API, logged in as an employee:
    • POST /api/orders/order_2/items/item_3/quantity with { "quantity": 2 } returns 400 with "Order items cannot be changed for this order status."
    • POST /api/orders/order_3/items/item_4/quantity with { "quantity": 1 } returns 400.
    • POST /api/orders/order_1/items/item_1/quantity with { "quantity": 2 } returns 200.

Screenshots or recordings

Risks / follow-ups

  • Behavior change: staff can no longer adjust quantities on processing orders. Shipping address edits and cancellation still allow processing orders; they weren't part of this ticket.
  • Stale page: if an order moves out of pending while its page is open, Save stays enabled until the page refreshes. The backend rejects the request and an error toast is shown.
  • Pre-existing: bun run check:api fails with TS2322 in order-quantity-assignment-3.test.ts:28 and order-search-assignment-1.test.ts:28. It fails the same way on master, and this PR doesn't touch those files.

PR checklist

  • change is scoped to one ticket or one small reviewable concern
  • acceptance criteria were checked
  • code follows CONTRIBUTING.md
  • no unrelated refactor is mixed in
  • debug code and temporary logs are removed
  • relevant automated checks were run locally
  • changed behavior was manually tested when needed
  • known risks or follow-ups are called out
## Summary Item quantities can now only be changed on **pending** orders status ## Ticket / Assignment - Ticket: #15 ## What changed - `packages/shared/src/order-status.ts`: added `canEditOrderItems(status)`, which returns `true` only for `"pending"`. - `apps/api/src/orders/order-status.ts`: now re-exports the shared `canEditOrderItems` instead of its own copy, which also allowed `"processing"`. - `apps/web/src/orders/order-items-panel.tsx`: uses `canEditOrderItems(order.status)` to disable the quantity input and Save button and to show the pending-only note. - `apps/web/public/app.css`: regenerated Tailwind build. It adds the new `disabled:` utilities, plus `resize-none` ## How to test List exact commands and manual checks. ```bash bun test apps/api/src/orders/order-quantity-assignment-3.test.ts bun run test bun run build:web ``` Manual checks: - UI, pending order order_1: the quantity is editable and saving shows "Quantity saved." - UI, processing order order_2 and shipped order order_3: the input and Save are disabled and the pending-only note is shown. - API, logged in as an employee: - POST /api/orders/order_2/items/item_3/quantity with { "quantity": 2 } returns 400 with "Order items cannot be changed for this order status." - POST /api/orders/order_3/items/item_4/quantity with { "quantity": 1 } returns 400. - POST /api/orders/order_1/items/item_1/quantity with { "quantity": 2 } returns 200. ## Screenshots or recordings <video src="attachments/8962f98b-338d-486a-90e9-e067bed62704" title="edit_based_status.mov" controls></video> ## Risks / follow-ups - Behavior change: staff can no longer adjust quantities on processing orders. Shipping address edits and cancellation still allow processing orders; they weren't part of this ticket. - Stale page: if an order moves out of pending while its page is open, Save stays enabled until the page refreshes. The backend rejects the request and an error toast is shown. - Pre-existing: bun run check:api fails with TS2322 in order-quantity-assignment-3.test.ts:28 and order-search-assignment-1.test.ts:28. It fails the same way on master, and this PR doesn't touch those files. ## PR checklist - [x] change is scoped to one ticket or one small reviewable concern - [x] acceptance criteria were checked - [x] code follows CONTRIBUTING.md - [x] no unrelated refactor is mixed in - [x] debug code and temporary logs are removed - [x] relevant automated checks were run locally - [x] changed behavior was manually tested when needed - [x] known risks or follow-ups are called out
aziz_28002 added 1 commit 2026-10-01 15:32:40 +00:00
fix:allow item quantity changes only for pending orders
Runner Test / test (push) Successful in 18s
Runner Test / test (pull_request) Successful in 16s
7069a7801f
All checks were successful
Runner Test / test (push) Successful in 18s
Runner Test / test (pull_request) Successful in 16s
This pull request has changes conflicting with the target branch.
  • apps/api/src/orders/order-status.ts
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/dg-3-pending-only-quantity-changes:fix/dg-3-pending-only-quantity-changes
git checkout fix/dg-3-pending-only-quantity-changes
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: derrick/ai-wave-02#19