add:internal order notes for employees #13

Open
aziz_28002 wants to merge 1 commits from feat/assignment-2-order-notes into master
Collaborator

Summary

Employees can now write and save internal notes on an order from the order detail page. The notes are stored on the order itself, so any teammate who opens the order later sees them in the new "Internal notes" card below Audit history. Each save is recorded in Audit history as "Updated internal notes." The API allows only employees to save notes and rejects notes that are empty or longer than 1000 characters.

Ticket / Assignment

Ticket: Assignment 2 (#9)

What changed

  • Shared contract: OrderDetail now includes notes (string | null). The 1000-character limit (maxOrderNotesLength) is shared by the API and the web app.
  • Database: new notes column on orders. Existing local databases get the column added automatically on startup, with no data loss or reseed needed.
  • API: new POST /api/orders/:orderId/notes, restricted to employees. The business rules (trimming, empty and length checks, 404 for unknown orders, audit event) live in update-order-notes.ts. The route handler only passes the request through.
  • GET /api/orders/:orderId now returns the saved notes.
  • UI: new "Internal notes" card on the order detail page, with a textarea and a "Save notes" button. Saving shows the "Notes saved." toast and refreshes the order and its audit history.

How to test

List exact commands and manual checks.

bun run test
bun run build:web
bun run check:web

Manual checks:

  • Log in as an employee, open an order, enter a note and click "Save notes". The "Notes saved." toast appears and Audit history shows "Updated internal notes."
  • Reload the page. The saved note is still in the textarea.
  • With an empty or spaces-only note, "Save notes" is disabled.

Screenshots or recordings

Screenshot 2026-09-24 at 8.23.22 PM.png

Risks / follow-ups

  • bun run check fails on an error that already exists on master in the Assignment 1 test file apps/api/src/orders/order-search-assignment-1.test.ts(28,3): TS2322 Type 'string | undefined' is not assignable to type 'string'. It is unrelated to this PR, and the test file was left untouched because it belongs to the owner. check:web passes.
  • Notes cannot be cleared once saved, because the API rejects empty notes as the Assignment 2 tests require.
  • Each order has a single note; saving replaces the previous text. Audit history records who updated the note and when, but not the old text.

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

🤖 Generated with Claude Code

## Summary Employees can now write and save internal notes on an order from the order detail page. The notes are stored on the order itself, so any teammate who opens the order later sees them in the new "Internal notes" card below Audit history. Each save is recorded in Audit history as "Updated internal notes." The API allows only employees to save notes and rejects notes that are empty or longer than 1000 characters. ## Ticket / Assignment Ticket: Assignment 2 (#9) ## What changed - Shared contract: `OrderDetail` now includes `notes` (`string | null`). The 1000-character limit (`maxOrderNotesLength`) is shared by the API and the web app. - Database: new `notes` column on `orders`. Existing local databases get the column added automatically on startup, with no data loss or reseed needed. - API: new `POST /api/orders/:orderId/notes`, restricted to employees. The business rules (trimming, empty and length checks, 404 for unknown orders, audit event) live in `update-order-notes.ts`. The route handler only passes the request through. - `GET /api/orders/:orderId` now returns the saved `notes`. - UI: new "Internal notes" card on the order detail page, with a textarea and a "Save notes" button. Saving shows the "Notes saved." toast and refreshes the order and its audit history. ## How to test List exact commands and manual checks. ```bash bun run test bun run build:web bun run check:web ``` Manual checks: - Log in as an employee, open an order, enter a note and click "Save notes". The "Notes saved." toast appears and Audit history shows "Updated internal notes." - Reload the page. The saved note is still in the textarea. - With an empty or spaces-only note, "Save notes" is disabled. ## Screenshots or recordings ![Screenshot 2026-09-24 at 8.23.22 PM.png](/attachments/5b8d24fa-5b97-436e-84ed-00171a8986f4) ## Risks / follow-ups - `bun run check` fails on an error that already exists on `master` in the Assignment 1 test file `apps/api/src/orders/order-search-assignment-1.test.ts(28,3): TS2322 Type 'string | undefined' is not assignable to type 'string'`. It is unrelated to this PR, and the test file was left untouched because it belongs to the owner. `check:web` passes. - Notes cannot be cleared once saved, because the API rejects empty notes as the Assignment 2 tests require. - Each order has a single note; saving replaces the previous text. Audit history records who updated the note and when, but not the old text. ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
aziz_28002 added 1 commit 2026-09-24 16:34:49 +00:00
add:internal order notes for employees
Runner Test / test (push) Successful in 16s
Runner Test / test (pull_request) Successful in 17s
bfe60631a5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -4,2 +4,4 @@
import type { OrderStatus } from "./order-status";
// Internal order notes are capped so they stay a short follow-up context, not a document.
export const maxOrderNotesLength = 1000;
Owner

This is fine for sharing a simple value across frontend and backend. I think a better way to make it more explicit is to encapsulate it by relation, so make it so that you can use it like: orderConstraints.notes.maxLength or similar, this way we can also easily add any other constraints when needed.

This is fine for sharing a simple value across frontend and backend. I think a better way to make it more explicit is to encapsulate it by relation, so make it so that you can use it like: `orderConstraints.notes.maxLength` or similar, this way we can also easily add any other constraints when needed.
Author
Collaborator

I see what you refer to, Sir.
Thanks, I will keep this pattern of extensibility in my mind next PRs

I see what you refer to, Sir. Thanks, I will keep this pattern of extensibility in my mind next PRs
Owner

Code is good, this would easily pass a simple feature addition. PR is a little wordy, but otherwise good job.

Code is good, this would easily pass a simple feature addition. PR is a little wordy, but otherwise good job.
All checks were successful
Runner Test / test (push) Successful in 16s
Runner Test / test (pull_request) Successful in 17s
This pull request has changes conflicting with the target branch.
  • apps/api/src/db/init-db.ts
  • apps/api/src/orders/order-routes.ts
  • apps/web/src/orders/order-detail-page.tsx
  • apps/web/src/orders/order-page.tsx
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/assignment-2-order-notes:feat/assignment-2-order-notes
git checkout feat/assignment-2-order-notes
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: derrick/ai-wave-02#13