2025-05-06 06:45:49 +00:00
|
|
|
import useAccount from '@/utils/hooks/useAccount'
|
|
|
|
|
import { Alert, Button, FormContainer, FormItem, Input } from '@/components/ui'
|
|
|
|
|
import { Field, Form, Formik } from 'formik'
|
|
|
|
|
import * as Yup from 'yup'
|
|
|
|
|
import { ActionLink } from '@/components/shared'
|
2025-06-28 21:34:28 +00:00
|
|
|
import { ROUTES_ENUM } from '@/routes/route.constant'
|
2025-05-06 06:45:49 +00:00
|
|
|
import { store } from '@/store'
|
|
|
|
|
import Captcha from '@/components/shared/Captcha'
|
2025-05-29 07:56:27 +00:00
|
|
|
import { useLocalization } from '@/utils/hooks/useLocalization'
|
2025-08-14 07:10:56 +00:00
|
|
|
import { Helmet } from 'react-helmet'
|
2025-05-06 06:45:49 +00:00
|
|
|
|
|
|
|
|
type FormSchema = {
|
|
|
|
|
email: string
|
|
|
|
|
captchaResponse: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const validationSchema = Yup.object().shape({
|
2025-05-29 07:56:27 +00:00
|
|
|
email: Yup.string().required(),
|
2025-05-06 06:45:49 +00:00
|
|
|
captchaResponse: Yup.string().required(),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const SendConfirmationCode = () => {
|
|
|
|
|
const { userName } = store.getState().auth.user
|
2025-05-29 07:56:27 +00:00
|
|
|
const { translate } = useLocalization()
|
2025-05-06 06:45:49 +00:00
|
|
|
|
|
|
|
|
const { message, error, sendConfirmationCode } = useAccount()
|
|
|
|
|
|
|
|
|
|
const onSubmit = async (values: FormSchema, setSubmitting: (isSubmitting: boolean) => void) => {
|
|
|
|
|
setSubmitting(true)
|
|
|
|
|
|
|
|
|
|
await sendConfirmationCode(values)
|
|
|
|
|
|
|
|
|
|
setSubmitting(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2025-08-14 07:10:56 +00:00
|
|
|
<Helmet
|
2025-09-13 11:46:34 +00:00
|
|
|
titleTemplate="%s | Sözsoft Kurs Platform"
|
2025-08-14 07:10:56 +00:00
|
|
|
title={translate('::' + 'Abp.Account.SendConfirmationCode')}
|
2025-09-13 11:46:34 +00:00
|
|
|
defaultTitle="Sözsoft Kurs Platform"
|
2025-08-14 07:10:56 +00:00
|
|
|
></Helmet>
|
|
|
|
|
|
2025-05-06 06:45:49 +00:00
|
|
|
<div className="mb-8">
|
2025-05-29 07:56:27 +00:00
|
|
|
<h3 className="mb-1">{translate('::Abp.Account.SendConfirmationCode')}</h3>
|
|
|
|
|
<p>{translate('::Abp.Account.SendConfirmationCode.Message')}</p>
|
2025-05-06 06:45:49 +00:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
{message && (
|
|
|
|
|
<Alert showIcon className="mb-4" type="success">
|
|
|
|
|
{message}
|
|
|
|
|
</Alert>
|
|
|
|
|
)}
|
|
|
|
|
{error && (
|
|
|
|
|
<Alert showIcon className="mb-4" type="danger">
|
|
|
|
|
{error}
|
|
|
|
|
</Alert>
|
|
|
|
|
)}
|
|
|
|
|
<Formik
|
|
|
|
|
initialValues={{
|
|
|
|
|
email: userName,
|
|
|
|
|
captchaResponse: '',
|
|
|
|
|
}}
|
|
|
|
|
validationSchema={validationSchema}
|
|
|
|
|
onSubmit={(values, { setSubmitting }) => {
|
|
|
|
|
onSubmit(values, setSubmitting)
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{({ touched, errors, isSubmitting, setFieldValue }) => (
|
|
|
|
|
<Form>
|
|
|
|
|
<FormContainer>
|
|
|
|
|
<FormItem
|
2025-05-29 07:56:27 +00:00
|
|
|
label={translate('::Abp.Account.EmailAddress')}
|
2025-05-06 06:45:49 +00:00
|
|
|
invalid={errors.email && touched.email}
|
|
|
|
|
errorMessage={errors.email}
|
|
|
|
|
>
|
|
|
|
|
<Field
|
|
|
|
|
type="email"
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
name="email"
|
2025-05-29 07:56:27 +00:00
|
|
|
placeholder={translate('::Abp.Account.EmailAddress')}
|
2025-05-06 06:45:49 +00:00
|
|
|
component={Input}
|
|
|
|
|
/>
|
|
|
|
|
</FormItem>
|
|
|
|
|
<Captcha
|
|
|
|
|
onError={() => setFieldValue('captchaResponse', '')}
|
|
|
|
|
onExpire={() => setFieldValue('captchaResponse', '')}
|
|
|
|
|
onSuccess={(token: string) => setFieldValue('captchaResponse', token)}
|
|
|
|
|
/>
|
|
|
|
|
<Button block loading={isSubmitting} variant="solid" type="submit">
|
|
|
|
|
{isSubmitting ? 'Sending code...' : 'Send Code'}
|
|
|
|
|
</Button>
|
|
|
|
|
<div className="mt-4 text-center">
|
2025-05-29 07:56:27 +00:00
|
|
|
<span>{translate('::Abp.Account.Backto')} </span>
|
2025-08-14 07:10:56 +00:00
|
|
|
<ActionLink to={ROUTES_ENUM.authenticated.login}>
|
|
|
|
|
{translate('::Abp.Account.SignIn')}
|
|
|
|
|
</ActionLink>
|
2025-05-06 06:45:49 +00:00
|
|
|
</div>
|
|
|
|
|
</FormContainer>
|
|
|
|
|
</Form>
|
|
|
|
|
)}
|
|
|
|
|
</Formik>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default SendConfirmationCode
|