import Input from '@/components/Input' import { Button } from '@/components/ui/button' import React from 'react' import { useAuthStore } from '../store/AuthStore'; import { useAuthentication } from '../hooks/useAuthData'; import { AuthenticationType } from '../types/Types'; import { useForm } from 'react-hook-form'; import * as yup from "yup" import { yupResolver } from "@hookform/resolvers/yup" import { toast } from '@/components/Toast'; import { extractErrorMessage } from '@/helpers/errorUtils'; import LoginStep2 from './LoginStep2'; const LoginStep1 = () => { const { step, setStep, setPhone } = useAuthStore(); const { mutate: authentication, isPending } = useAuthentication(); const validationSchema = yup .object({ phone: yup.string().required('شماره تلفن خود را وارد کنید'), }) .required() const { register, handleSubmit, watch, formState: { errors }, } = useForm({ resolver: yupResolver(validationSchema), }) const onSubmit = (data: AuthenticationType) => { authentication(data, { onSuccess: () => { toast("کد با موفقیت ارسال شد", "success") setPhone(watch("phone")) setStep(2) }, onError: (error: Error) => { toast(extractErrorMessage(error), 'error') } }) } if (step === 2) { return ( ) } return (
ورود و ثبت نام
) } export default LoginStep1