'use strict';

var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
var Button = require('@bigbinary/neetoui/Button');
var Modal = require('@bigbinary/neetoui/Modal');
var Typography = require('@bigbinary/neetoui/Typography');
var reactI18next = require('react-i18next');
var reactQuery = require('@tanstack/react-query');
var axios = require('axios');
var jsxRuntime = require('react/jsx-runtime');

var create = function create() {
  return axios.post("/neeto_sso/api/v1/subscription_request");
};
var subscriptionRequestApi = {
  create: create
};

var useCreateSubscriptionRequest = function useCreateSubscriptionRequest() {
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
    onSuccess = _ref.onSuccess;
  return reactQuery.useMutation({
    mutationFn: subscriptionRequestApi.create,
    onSuccess: onSuccess
  });
};

var SubscriptionUpgradeRequestModal = function SubscriptionUpgradeRequestModal(_ref) {
  var _globalProps$appName;
  var isOpen = _ref.isOpen,
    onClose = _ref.onClose;
  var _useTranslation = reactI18next.useTranslation(),
    t = _useTranslation.t;
  var pricingPageUrl = "https://neeto.com/".concat((_globalProps$appName = initializers.globalProps.appName) === null || _globalProps$appName === void 0 ? void 0 : _globalProps$appName.toLowerCase(), "/pricing");
  var _useCreateSubscriptio = useCreateSubscriptionRequest({
      onSuccess: onClose
    }),
    sendRequest = _useCreateSubscriptio.mutate,
    isPending = _useCreateSubscriptio.isPending;
  return /*#__PURE__*/jsxRuntime.jsxs(Modal, {
    isOpen: isOpen,
    onClose: onClose,
    closeOnEsc: !isPending,
    closeOnOutsideClick: !isPending,
    children: [/*#__PURE__*/jsxRuntime.jsx(Modal.Header, {
      children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
        style: "h3",
        weight: "semibold",
        children: t("neetoMolecules.subscriptionRequest.title")
      })
    }), /*#__PURE__*/jsxRuntime.jsxs(Modal.Body, {
      children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
        style: "body2",
        children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
          components: {
            strong: /*#__PURE__*/jsxRuntime.jsx("strong", {})
          },
          i18nKey: "neetoMolecules.subscriptionRequest.description"
        })
      }), /*#__PURE__*/jsxRuntime.jsx(Typography, {
        className: "mt-3",
        style: "body2",
        children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
          i18nKey: "neetoMolecules.subscriptionRequest.pricingInfo",
          components: {
            pricingLink: /*#__PURE__*/jsxRuntime.jsx("a", {
              className: "neeto-ui-text-primary-500",
              href: pricingPageUrl,
              rel: "noopener noreferrer",
              target: "_blank"
            })
          }
        })
      })]
    }), /*#__PURE__*/jsxRuntime.jsxs(Modal.Footer, {
      className: "flex gap-x-2",
      children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
        disabled: isPending,
        label: t("neetoMolecules.subscriptionRequest.cancel"),
        style: "secondary",
        onClick: onClose
      }), /*#__PURE__*/jsxRuntime.jsx(Button, {
        disabled: isPending,
        label: t("neetoMolecules.subscriptionRequest.sendRequest"),
        loading: isPending,
        style: "primary",
        onClick: sendRequest
      })]
    })]
  });
};

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