"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

exports.__esModule = true;
exports.AuthPopup = void 0;

var _react = _interopRequireWildcard(require("react"));

var _lib = require("@sentecacommerce-theme/lib");

var _Components = require("./Components");

var _ = require("../../");

var AuthPopup = function AuthPopup(props) {
  var isCheckout = props.isCheckout;

  var _useState = (0, _react.useState)('Login'),
      currentForm = _useState[0],
      setCurrentForm = _useState[1];

  var _useGlobalLabels = (0, _lib.useGlobalLabels)(),
      buttons = _useGlobalLabels.buttons;

  var _useUIFunctions = (0, _lib.useUIFunctions)(),
      closeViewById = _useUIFunctions.closeViewById;

  var openForm = function openForm(form) {
    return function () {
      setCurrentForm(form);
    };
  };

  var _useConfigState = (0, _lib.useConfigState)(),
      views = _useConfigState.views;

  var handleClose = function handleClose() {
    return closeViewById(views.auth);
  };

  var Forms = {
    Login: /*#__PURE__*/_react["default"].createElement(_Components.LoginForm, {
      handleClose: handleClose,
      openForgotPassword: openForm('Forgot Password')
    }),
    Register: /*#__PURE__*/_react["default"].createElement(_Components.RegisterForm, {
      handleClose: handleClose
    }),
    'Forgot Password': /*#__PURE__*/_react["default"].createElement(_Components.ForgotPassword, {
      handleClose: handleClose,
      goBack: openForm('Login')
    })
  };
  return /*#__PURE__*/_react["default"].createElement(_.Modal, {
    withBottomOffset: true,
    maxWidth: "45rem",
    open: true,
    handleClose: handleClose
  }, isCheckout && /*#__PURE__*/_react["default"].createElement("div", {
    className: "mt-4 mt-md-0 pb-2"
  }, /*#__PURE__*/_react["default"].createElement(_.Button, {
    bordered: true,
    borderRadius: "small",
    fullWidth: true,
    variant: "light",
    iconPosition: "right",
    link: "/checkout",
    onClick: handleClose
  }, /*#__PURE__*/_react["default"].createElement("p", {
    style: {
      lineHeight: '1.5'
    }
  }, buttons.guestCheckout))), currentForm !== 'Forgot Password' && /*#__PURE__*/_react["default"].createElement(_Components.Headers, {
    active: currentForm,
    setActive: setCurrentForm
  }), Forms[currentForm]);
};

exports.AuthPopup = AuthPopup;
//# sourceMappingURL=index.js.map