"use client";

import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/Button";
import { Modal } from "@/components/ui/Modal";

/**
 * Confirming the removal of a scan permission.
 *
 * Deliberately *not* the shared `ConfirmActionModal`: this dialog puts its
 * buttons in the modal footer without `xss:!w-full` and uses `pb-10` on the
 * question, where the shared one stacks its buttons on a phone and uses `pb-6`.
 * Folding them together would change how this dialog looks, which a
 * decomposition is not allowed to do.
 */
export default function RemovePermissionModal({
  open,
  onClose,
  onConfirm,
  isDeleting,
}: {
  open: boolean;
  onClose: () => void;
  onConfirm: () => void;
  isDeleting: boolean;
}) {
  const { t } = useTranslation();

  return (
    <Modal
      open={open}
      onClose={() => !isDeleting && onClose()}
      title={t("COMMON.REMOVE_PERMISSION")}
      size="sm"
      footer={
        <div className="flex justify-center w-full gap-5">
          <Button
            variant="primary"
            size="medium"
            disabled={isDeleting}
            onClick={onConfirm}
          >
            {t("COMMON.CONFIRM")}
          </Button>
          <Button
            variant="secondary"
            size="medium"
            onClick={onClose}
            disabled={isDeleting}
          >
            {t("COMMON.CANCEL")}
          </Button>
        </div>
      }
    >
      <div className="pb-10 text-center text-lg">
        <p>{t("COMMON.REMOVE_PERMISSION_DESCRIPTION")}</p>
      </div>
    </Modal>
  );
}
