import { aZ as headerAlertsQueue, h as AlertType, T as Trans, i as CommonError, j as Alert, a9 as Spinner, aa as SpinnerStyle } from "./index.js";
import React__default from "react";
import "./dateFns.js";
import "./validator.js";
import "./reactPlayer.js";
import "react-router-dom";
import "./reactSlick.js";
var AccountDeletionNoticePage$1 = "";
class AccountDeletionNoticePage extends React__default.Component {
  constructor(props) {
    super(props);
    this.notifyCancelAccountDeletionSuccess = async () => {
      headerAlertsQueue.push({
        type: AlertType.success,
        element: /* @__PURE__ */ React__default.createElement(Trans, {
          i18nKey: "AccountDeletionNoticePage.cancelAccountDeletionSuccess"
        }, "The account deletion process has been cancelled. Please log in to continue."),
        autoDismiss: true
      });
      this.props.appState.clear();
    };
    this.notifyCancelAccountDeletionError = (error) => {
      this.setState({
        alert: {
          type: AlertType.danger,
          element: /* @__PURE__ */ React__default.createElement(CommonError, {
            error
          })
        }
      });
    };
    this.cancelDeletion = async () => {
      const { user } = this.props.appState.getUserManager().state;
      if (!user)
        return;
      try {
        await this.logic.cancelDeleteAccount(user.userId);
        this.notifyCancelAccountDeletionSuccess();
        await this.props.appState.logout();
      } catch (error) {
        this.notifyCancelAccountDeletionError(error);
      }
    };
    this.continueDeletion = async () => {
      await this.props.appState.logout();
    };
    this.logic = this.props.appState.getGdprManager();
    this.logic.subscribe(() => this.setState({}));
    this.state = {
      alert: null
    };
  }
  render() {
    const { alert } = this.state;
    const { isRequestingDeletion } = this.logic.state;
    const deletionDays = 28;
    return /* @__PURE__ */ React__default.createElement("div", {
      className: "deletionNoticeContainer"
    }, /* @__PURE__ */ React__default.createElement("main", null, !!alert && !isRequestingDeletion && /* @__PURE__ */ React__default.createElement(Alert, {
      type: alert.type,
      className: "alert",
      onDismiss: () => this.setState({ alert: null })
    }, alert.element), /* @__PURE__ */ React__default.createElement("p", {
      className: "title"
    }, /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "AccountDeletionNoticePage.title"
    }, "Account deletion in-progress")), /* @__PURE__ */ React__default.createElement("div", {
      className: "content"
    }, /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "AccountDeletionNoticePage.content"
    }, "Your account will be deleted ", /* @__PURE__ */ React__default.createElement("strong", {
      className: "text-[color:rgb(var(--od-rgba-text))]"
    }, { deletionDays }, " days"), " after the day you requested for deletion. For more information, you can check your email related to the deletion request.")), /* @__PURE__ */ React__default.createElement("div", {
      className: "btnContainer"
    }, /* @__PURE__ */ React__default.createElement("button", {
      className: "btn big btnContinue",
      onClick: () => this.continueDeletion()
    }, /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "AccountDeletionNoticePage.button.keepDeleting"
    }, "Continue the Deletion")), /* @__PURE__ */ React__default.createElement("button", {
      className: "btn big btn-primary btnCancel",
      disabled: isRequestingDeletion,
      onClick: () => this.cancelDeletion()
    }, isRequestingDeletion && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(Spinner, {
      className: `${SpinnerStyle.inline} spinner`
    }), /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "AccountDeletionNoticePage.form.processing"
    }, "Processing...")), !isRequestingDeletion && /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "AccountDeletionNoticePage.button.cancelDeletion"
    }, "Cancel Deletion")))));
  }
}
export { AccountDeletionNoticePage as default };
