import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/shared/common/ui/alert-dialog";
import { Button } from "@/shared/common/ui/button";
import { t } from "i18next";
import { Trash2 } from "lucide-react";
import { ReactNode } from "react";

interface DeleteOrganizationPopupProps {
  organizationName: string;
  onDelete: () => void;
  onCancel: () => void;
  isLoading: boolean;
  trigger: ReactNode;
}

export const DeleteOrganizationPopup = ({
  organizationName,
  onDelete,
  onCancel,
  isLoading,
  trigger,
}: DeleteOrganizationPopupProps) => {
  return (
    <AlertDialog>
      <AlertDialogTrigger asChild>{trigger}</AlertDialogTrigger>
      <AlertDialogContent>
        <AlertDialogHeader>
          <AlertDialogTitle>{t("organization.deleteOrganization")}</AlertDialogTitle>
          <AlertDialogDescription>
            {t("organization.confirmDelete")}{" "}
            <strong>{organizationName}</strong>? {t("organization.cannotUndo")}
          </AlertDialogDescription>
        </AlertDialogHeader>
        <AlertDialogFooter>
          <AlertDialogCancel
            onClick={onCancel}
            disabled={isLoading}
            className="cursor-pointer"
          >
            {t("common.Cancel")}
          </AlertDialogCancel>
          <AlertDialogAction
            className="bg-red-600 hover:bg-red-700 text-white cursor-pointer"
            disabled={isLoading}
            onClick={onDelete}
          >
            {isLoading ? t("organization.deleting") : t("organization.delete")}
          </AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
};
