%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/emergentqj/actioncivile/pre-auth/def/static/js/components/ForgotPassword/
Upload File :
Create Path :
Current File : /home/emergentqj/actioncivile/pre-auth/def/static/js/components/ForgotPassword/index.js

import React, { useEffect } from "react";
import PropTypes from "prop-types";
import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next";

import SendLicensePlateContainer from "containers/ForgotPassword/SendLicensePlateContainer";
import EnterPhoneFormContainer from "containers/ForgotPassword/SendPhoneContainer";
import CodeFormContainer from "containers/ForgotPassword/SendTokenContainer";
import ResetPasswordContainer from "containers/ForgotPassword/ResetPasswordContainer";
import ResetPasswordMessageContainer from "containers/ForgotPassword/ResetPasswordMessageContainer";
import { withStyles } from "@material-ui/styles";
import styles from "common/components/styles";
import { Box } from "common/components";
import { STEPS } from "reducers/resetPassword";
import CantBeVerified from "components/ForgotPassword/CantBeVerified";

const getForm = (step) => {
  switch (step) {
    case STEPS.PHONE_EMAIL_FORM:
      return <EnterPhoneFormContainer />;
    case STEPS.RECEIVED_CODE_FORM:
      return <CodeFormContainer />;
    case STEPS.RESET_PASSWORD_FORM:
      return <ResetPasswordContainer />;
    case STEPS.RESET_PASSWORD_SUCCESS:
      return <ResetPasswordMessageContainer />;
    case STEPS.LICENSE_PLATE_FORM:
      return <SendLicensePlateContainer />;
    case STEPS.CANNOT_VERIFY:
      return <CantBeVerified />;
    default:
      return null;
  }
};

function ForgotPassword({
  classes,
  step,
  resetRestoreSession,
}) {
  const [t] = useTranslation();
  const showGoBackButton = step !== STEPS.RECEIVED_CODE_FORM
    && step !== STEPS.RESET_PASSWORD_SUCCESS;

  // On unmount
  useEffect(
    () => () => resetRestoreSession(),
    [resetRestoreSession],
  );
  return (
    <div className={classes.narrowedForm}>
      {getForm(step)}
      {showGoBackButton && (
        <Box extraSpaceBefore>
          <Link to="/" className={[classes.link].join(" ")}>
            {"< "}
            {t("auth.login.backToLogin")}
          </Link>
        </Box>
      )}
    </div>
  );
}

ForgotPassword.propTypes = {
  classes: PropTypes.object.isRequired,
  step: PropTypes.string,
  resetRestoreSession: PropTypes.func.isRequired,
};

ForgotPassword.defaultProps = {
  step: STEPS.PHONE_EMAIL_FORM,
};

export default withStyles(styles)(ForgotPassword);

Zerion Mini Shell 1.0