import {UserOutlined} from "@ant-design/icons"; import {Button, Form, Input} from "antd"; import i18next from "i18next"; import React, {useEffect} from "react"; import {CountryCodeSelect} from "../../common/select/CountryCodeSelect"; import {SendCodeInput} from "../../common/SendCodeInput"; import * as Setting from "../../Setting"; import {EmailMfaType, SmsMfaType} from "../MfaSetupPage"; import {mfaAuth} from "./MfaVerifyForm"; export const MfaVerifySmsForm = ({mfaProps, application, onFinish, method, user}) => { const [dest, setDest] = React.useState(""); const [form] = Form.useForm(); useEffect(() => { if (method === mfaAuth) { setDest(mfaProps.secret); return; } if (mfaProps.mfaType === SmsMfaType) { setDest(user.phone); return; } if (mfaProps.mfaType === EmailMfaType) { setDest(user.email); } }, [mfaProps.mfaType]); const isShowText = () => { if (method === mfaAuth) { return true; } if (mfaProps.mfaType === SmsMfaType && user.phone !== "") { return true; } if (mfaProps.mfaType === EmailMfaType && user.email !== "") { return true; } return false; }; const isEmail = () => { return mfaProps.mfaType === EmailMfaType; }; return (
{isShowText() ?
{isEmail() ? i18next.t("mfa:Your email is") : i18next.t("mfa:Your phone is")} {dest}
: (

{isEmail() ? i18next.t("mfa:Please bind your email first, the system will automatically uses the mail for multi-factor authentication") : i18next.t("mfa:Please bind your phone first, the system automatically uses the phone for multi-factor authentication")}

{isEmail() ? null : } {setDest(e.target.value);}} prefix={} placeholder={isEmail() ? i18next.t("general:Email") : i18next.t("general:Phone")} />
) }
); }; export default MfaVerifySmsForm;