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:
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { apiDelete, apiGet, apiPost, apiPut } from "../lib/api";
|
||||
import { apiDelete, apiGet, apiPatch, apiPost, apiPut } from "../lib/api";
|
||||
|
||||
interface SetupListItem {
|
||||
id: number;
|
||||
@@ -24,6 +24,7 @@ interface SetupItemWithCategory {
|
||||
updatedAt: string;
|
||||
categoryName: string;
|
||||
categoryIcon: string;
|
||||
classification: string;
|
||||
}
|
||||
|
||||
interface SetupWithItems {
|
||||
@@ -105,3 +106,20 @@ export function useRemoveSetupItem(setupId: number) {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateItemClassification(setupId: number) {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({
|
||||
itemId,
|
||||
classification,
|
||||
}: { itemId: number; classification: string }) =>
|
||||
apiPatch<{ success: boolean }>(
|
||||
`/api/setups/${setupId}/items/${itemId}/classification`,
|
||||
{ classification },
|
||||
),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["setups", setupId] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user