Commit 62ff8335 authored by 박상호's avatar 박상호 🎼
Browse files

MainNav까지

parent be401a9c
...@@ -15,7 +15,9 @@ function MainNav() { ...@@ -15,7 +15,9 @@ function MainNav() {
{' '}KU# {' '}KU#
</Navbar.Brand> </Navbar.Brand>
<Nav> <Nav>
{user ? <Nav.Link className="text-light" onClick={() => handleLogout()}>Logout</Nav.Link> {user ? <> <Nav.Link className="text-light" onClick={() => handleLogout()}>Logout</Nav.Link>
<Nav.Link className="text-light" href="/account"> Mypage </Nav.Link>
</>
: ( : (
<> <>
<Nav.Link className="text-light" href='/login'>Login</Nav.Link> <Nav.Link className="text-light" href='/login'>Login</Nav.Link>
......
...@@ -2,6 +2,7 @@ import React, { useState } from 'react'; ...@@ -2,6 +2,7 @@ import React, { useState } from 'react';
import axios from 'axios' import axios from 'axios'
import { Form, Col, Container, Button, Row, Alert } from 'react-bootstrap' import { Form, Col, Container, Button, Row, Alert } from 'react-bootstrap'
import catchErrors from '../utils/catchErrors' import catchErrors from '../utils/catchErrors'
import { Redirect } from 'react-router-dom';
const INIT_USER = { const INIT_USER = {
name: '', name: '',
...@@ -15,7 +16,7 @@ const INIT_USER = { ...@@ -15,7 +16,7 @@ const INIT_USER = {
function Signup() { function Signup() {
const [user, setUser] = useState(INIT_USER) const [user, setUser] = useState(INIT_USER)
const [error, setError] = useState('') const [error, setError] = useState('')
const [success, setSuccess] = useState(false)
const [validated, setValidated] = useState(false); const [validated, setValidated] = useState(false);
function handleChange(event) { function handleChange(event) {
...@@ -39,12 +40,11 @@ function Signup() { ...@@ -39,12 +40,11 @@ function Signup() {
setError('') setError('')
const response = await axios.post('/api/users/signup', user) const response = await axios.post('/api/users/signup', user)
console.log(response.data) console.log(response.data)
setSuccess(true)
} catch (error) { } catch (error) {
catchErrors(error, setError) catchErrors(error, setError)
} }
} }
function checkPassword(event) { function checkPassword(event) {
const p1 = user.password const p1 = user.password
...@@ -60,6 +60,10 @@ function Signup() { ...@@ -60,6 +60,10 @@ function Signup() {
return true return true
} }
} }
if (success) {
alert('회원가입 되었습니다.')
return <Redirect to='/login'/>
}
return ( return (
......
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