Commit aa88e353 authored by 우지원's avatar 우지원
Browse files

menu, loginpage 수정

parent 7566e570
...@@ -3,23 +3,18 @@ import React, { useState, useEffect } from 'react'; ...@@ -3,23 +3,18 @@ import React, { useState, useEffect } from 'react';
import { Navbar, Nav, Button } from 'react-bootstrap'; import { Navbar, Nav, Button } from 'react-bootstrap';
import { handleLogout, isAuthenticated } from '../utils/auth'; import { handleLogout, isAuthenticated } from '../utils/auth';
const INIT_USER = {
username: ''
}
function Menu() { function Menu() {
const user = isAuthenticated() const user = isAuthenticated()
const [userName, setUsername] = useState(INIT_USER) const [userName, setUsername] = useState('')
async function getLoginedUser() { async function getLoginedUser() {
const userId = localStorage.getItem('user') const userId = localStorage.getItem('user')
const response = await axios.get(`/users/${userId}`) const response = await axios.get(`/users/${userId}`)
console.log(response.data.username) console.log(response.data.username)
const resName = response.data.username const resName = response.data.username
//const resName = JSON.stringify(response.data.username)
// const resName = JSON.stringify(response.data.username) console.log(resName)
// console.log(resName)
setUsername(resName) setUsername(resName)
} }
console.log(userName) console.log(userName)
......
...@@ -12,7 +12,7 @@ const INIT_USER = { ...@@ -12,7 +12,7 @@ const INIT_USER = {
} }
function LogIn() { function LogIn() {
const [validated, setValidated] = useState(false); //const [validated, setValidated] = useState(false);
const [user, setUser] = useState(INIT_USER) const [user, setUser] = useState(INIT_USER)
//로딩, 에러, diserved 상태 넣어야됨. //로딩, 에러, diserved 상태 넣어야됨.
const [disabled, setDisabled] = useState(true) const [disabled, setDisabled] = useState(true)
...@@ -73,7 +73,7 @@ function LogIn() { ...@@ -73,7 +73,7 @@ function LogIn() {
<> <>
<Menu /> <Menu />
<Form noValidate validated={validated} onSubmit={handleSubmit} className='vh-100 flex-column align-items-center justify-content-center mt-2'> <Form onSubmit={handleSubmit} className='vh-100 flex-column align-items-center justify-content-center mt-2'>
<Container className="d-flex justify-content-center"> <Container className="d-flex justify-content-center">
<div className="mt-5 p-5 shadow w-75"> <div className="mt-5 p-5 shadow w-75">
......
...@@ -4,6 +4,7 @@ import axios from "axios" ...@@ -4,6 +4,7 @@ import axios from "axios"
export function handleLogin(userId) { export function handleLogin(userId) {
localStorage.setItem('user', userId) localStorage.setItem('user', userId)
} }
export async function handleLogout() { export async function handleLogout() {
localStorage.removeItem('user') localStorage.removeItem('user')
await axios.get('/auth/logout') await axios.get('/auth/logout')
......
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