import { yupResolver } from "@hookform/resolvers/yup"; import { Box, Button, Stack, Typography } from "@mui/material"; import { HasChildren } from "@types"; import { FormProvider, RHFAutoComplete, RHFTextField, } from "components/hook-form"; import { AutoCompleteOption, AutoCompleteOptionType, getValue, } from "components/hook-form/RHFAutoComplete"; import { useState } from "react"; import { useForm } from "react-hook-form"; import * as Yup from "yup"; type AreaBoxProps = { title: string; } & HasChildren; function AreaBox({ title, children }: AreaBoxProps) { return ( {title} {children} ); } type FormProps = { address: string; }; type Props = { onNext?: VoidFunction; onPrev?: VoidFunction; }; export default function useInputSMSSendAddress({ onNext, onPrev }: Props) { const form = useForm({ defaultValues: { address: "", }, resolver: yupResolver( Yup.object().shape({ address: Yup.string() .required("必須項目です") .matches(/^[0-9]{11}$/, "正しい電話番号を入力してください"), }) ), }); const handleSubmit = () => { if (onNext) { onNext(); } }; const handlePrev = () => { if (onPrev) { onPrev(); } }; const element = ( ); return { element, values: form.getValues }; }