diff --git a/src/components/forms/login-with-code-form.tsx b/src/components/forms/login-with-code-form.tsx index 3507443..b0e19a5 100644 --- a/src/components/forms/login-with-code-form.tsx +++ b/src/components/forms/login-with-code-form.tsx @@ -1,9 +1,21 @@ import { Link } from "react-router-dom" import { Input } from "../common/input" +import { Controller, SubmitHandler, useForm } from "react-hook-form" +import { LoginWithCodeInterface } from "../../types" +import { yupResolver } from "@hookform/resolvers/yup" +import { LoginWithCodeSchema } from "../../schema" +import { ErrorComponent } from "../common/error" +import { Button } from "@headlessui/react" export const LoginWithCodeForm = () => { + const { handleSubmit, formState: { errors }, control } = useForm({ + resolver: yupResolver(LoginWithCodeSchema) + }) + const handleLoginWithCode: SubmitHandler = async (data) => { + console.log("data=>", data) + } return ( -
logo
@@ -14,15 +26,20 @@ export const LoginWithCodeForm = () => {
- + ( +
+ + +
+ )} />
- +

بازگشت

- + ) } \ No newline at end of file diff --git a/src/schema/index.ts b/src/schema/index.ts index c83ff7f..ea3356d 100644 --- a/src/schema/index.ts +++ b/src/schema/index.ts @@ -24,4 +24,12 @@ export const forgotPasswordSchema = yup.object({ .min(11, "شماره تماس نمیتوند کمتر از 11 رقم باشد") .max(11, "شماره تماس نمیتواند بیشتر از 11 رقم باشد") .matches(/^[0-9]{11}$/, "شماره تماس نامعتبر"), +}) + +export const LoginWithCodeSchema = yup.object({ + phoneNumber: yup.string() + .required("وارد کردن شماره تماس الزامی میباشد") + .min(11, "شماره تماس نمیتوند کمتر از 11 رقم باشد") + .max(11, "شماره تماس نمیتواند بیشتر از 11 رقم باشد") + .matches(/^[0-9]{11}$/, "شماره تماس نامعتبر"), }) \ No newline at end of file diff --git a/src/types/index.ts b/src/types/index.ts index a3abfc2..c8fa616 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -10,4 +10,9 @@ export interface ResetPasswordInterface { export interface ForgotPasswordInterface { phoneNumber: string -} \ No newline at end of file +} + +export interface LoginWithCodeInterface { + phoneNumber: string +} +