added unapprove
Deploy / deploy (push) Successful in 2m37s

This commit is contained in:
twotalesanimation
2026-06-11 15:19:12 +02:00
parent 7b9bbbec16
commit b640fa472c
5 changed files with 361 additions and 2 deletions
+21 -1
View File
@@ -35,7 +35,7 @@ import {
Trash2,
} from "lucide-react";
import type { VersionWithDetails } from "@/types";
import { submitApproval } from "@/actions/approvals";
import { submitApproval, unapproveVersion } from "@/actions/approvals";
import { deleteVersion } from "@/actions/versions";
import { useToast } from "@/components/ui/use-toast";
@@ -113,6 +113,17 @@ export function VersionList({
}
};
const handleUnapprove = async (versionId: string) => {
if (!confirm("Undo approval? The version will return to Pending Review and the task will return to Internal Review.")) return;
try {
await unapproveVersion(versionId);
toast({ title: "Approval undone", description: "Version reset to Pending Review" });
router.refresh();
} catch (e) {
toast({ title: "Failed to unapprove", description: e instanceof Error ? e.message : undefined, variant: "destructive" });
}
};
const handleDelete = async (versionId: string, label: string) => {
if (!confirm(`Delete ${label}? This will permanently remove the file and all comments.`)) return;
try {
@@ -233,6 +244,15 @@ export function VersionList({
<XCircle className="h-3.5 w-3.5 mr-2" />
Reject
</DropdownMenuItem>
{version.approvalStatus === "APPROVED" && (
<DropdownMenuItem
className="text-amber-500"
onClick={() => handleUnapprove(version.id)}
>
<AlertCircle className="h-3.5 w-3.5 mr-2" />
Undo Approval
</DropdownMenuItem>
)}
</>
)}
{canManage && (