import axios from "axios"; import { useEffect, useState } from "react"; import userApi from "../apis/user.api"; const INIT_USER = { name: "", idNumber1: "", idNumber2: "", email: "", password: "", checkpw: "", phone: "", }; const Signup = () => { const [user, setUser] = useState(INIT_USER); const [error, setError] = useState(""); const [disabled, setDisabled] = useState(false); const [success, setSuccess] = useState(false); useEffect(() => { setDisabled( !( user.name && user.idNumber1 && user.idNumber2 && user.email && user.password && user.checkpw ) ); }, [user]); function handleChange(event) { const { name, value } = event.target; setUser({ ...user, [name]: value }); // console.log(user); } async function handleSubmit() { try { const data = await userApi.signup(user) setLoading(true); setError(""); // const success = await login(user.email, user.password); console.log(data); setSuccess(success); } catch (error) { // catchErrors(error, setError); } finally { setLoading(false); } } if (success) { alert('회원가입 되었습니다.') } const { name, idNumber1, idNumber2, id, password, checkpw, phone } = user; return (
회원가입
* * * * * *
{console.log(disabled)}
); }; export default Signup;