import { Button, Flex, Form, Result, Space, Typography } from "antd"; import { useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; import { Constants, EncodeStringToBase64, myFetch, setUserSessionToLocalStorage, showInputsInvalidNotification, showUnkownErrorNotification, } from "../../utils"; import { MyLanguageSwitch, MyRecaptcha, PendingEmailVerification, PrivacyPolicyCheckbox, RememberMeCheckbox, } from "."; import { MyEmailFormInput, MyPasswordFormInput, } from "../../Components/MyFormInputs"; const LoginStep = { LOGIN: 1, PENDING_DELETION: 2, INIT_LOGIN: 3, BANNED: 4, _BACK_TO_PASSWORD: 5, // needed for going back from pending deletion to password step as the useEffect for the account name is triggered and would set the step to account name PENDING_EMAIL_VERIFICATION: 6, INIT_PAYMENT: 7, }; // First step: account name -> get state of account by backend // Second step: if account is active -> password -> login otherwise show the state of the account (e. g. deleted, banned) export function Login({ notificationApi }) { const { t } = useTranslation(); const navigate = useNavigate(); const [step, setStep] = useState(LoginStep.LOGIN); const [isRequesting, setIsRequesting] = useState(false); const recaptchaRef = useRef(null); const recaptchaValueRef = useRef(null); const [form] = Form.useForm(); // const email = Form.useWatch("email", form); const showErrorNotification = (errStatus) => { if (errStatus === 400) { notificationApi["error"]({ message: t("authentication.login.request.400.title"), description: t("authentication.login.request.400.description"), }); } }; /* useEffect(() => { if (!email) return; // triggered if step was set to pending deletion and the user wants to reactivate the account if (step === LoginStep._BACK_TO_PASSWORD) { setStep(LoginStep.LOGIN); return; } // reset step if account name changed for handling the state of the account if (step === LoginStep.LOGIN || step === LoginStep.INIT_LOGIN) { setStep(LoginStep.ACCOUNT_NAME); } }, [email]); */ if (step === LoginStep.PENDING_DELETION) { return ( setStep(LoginStep.LOGIN)}> {t("common.button.cancel")} , , ]} /> ); } if (step === LoginStep.BANNED) { return ( {t("authentication.login.stateAccountBanned.infoSupport")} } extra={[ , ]} /> ); } if (step === LoginStep.PENDING_EMAIL_VERIFICATION) { return ; } if (step === LoginStep.INIT_PAYMENT) { return ( ); } return (
{step === LoginStep.INIT_LOGIN && ( {t("authentication.login.stateInitLogin.info")} )} {t("authentication.login.dontHaveAccount")}{" "} ); } const FORGOT_PASSWORD_STEP = { ENTER_EMAIL: 1, RESET_LINK_SENT: 2, }; export function ForgotPassword({ notificationApi }) { const { t } = useTranslation(); const [form] = Form.useForm(); const navigate = useNavigate(); const [step, setStep] = useState(FORGOT_PASSWORD_STEP.ENTER_EMAIL); const [isRequesting, setIsRequesting] = useState(false); const recaptchaValueRef = useRef(null); if (step === FORGOT_PASSWORD_STEP.RESET_LINK_SENT) { return ( ); } return (
{t("authentication.forgotPassword.title")} {t("authentication.forgotPassword.info")} ); }