- 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>
31 lines
678 B
TypeScript
31 lines
678 B
TypeScript
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>
|
|
);
|
|
}
|