import React, { useState, useEffect, useRef } from 'react'; import { Redirect } from 'react-router-dom'; import Nav1 from '../Components/MainNav'; import Nav2 from '../Components/SubNav'; import { Form, Col, Container, Button, Row, Alert } from 'react-bootstrap' import FormCheckInput from 'react-bootstrap/esm/FormCheckInput'; const INIT_USER = { name: '', number: '', id: '', password: '', password2: '', tel: '' } function Signup() { const [user, setUser] = useState(true) //const [disabled, setDisabled] = useState(true) const [error, setError] = useState('') //useEffect(() => { // const isUser = Object.values(user).every(el => Boolean(el)) // isUser ? setDisabled(false) : setDisabled(true) //}, user) function handleChange(event) { const { name, value } = event.target setUser({ ...user, [name]: value }) } const [validated, setValidated] = useState(false); async function handleSubmit(event) { event.preventDefault() const form = event.currentTarget; console.log(form) if (form.checkValidity() === false) { event.preventDefault(); event.stopPropagation(); } setValidated(true); console.log(user) try { setError('') const response = await fetch('/signup', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(user) }) const data = await response.json() console.log(data) } catch (error) { console.log(error) setError('다시 시도하세요.') } } return (