feat(09-01): add classification API route, client hook, badge component, and setup detail wiring
- Add PATCH /:id/items/:itemId/classification endpoint with Zod validation - Add apiPatch helper to client API library - Add useUpdateItemClassification mutation hook - Add classification field to SetupItemWithCategory interface - Create ClassificationBadge click-to-cycle component (base/worn/consumable) - Wire ClassificationBadge into setup detail page item grid - Add integration tests for PATCH classification route (valid + invalid) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { Hono } from "hono";
|
||||
import {
|
||||
createSetupSchema,
|
||||
syncSetupItemsSchema,
|
||||
updateClassificationSchema,
|
||||
updateSetupSchema,
|
||||
} from "../../shared/schemas.ts";
|
||||
import {
|
||||
@@ -12,6 +13,7 @@ import {
|
||||
getSetupWithItems,
|
||||
removeSetupItem,
|
||||
syncSetupItems,
|
||||
updateItemClassification,
|
||||
updateSetup,
|
||||
} from "../services/setup.service.ts";
|
||||
|
||||
@@ -73,6 +75,19 @@ app.put("/:id/items", zValidator("json", syncSetupItemsSchema), (c) => {
|
||||
return c.json({ success: true });
|
||||
});
|
||||
|
||||
app.patch(
|
||||
"/:id/items/:itemId/classification",
|
||||
zValidator("json", updateClassificationSchema),
|
||||
(c) => {
|
||||
const db = c.get("db");
|
||||
const setupId = Number(c.req.param("id"));
|
||||
const itemId = Number(c.req.param("itemId"));
|
||||
const { classification } = c.req.valid("json");
|
||||
updateItemClassification(db, setupId, itemId, classification);
|
||||
return c.json({ success: true });
|
||||
},
|
||||
);
|
||||
|
||||
app.delete("/:id/items/:itemId", (c) => {
|
||||
const db = c.get("db");
|
||||
const setupId = Number(c.req.param("id"));
|
||||
|
||||
Reference in New Issue
Block a user