'use strict';

var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var React = require('react');
var neetoCist = require('@bigbinary/neeto-cist');
var Button = require('@bigbinary/neetoui/Button');
var Checkbox = require('@bigbinary/neetoui/Checkbox');
var Modal = require('@bigbinary/neetoui/Modal');
var Typography = require('@bigbinary/neetoui/Typography');
var ramda = require('ramda');
var reactI18next = require('react-i18next');
var jsxRuntime = require('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 ? neetoCist.noop : _ref$onArchive,
    _ref$onClose = _ref.onClose,
    onClose = _ref$onClose === void 0 ? neetoCist.noop : _ref$onClose,
    _ref$onDelete = _ref.onDelete,
    onDelete = _ref$onDelete === void 0 ? neetoCist.noop : _ref$onDelete,
    _ref$title = _ref.title,
    title = _ref$title === void 0 ? "" : _ref$title;
  var _useTranslation = reactI18next.useTranslation(),
    t = _useTranslation.t;
  var _useState = React.useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    isChecked = _useState2[0],
    setIsChecked = _useState2[1];
  var handleClose = function handleClose() {
    setIsChecked(false);
    onClose();
  };
  React.useEffect(function () {
    if (ramda.not(isOpen)) setIsChecked(false);
  }, [isOpen]);
  return /*#__PURE__*/jsxRuntime.jsxs(Modal, {
    className: className,
    isOpen: isOpen,
    "data-cy": "alert-box",
    "data-testid": "delete-archive-modal",
    onClose: handleClose,
    children: [/*#__PURE__*/jsxRuntime.jsx(Modal.Header, {
      children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
        "data-cy": "delete-archive-alert-title",
        style: "h2",
        children: title
      })
    }), /*#__PURE__*/jsxRuntime.jsxs(Modal.Body, {
      children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
        "data-cy": "delete-archive-alert-message",
        lineHeight: "normal",
        style: "body2",
        children: description
      }), /*#__PURE__*/jsxRuntime.jsx(Checkbox, {
        checked: isChecked,
        className: "mt-4",
        "data-cy": "delete-archive-alert-archive-checkbox",
        "data-testid": "delete-archive-alert-archive-checkbox",
        label: checkboxLabel,
        onChange: function onChange() {
          return setIsChecked(function (isChecked) {
            return !isChecked;
          });
        }
      })]
    }), /*#__PURE__*/jsxRuntime.jsxs(Modal.Footer, {
      className: "neeto-ui-gap-2 neeto-ui-flex neeto-ui-items-center justify-end",
      children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
        "data-cy": "delete-archive-alert-archive-button",
        disabled: ramda.not(isOpen),
        label: t("neetoMolecules.common.actions.archive"),
        loading: isArchiving,
        style: "secondary",
        onClick: onArchive
      }), /*#__PURE__*/jsxRuntime.jsx(Button, {
        "data-cy": "delete-archive-alert-delete-button",
        disabled: ramda.not(isChecked),
        label: t("neetoMolecules.common.actions.delete"),
        loading: isDeleting,
        style: "danger",
        onClick: onDelete
      })]
    })]
  });
};

module.exports = DeleteArchiveModal;
//# sourceMappingURL=DeleteArchiveModal.js.map
