82 lines
2.4 KiB
TypeScript
82 lines
2.4 KiB
TypeScript
import { FC } from 'react'
|
|
import Input from '../../../components/Input'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { LoginType } from '../types/AuthTypes'
|
|
import { useFormik } from 'formik'
|
|
import * as Yup from 'yup'
|
|
import { useAuthStore } from '../../store/AuthStore'
|
|
import Error from '../../../components/Error'
|
|
import Button from '../../../components/Button'
|
|
import { Link } from 'react-router-dom'
|
|
import { Pages } from '../../../config/Pages'
|
|
|
|
const LoginStep1: FC = () => {
|
|
|
|
const { t } = useTranslation('global')
|
|
const { setPhone, phone, setStepLogin } = useAuthStore()
|
|
|
|
const formik = useFormik<LoginType>({
|
|
initialValues: {
|
|
phone_email: phone,
|
|
},
|
|
validationSchema: Yup.object({
|
|
phone_email: Yup.string()
|
|
.required(t('errors.required'))
|
|
}),
|
|
onSubmit(values) {
|
|
setPhone(values.phone_email)
|
|
setStepLogin(2)
|
|
},
|
|
})
|
|
|
|
return (
|
|
<div>
|
|
<div className='mt-5'>
|
|
<h2 className='text-2xl font-bold'>
|
|
{t('auth.welcome')}
|
|
</h2>
|
|
<p className='text-description text-sm mt-2'>
|
|
{t('auth.enter_info_login')}
|
|
</p>
|
|
</div>
|
|
|
|
<div className='mt-16'>
|
|
<Input
|
|
label={t('auth.mobile_or_email')}
|
|
placeholder={t('auth.enter_mobile_or_email')}
|
|
type='text'
|
|
className='text-right'
|
|
name='phone_email'
|
|
onChange={formik.handleChange}
|
|
value={formik.values.phone_email}
|
|
/>
|
|
|
|
{
|
|
formik.touched.phone_email && formik.errors.phone_email &&
|
|
<Error
|
|
errorText={formik.errors.phone_email}
|
|
/>
|
|
}
|
|
|
|
</div>
|
|
|
|
|
|
<Button
|
|
label={t('auth.next')}
|
|
className='mt-8'
|
|
onClick={() => formik.handleSubmit()}
|
|
/>
|
|
|
|
<div className='mt-6 flex justify-center gap-2 items-center text-sm'>
|
|
<p className='text-description'>
|
|
{t('auth.have_account')}
|
|
</p>
|
|
<Link to={Pages.auth.register}>
|
|
<div>{t('auth.register')}</div>
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default LoginStep1 |