Added delete version
Deploy / deploy (push) Successful in 2m28s

This commit is contained in:
twotalesanimation
2026-05-20 21:53:18 +02:00
parent 05475a6c19
commit e4eb8fb3a9
3 changed files with 102 additions and 0 deletions
@@ -41,9 +41,11 @@ import {
AlertCircle,
User,
ExternalLink,
Trash2,
} from "lucide-react";
import { TASK_STATUS_CONFIG, TASK_TYPE_LABELS } from "@/components/tasks/TaskCard";
import { VersionUpload } from "@/components/versions/VersionUpload";
import { deleteVersion } from "@/actions/versions";
import type { CommentWithReplies } from "@/types";
import { CommentPanel } from "@/components/comments/CommentPanel";
@@ -155,6 +157,17 @@ export function TaskDetailClient({
}
};
const handleDeleteVersion = async (versionId: string, label: string) => {
if (!confirm(`Delete ${label}? This will permanently remove the file and all comments.`)) return;
try {
await deleteVersion(versionId);
toast({ title: "Version deleted" });
router.refresh();
} catch (e) {
toast({ title: "Delete failed", description: e instanceof Error ? e.message : undefined, variant: "destructive" });
}
};
return (
<div className="min-h-screen bg-background">
<div className="max-w-5xl mx-auto p-6 space-y-6">
@@ -298,6 +311,21 @@ export function TaskDetailClient({
Review
</Button>
</Link>
{canManage && (
<Button
variant="ghost"
size="icon"
className="h-7 w-7 text-muted-foreground hover:text-red-500"
onClick={() =>
handleDeleteVersion(
v.id,
`v${String(v.versionNumber).padStart(3, "0")}`
)
}
>
<Trash2 className="h-3.5 w-3.5" />
</Button>
)}
</div>
</div>
))}