import React, { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import ListCard from '../Components/ListCard'; import axios from 'axios'; import catchError from '../utils/catchErrors'; import { isAuthenticated } from '../utils/auth'; import { Card, Image, Container, Row, Col, Button, Form, Modal } from 'react-bootstrap'; const INIT_ACCOUNT = { name: "", avatarUrl: '' } function Account() { const [account, setAccount] = useState(INIT_ACCOUNT) const [show, setShow] = useState(false); const [proshow, setProshow] = useState(false) const [error, setError] = useState("") const userId = isAuthenticated() const [ordered, setOrdered] = useState([]) async function getUsername(user) { try { setError('') const response = await axios.get(`/api/users/account/${user}`) setAccount(response.data) } catch (error) { catchError(error, setError) } } useEffect(() => { getUsername(userId) getOrdered() }, [userId]) const handleChange = (event) => { const { name, value, files } = event.target if (files) { setAccount({ ...account, [name]: files }) } else { setAccount({ ...account, [name]: value }) } } const handleBasic = async () => { const formData = new FormData() formData.append('avatar', '') try { if (userId) { const response = await axios.put(`/api/users/account/${userId}`, formData) window.location.reload() } } catch (error) { catchError(error, setError) } setShow(false) } const handleSubmit = async (event) => { event.preventDefault() if (account.avatar) { const formData = new FormData() formData.append('avatar', account.avatar[0]) try { setError('') if (userId) { const response = await axios.put(`/api/users/account/${userId}`, formData) window.location.reload() } } catch (error) { catchError(error, setError) } } else { alert("파일을 선택해주세요.") } } async function getOrdered() { try { setError('') const response = await axios.post(`/api/users/addorder`, { userId: userId }) const res = response.data setOrdered(res) } catch (error) { catchError(error, setError) } } return (

My Page

setShow(false)}> 이미지를 변경하시겠습니까?

setProshow(true)}> {account.name} setProshow(false)}> 회원정보
  • Role : {account.role}
  • ID : {account.id}
  • Username : {account.name}
  • Email : {account.email}
  • Tel : {account.tel}
  • {' '}({account.id}){" "}님

    KU# 를 방문해주신 {account.name} 님,
    진심으로 환영합니다! 즐거운 쇼핑 되세요.

    * 문의 : shoppingmall_KU@korea.ac.kr
    ) } export default Account