import { jsx as _jsx } from "react/jsx-runtime";
import { approveReview, rejectReview } from "../services/reviewsService";
import { Check, X } from "lucide-react";
import { toast } from "sonner";
export const approveReviewCommand = {
    id: "approveReview",
    label: "Approve Page",
    icon: _jsx(Check, { strokeWidth: 1, className: "text-green-500" }),
    execute: async (context) => {
        if (!context.editContext.currentItemDescriptor) {
            return;
        }
        await approveReview(context.editContext.currentItemDescriptor);
        toast.success("Page/item approved");
    },
    disabled: (context) => {
        return !isReviewer(context);
    },
};
export const rejectReviewCommand = {
    id: "rejectReview",
    label: "Reject Page",
    icon: _jsx(X, { strokeWidth: 1, className: "text-red-500" }),
    execute: async (context) => {
        if (!context.editContext.currentItemDescriptor) {
            return;
        }
        await rejectReview(context.editContext.currentItemDescriptor);
        toast.error("Page/item rejected");
    },
    disabled: (context) => {
        return !isReviewer(context);
    },
};
function isReviewer(context) {
    const email = context.editContext.user?.email;
    if (!email)
        return false;
    return context.editContext.reviews.reviews.some((rwa) => rwa.assignments?.some((a) => a.reviewerEmail === email));
}
//# sourceMappingURL=reviewCommands.js.map