Commit 98bc3e3a authored by 이재연's avatar 이재연
Browse files

ㅇㅇㅇㅇㅇ

parent a645a94a
......@@ -2,6 +2,7 @@ import React, { useState } from 'react';
import axios from 'axios'
import { Form, Col, Container, Button, Row, Alert } from 'react-bootstrap'
import catchErrors from '../utils/catchErrors'
import { Redirect } from 'react-router-dom';
const INIT_USER = {
name: '',
......@@ -15,8 +16,8 @@ const INIT_USER = {
function Signup() {
const [user, setUser] = useState(true)
const [error, setError] = useState('')
const [validated, setValidated] = useState(false);
const [success, setSuccess] = useState(false)
const [validated, setValidated] = useState(false);
function handleChange(event) {
const { name, value } = event.target
......@@ -39,30 +40,35 @@ const [validated, setValidated] = useState(false);
setError('')
const response = await axios.post('/api/users/signup', user)
console.log(response.data)
setSuccess(true)
} catch (error) {
catchErrors(error, setError)
}
}
}
function checkPassword(event){
const p1=user.password
const p2=user.password2
function checkPassword(event) {
const p1 = user.password
const p2 = user.password2
if(p1 !== p2){
if (p1 !== p2) {
event.preventDefault();
event.stopPropagation();
alert('비밀번호가 일치하지 않습니다.')
return false
}else{
} else {
return true
}
}
if (success) {
alert('회원가입 되었습니다.')
return <Redirect to='/login'/>
}
return (
return (
<div>
<Container className="my-5">
......@@ -186,7 +192,7 @@ const [validated, setValidated] = useState(false);
</Row>
</Container>
</div>
)
)
}
export default Signup
\ No newline at end of file
node_modules
package-lock.json
uploads/
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment