feat(F-177): completed feature

This commit is contained in:
chattie
2026-08-22 18:54:41 +02:00
parent 4081462cc4
commit abdb03b6b5
17 changed files with 326 additions and 23 deletions

View File

@@ -0,0 +1,7 @@
# F-177 — Architecture
- Add `orders_orders.state_changed_at`, initialized from `updated_at`, indexed for monitored states.
- Every state transition updates both `updated_at` and `state_changed_at`; non-state edits only update `updated_at`.
- Admin endpoint `GET /orders/notifications/stale?hours=24&limit=20`: RBAC admin, fixed monitored states, parameterized threshold, total + items.
- Header client component polls every 5 minutes, refreshes when opened, closes on Escape/outside click, and links to `/orders/:id`.
- Bell badge caps visual text at `99+`; dropdown differentiates pending and shipped.

View File

@@ -0,0 +1,3 @@
# Admin order notifications
The bell in the Admin header lists orders that have remained `Pending` or `Shipped` for more than 24 hours without a state transition. The badge is the total number of stale orders. Open the bell to review age, customer and amount; selecting an entry opens that order. Data refreshes every five minutes and whenever the panel opens.

View File

@@ -0,0 +1,8 @@
# F-177 — Implementer
- Migration 051 adds indexed `state_changed_at`, backfilled from `updated_at`.
- Repository and payment state transitions now update that timestamp; edits unrelated to state do not reset the 24 h clock.
- New admin-only `GET /orders/notifications/stale` returns PENDING/SHIPPED orders older than threshold, total count, customer, amount and elapsed hours.
- Header bell includes count badge, accessible dropdown, status/age/amount, direct links, empty/error/loading states, 5-minute polling, manual refresh, Escape and outside-click closing.
Evidence: migration applied; project typecheck PASS; order tests 7/7; Admin Next build PASS; authenticated endpoint HTTP 200. Controlled acceptance row at 25 h returned total=1/state=PENDING/ageHours=25, then database row was restored.

View File

@@ -0,0 +1 @@
{"feature_id":"F-177","agent":"leader","stage":"close","verdict":"APPROVED","checks":[{"item":"reviewer/security/qa approved","ok":true},{"item":"migration applied","ok":true},{"item":"controlled 25-hour runtime acceptance","ok":true},{"item":"verify.sh green","ok":true}],"issues":[]}

View File

@@ -0,0 +1 @@
{"feature_id":"F-177","agent":"qa","stage":"qa_gate","verdict":"APPROVED","checks":[{"item":"25-hour PENDING order appears","ok":true},{"item":"fresh/no qualifying orders excluded","ok":true},{"item":"endpoint total and age correct","ok":true},{"item":"Admin build","ok":true},{"item":"orders regression tests 7/7","ok":true},{"item":"verify.sh","ok":true}],"issues":[]}

View File

@@ -0,0 +1 @@
{"feature_id":"F-177","agent":"reviewer","stage":"review_gate","verdict":"APPROVED","checks":[{"item":"dedicated state transition timestamp","ok":true},{"item":"PENDING and SHIPPED threshold query","ok":true},{"item":"responsive accessible header dropdown","ok":true},{"item":"tests/build/runtime","ok":true}],"issues":[]}

View File

@@ -0,0 +1 @@
{"feature_id":"F-177","agent":"security","stage":"security_gate","verdict":"APPROVED","checks":[{"item":"admin role required","ok":true},{"item":"hours and limit bounded","ok":true},{"item":"SQL values parameterized","ok":true},{"item":"no sensitive data beyond existing admin order access","ok":true}],"issues":[]}

View File

@@ -1,3 +1,3 @@
# F-176Fix POS existing product search
# F-177Add stale order notifications to admin header
POS search currently executes stale SQL against nonexistent variant fields (`v.name`, `v.active`, `p.active`, `s.quantity`, `pp.price_cents`, category-by-variant), then hides HTTP 500 as an empty result. Align search/EAN/SKU queries with current catalog, pricing, inventory and category schemas. Barcode text must support exact and partial EAN lookup.
Create an admin-only stale-order endpoint and header bell. Notify when an order remains in `PENDING` or `SHIPPED` for at least 24 hours since its last state transition. Show badge count, dropdown details, elapsed time and direct links to each order. Refresh automatically and on demand.

View File

@@ -1,68 +1,68 @@
{
"feature_id": "F-176",
"feature_id": "F-177",
"stage": "close",
"agent": "leader",
"action": "Close POS existing product search fix",
"action": "Close admin stale-order notifications",
"state": "running",
"next_agent": "leader",
"waiting_for": "Seleccionar una feature pending y actualizar este estado",
"updated_at": "2026-08-22T16:49:23Z",
"updated_at": "2026-08-22T16:54:21Z",
"timeline": [
{
"ts": "2026-08-22T16:45:39Z",
"ts": "2026-08-22T16:49:42Z",
"agent": "leader",
"stage": "intake",
"state": "running",
"message": "Diagnose POS product search for existing barcode"
"message": "Define stale pending/shipped order notifications"
},
{
"ts": "2026-08-22T16:46:57Z",
"ts": "2026-08-22T16:50:13Z",
"agent": "architect",
"stage": "design",
"state": "running",
"message": "Align POS lookup SQL with current catalog schema"
"message": "Design state-age endpoint and admin header bell"
},
{
"ts": "2026-08-22T16:47:05Z",
"ts": "2026-08-22T16:50:24Z",
"agent": "implementer",
"stage": "build",
"state": "running",
"message": "Repair POS product lookup queries and visible errors"
"message": "Implement stale-order endpoint, state timestamp and header dropdown"
},
{
"ts": "2026-08-22T16:48:42Z",
"ts": "2026-08-22T16:53:33Z",
"agent": "reviewer",
"stage": "review_gate",
"state": "running",
"message": "Review current-schema POS search repair"
"message": "Review state-age semantics and header component"
},
{
"ts": "2026-08-22T16:48:51Z",
"ts": "2026-08-22T16:53:42Z",
"agent": "security",
"stage": "security_gate",
"state": "running",
"message": "Audit POS search authorization and SQL parameters"
"message": "Audit notification endpoint RBAC and query bounds"
},
{
"ts": "2026-08-22T16:49:02Z",
"ts": "2026-08-22T16:53:51Z",
"agent": "qa",
"stage": "qa_gate",
"state": "running",
"message": "Validate partial barcode and exact EAN searches"
"message": "Validate 24-hour stale-order notification acceptance"
},
{
"ts": "2026-08-22T16:49:12Z",
"ts": "2026-08-22T16:54:10Z",
"agent": "documenter",
"stage": "document",
"state": "running",
"message": "Document repaired POS lookup behavior"
"message": "Document stale-order notification behavior"
},
{
"ts": "2026-08-22T16:49:23Z",
"ts": "2026-08-22T16:54:21Z",
"agent": "leader",
"stage": "close",
"state": "running",
"message": "Close POS existing product search fix"
"message": "Close admin stale-order notifications"
}
]
}