import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { useState, useEffect } from 'react';
import { noop } from '@bigbinary/neeto-cist';
import Button from '@bigbinary/neetoui/Button';
import Checkbox from '@bigbinary/neetoui/Checkbox';
import Modal from '@bigbinary/neetoui/Modal';
import Typography from '@bigbinary/neetoui/Typography';
import { not } from 'ramda';
import { useTranslation } from 'react-i18next';
import { jsxs, jsx } from 'react/jsx-runtime';

var DeleteArchiveModal = function DeleteArchiveModal(_ref) {
  var _ref$checkboxLabel = _ref.checkboxLabel,
    checkboxLabel = _ref$checkboxLabel === void 0 ? "" : _ref$checkboxLabel,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? "" : _ref$className,
    _ref$description = _ref.description,
    description = _ref$description === void 0 ? "" : _ref$description,
    _ref$isArchiving = _ref.isArchiving,
    isArchiving = _ref$isArchiving === void 0 ? false : _ref$isArchiving,
    _ref$isDeleting = _ref.isDeleting,
    isDeleting = _ref$isDeleting === void 0 ? false : _ref$isDeleting,
    _ref$isOpen = _ref.isOpen,
    isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
    _ref$onArchive = _ref.onArchive,
    onArchive = _ref$onArchive === void 0 ? noop : _ref$onArchive,
    _ref$onClose = _ref.onClose,
    onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
    _ref$onDelete = _ref.onDelete,
    onDelete = _ref$onDelete === void 0 ? noop : _ref$onDelete,
    _ref$title = _ref.title,
    title = _ref$title === void 0 ? "" : _ref$title;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    isChecked = _useState2[0],
    setIsChecked = _useState2[1];
  var handleClose = function handleClose() {
    setIsChecked(false);
    onClose();
  };
  useEffect(function () {
    if (not(isOpen)) setIsChecked(false);
  }, [isOpen]);
  return /*#__PURE__*/jsxs(Modal, {
    className: className,
    isOpen: isOpen,
    "data-testid": "alert-box",
    onClose: handleClose,
    children: [/*#__PURE__*/jsx(Modal.Header, {
      children: /*#__PURE__*/jsx(Typography, {
        "data-testid": "delete-archive-alert-title",
        style: "h2",
        children: title
      })
    }), /*#__PURE__*/jsxs(Modal.Body, {
      children: [/*#__PURE__*/jsx(Typography, {
        "data-testid": "delete-archive-alert-message",
        lineHeight: "normal",
        style: "body2",
        children: description
      }), /*#__PURE__*/jsx(Checkbox, {
        checked: isChecked,
        className: "mt-4",
        "data-testid": "delete-archive-alert-archive-checkbox",
        label: checkboxLabel,
        onChange: function onChange() {
          return setIsChecked(function (isChecked) {
            return !isChecked;
          });
        }
      })]
    }), /*#__PURE__*/jsxs(Modal.Footer, {
      className: "neeto-ui-gap-2 neeto-ui-flex neeto-ui-items-center justify-end",
      children: [/*#__PURE__*/jsx(Button, {
        "data-testid": "delete-archive-alert-archive-button",
        disabled: not(isOpen),
        label: t("neetoMolecules.common.actions.archive"),
        loading: isArchiving,
        style: "secondary",
        onClick: onArchive
      }), /*#__PURE__*/jsx(Button, {
        "data-testid": "delete-archive-alert-delete-button",
        disabled: not(isChecked),
        label: t("neetoMolecules.common.actions.delete"),
        loading: isDeleting,
        style: "danger",
        onClick: onDelete
      })]
    })]
  });
};

export { DeleteArchiveModal as default };
//# sourceMappingURL=DeleteArchiveModal.js.map
