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:
30
src/client/components/ClassificationBadge.tsx
Normal file
30
src/client/components/ClassificationBadge.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
const CLASSIFICATION_LABELS: Record<string, string> = {
|
||||
base: "Base Weight",
|
||||
worn: "Worn",
|
||||
consumable: "Consumable",
|
||||
};
|
||||
|
||||
interface ClassificationBadgeProps {
|
||||
classification: string;
|
||||
onCycle: () => void;
|
||||
}
|
||||
|
||||
export function ClassificationBadge({
|
||||
classification,
|
||||
onCycle,
|
||||
}: ClassificationBadgeProps) {
|
||||
const label = CLASSIFICATION_LABELS[classification] ?? "Base Weight";
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onCycle();
|
||||
}}
|
||||
className="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-600 hover:bg-gray-200 transition-colors cursor-pointer"
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user