@@ -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 && (
|
||||
|
||||
Reference in New Issue
Block a user