import React, { FC, useState } from 'react' import { Button, Form, Input, message } from 'antd' import { useGuardContext } from '../../../../context/global/context' import { MFACheckPhoneFormProps } from '../../types' import './style.less' import { VALIDATE_PATTERN } from '../../../../utils' import { useTranslation } from 'react-i18next' export const CheckPhoneForm: FC = ({ onSuccess, mfaToken, }) => { const { state: { authClient }, } = useGuardContext() const { t } = useTranslation() const [rawForm] = Form.useForm() const [loading, setLoading] = useState(false) const onFinish = async ({ phone }: any) => { try { const bindable = await authClient.mfa.phoneOrEmailBindable({ mfaToken, phone, }) if (!bindable) { message.error( t('common.unBindEmaileDoc', { email: phone, }) ) return } onSuccess(phone!) } catch (e) { // do nothing } finally { setLoading(false) } } return ( <>

{t('common.bindPhone')}

{t('login.bindPhoneInfo')}

setLoading(true)} onFinish={onFinish} onFinishFailed={() => setLoading(false)} >
) }