set otp code
This commit is contained in:
@@ -28,6 +28,7 @@ function StepEnterNumber(_props: StepEnterNumberProps = {}) {
|
|||||||
const { t } = useTranslation('auth')
|
const { t } = useTranslation('auth')
|
||||||
const { name } = useParams()
|
const { name } = useParams()
|
||||||
const [step, setStep] = useState(AUTH_STEP.ENTER_NUMBER)
|
const [step, setStep] = useState(AUTH_STEP.ENTER_NUMBER)
|
||||||
|
const [code, setCode] = useState('')
|
||||||
|
|
||||||
const { mutate: mutateOtpRequest, isPending } = useOtpRequest()
|
const { mutate: mutateOtpRequest, isPending } = useOtpRequest()
|
||||||
|
|
||||||
@@ -44,7 +45,9 @@ function StepEnterNumber(_props: StepEnterNumberProps = {}) {
|
|||||||
if (name) {
|
if (name) {
|
||||||
values.slug = name as string
|
values.slug = name as string
|
||||||
mutateOtpRequest(values, {
|
mutateOtpRequest(values, {
|
||||||
onSuccess: () => {
|
onSuccess: (data) => {
|
||||||
|
setCode(data?.data?.code)
|
||||||
|
|
||||||
toast(t('otp_sent'), 'success')
|
toast(t('otp_sent'), 'success')
|
||||||
setStep(AUTH_STEP.ENTER_OTP)
|
setStep(AUTH_STEP.ENTER_OTP)
|
||||||
},
|
},
|
||||||
@@ -101,7 +104,7 @@ function StepEnterNumber(_props: StepEnterNumberProps = {}) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{step === AUTH_STEP.ENTER_OTP && (
|
{step === AUTH_STEP.ENTER_OTP && (
|
||||||
<StepOtp phone={formik.values.phone} slug={formik.values.slug} />
|
<StepOtp phone={formik.values.phone} slug={formik.values.slug} code={code} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ import { useSearchParams } from 'next/navigation'
|
|||||||
type Props = {
|
type Props = {
|
||||||
phone: string,
|
phone: string,
|
||||||
slug: string
|
slug: string
|
||||||
|
code: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const StepOtp = ({ phone, slug }: Props) => {
|
const StepOtp = ({ phone, slug, code }: Props) => {
|
||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
const redirectUrl = searchParams.get('redirect')
|
const redirectUrl = searchParams.get('redirect')
|
||||||
const { t } = useTranslation('auth')
|
const { t } = useTranslation('auth')
|
||||||
@@ -38,7 +39,7 @@ const StepOtp = ({ phone, slug }: Props) => {
|
|||||||
const formik = useFormik<LoginVerifyOTPType>({
|
const formik = useFormik<LoginVerifyOTPType>({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
phone: phone,
|
phone: phone,
|
||||||
otp: '',
|
otp: code,
|
||||||
slug: slug
|
slug: slug
|
||||||
},
|
},
|
||||||
validationSchema: Yup.object({
|
validationSchema: Yup.object({
|
||||||
|
|||||||
Reference in New Issue
Block a user