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

menu, loginpage 수정

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