Commit 7498fb19 authored by 박상호's avatar 박상호 🎼
Browse files

123

parent 8a73dfb2
......@@ -7,4 +7,13 @@ export function signIn({id,password}){
const user=users.find(user=>user.id===id && user.password===password);
if (user===undefined) throw new Error();
return user;
}
export function isAuthenticated(){
const userId = localStorage.getItem("loginStatus")
if (userId) {
return userId
} else {
return false
}
}
\ No newline at end of file
import React from 'react'
import React, { useEffect, useState } from 'react'
import { Card, Image, Container, Row, Col, Table, Accordion } from 'react-bootstrap'
import { Link } from 'react-router-dom';
import person from '../person.svg';
import mypagetiger from '../mypagetiger.svg';
import catchErrors from '../utils/catchErrors';
import { isAuthenticated } from '../utils/auth'
const INIT_PROFILE = {
name: "",
tel: ""
}
function Mypage() {
const [profile, setProfile] = useState(INIT_PROFILE)
const [error, setError] = useState("")
const user = isAuthenticated()
async function getProfile(user) {
try {
const response = await axios.get(`/api/users/profile/${user}`)
setProfile(response, data)
} catch (error) {
catchErrors(error, setError)
}
}
useEffect(() => {
getProfile(user)
}, [user])
return (
<Container className="px-3">
<h3 className="my-4 mx-3 font-weight-bold">My Page</h3>
......
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