fix: Wire archive button to updateInitiative mutation
The Archive menu item in InitiativeCard had no onClick handler. Added mutation call with confirmation dialog (shift+click to skip).
This commit is contained in:
@@ -36,6 +36,21 @@ export function InitiativeCard({
|
||||
onSpawnArchitect,
|
||||
onDelete,
|
||||
}: InitiativeCardProps) {
|
||||
const utils = trpc.useUtils();
|
||||
const archiveMutation = trpc.updateInitiative.useMutation({
|
||||
onSuccess: () => utils.listInitiatives.invalidate(),
|
||||
});
|
||||
|
||||
function handleArchive(e: React.MouseEvent) {
|
||||
if (
|
||||
!e.shiftKey &&
|
||||
!window.confirm(`Archive "${initiative.name}"?`)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
archiveMutation.mutate({ id: initiative.id, status: "archived" });
|
||||
}
|
||||
|
||||
// Each card fetches its own phase stats (N+1 acceptable for v1 small counts)
|
||||
const phasesQuery = trpc.listPhases.useQuery({
|
||||
initiativeId: initiative.id,
|
||||
@@ -109,7 +124,7 @@ export function InitiativeCard({
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem>Archive</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={handleArchive}>Archive</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem
|
||||
className="text-destructive"
|
||||
|
||||
Reference in New Issue
Block a user