import React, { useState } from 'react'; import axios from 'axios' import { Form, Col, Container, Button, Row, Alert } from 'react-bootstrap' import catchErrors from '../utils/catchErrors' const INIT_USER = { name: '', number: '', id: '', password: '', password2: '', tel: '' } function Signup() { const [user, setUser] = useState('') const [error, setError] = useState('') const [validated, setValidated] = useState(false); function handleChange(event) { const { name, value } = event.target setUser({ ...user, [name]: value }) } 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 axios.post('/api/users/signup', user) console.log(response.data) } catch (error) { catchErrors(error, setError) } } function checkPassword(event) { const p1 = user.password const p2 = user.password2 if (p1 !== p2) { event.preventDefault(); event.stopPropagation(); alert('비밀번호가 일치하지 않습니다.') return false } else { return true } } return (