import { useState } from 'react'; import { Redirect } from "react-router-dom"; import { Formik } from 'formik'; import * as Yup from 'yup'; import authApi from '../../apis/auth.api'; import catchErrors from "../../utils/catchErrors"; import styles from "./form.module.scss"; const SignupForm = () => { const [success, setSuccess] = useState(false); const [error, setError] = useState(""); if (success) { return ; } return ( <>

회원가입

{ try { setError("") const result = await authApi.signup(values) // console.log('회원가입 요청 후 result 확인', result, '|', result.status) if (result.status === 201) { alert("회원가입이 완료되었습니다.") setSuccess(true) } } catch (error) { catchErrors(error, setError) resetForm(); } setTimeout(() => { setSubmitting(false); }, 400); }} > {formik => (
{formik.touched.userId && formik.errors.userId ? (
{formik.errors.userId}
) : null}
{formik.touched.password && formik.errors.password ? (
{formik.errors.password}
) : null}
{formik.touched.repassword && formik.errors.repassword ? (
{formik.errors.repassword}
) : null}
{formik.touched.userName && formik.errors.userName ? (
{formik.errors.userName}
) : null}
{formik.touched.userStudNum && formik.errors.userStudNum ? (
{formik.errors.userStudNum}
) : null}
)}
); } export default SignupForm;