extract message
This commit is contained in:
@@ -13,6 +13,7 @@ import { useOtpRequest } from '@/app/auth/login/hooks/useAuthData'
|
||||
import { useParams } from 'next/navigation'
|
||||
import { toast } from '@/components/Toast'
|
||||
import StepOtp from './StepOtp'
|
||||
import { extractErrorMessage } from '@/lib/func'
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +23,7 @@ function StepEnterNumber() {
|
||||
const { name } = useParams()
|
||||
const [step, setStep] = useState(AUTH_STEP.ENTER_NUMBER)
|
||||
|
||||
const { mutate: mutateOtpRequest } = useOtpRequest()
|
||||
const { mutate: mutateOtpRequest, isPending } = useOtpRequest()
|
||||
|
||||
const formik = useFormik<LoginOTPRequestType>({
|
||||
initialValues: {
|
||||
@@ -35,15 +36,13 @@ function StepEnterNumber() {
|
||||
onSubmit: (values) => {
|
||||
if (name) {
|
||||
values.slug = name as string
|
||||
values.phone = 'qtest'
|
||||
mutateOtpRequest(values, {
|
||||
onSuccess: () => {
|
||||
toast(t('auth.otp_sent'))
|
||||
setStep(AUTH_STEP.ENTER_OTP)
|
||||
},
|
||||
onError: (error) => {
|
||||
// toast(t('auth.otp_sent_error'))
|
||||
console.log(error);
|
||||
toast(extractErrorMessage(error), 'error')
|
||||
|
||||
}
|
||||
})
|
||||
@@ -100,7 +99,7 @@ function StepEnterNumber() {
|
||||
</div>
|
||||
<Button
|
||||
disabled={!formik.isValid}
|
||||
pending={false}
|
||||
pending={isPending}
|
||||
type='button'
|
||||
onClick={() => formik.handleSubmit()}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user