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,
|
onSpawnArchitect,
|
||||||
onDelete,
|
onDelete,
|
||||||
}: InitiativeCardProps) {
|
}: 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)
|
// Each card fetches its own phase stats (N+1 acceptable for v1 small counts)
|
||||||
const phasesQuery = trpc.listPhases.useQuery({
|
const phasesQuery = trpc.listPhases.useQuery({
|
||||||
initiativeId: initiative.id,
|
initiativeId: initiative.id,
|
||||||
@@ -109,7 +124,7 @@ export function InitiativeCard({
|
|||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent align="end">
|
<DropdownMenuContent align="end">
|
||||||
<DropdownMenuItem>Archive</DropdownMenuItem>
|
<DropdownMenuItem onClick={handleArchive}>Archive</DropdownMenuItem>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
className="text-destructive"
|
className="text-destructive"
|
||||||
|
|||||||
Reference in New Issue
Block a user