1.6 KiB
1.6 KiB
F-085 — Architect: /tax-rates TIPO column is not editable
Root cause
/admin/tax-rates PATCH route (project/src/modules/pricing/api/pricing.routes.ts) only accepts { name, ratePercent, active }; appliesTo is not in the body schema and not written to the DB. The admin page renders the column as plain <td>{r.appliesTo}</td>.
Design
- Extend the PATCH body Zod schema with
appliesTo: z.enum(['general','reduced','super-reduced']).optional(). Server validates the value against the enum (no DB constraint, but rejection is fast and the error message is clear). - Add a new UPDATE branch for
applies_tomirroring the existing ones. - In the admin page, the TIPO cell is now click-to-edit:
- Click
<button>→ switches to a<select autoFocus>with the three valid values. - On
change, if the new value differs, fire PATCH immediately and close edit mode. - On
blur, if value still equals the original, just close; if different andchangealready fired, no-op.
- Click
- Success path updates the row in-place (
rates.map(...)).
Risk
Low. Server-side enum validation; no SQL injection; no new deps.
Acceptance mapping
- "TIPO cell enters edit mode on click and shows a select with allowed types" → button → select.
- "Selecting a new type and confirming triggers PATCH /tax-rates/:id" → onChange path.
- "Invalid types are rejected client and server side" → Zod enum on server; select restricts client.
- "Successful change is reflected without a full page reload" → in-place state update.
- "verify.sh is green" → typecheck + lint clean.