Mypage.js 3.33 KB
Newer Older
박상호's avatar
123    
박상호 committed
1
import React, { useEffect, useState } from 'react'
박상호's avatar
1247    
박상호 committed
2
3
import { Card, Image, Container, Row, Col, Table, Accordion } from 'react-bootstrap'
import { Link } from 'react-router-dom';
박상호's avatar
0106    
박상호 committed
4
import person from '../person.svg';
박상호's avatar
1247    
박상호 committed
5
import mypagetiger from '../mypagetiger.svg';
박상호's avatar
123    
박상호 committed
6
import catchErrors from '../utils/catchErrors';
박상호's avatar
qwe    
박상호 committed
7
8
import { isAuthenticated } from '../utils/Auth'
import axios from 'axios';
박상호's avatar
0106    
박상호 committed
9

박상호's avatar
123    
박상호 committed
10
11
const INIT_PROFILE = {
  name: "",
박상호's avatar
qwe    
박상호 committed
12
  avatar: "",
박상호's avatar
123    
박상호 committed
13
14
  tel: ""
}
박상호's avatar
0106    
박상호 committed
15
16

function Mypage() {
박상호's avatar
123    
박상호 committed
17
18
19
20
21
22
23
24

  const [profile, setProfile] = useState(INIT_PROFILE)
  const [error, setError] = useState("")

  const user = isAuthenticated()

  async function getProfile(user) {
    try {
박상호's avatar
qwe    
박상호 committed
25
26
      const response = await axios.get(`/api/users/Mypage/${user}`)
      setProfile(response.data)
박상호's avatar
123    
박상호 committed
27
28
29
30
31
32
33
34
35
36
    } catch (error) {
      catchErrors(error, setError)
    }
  }

  useEffect(() => {
    getProfile(user)
  }, [user])


박상호's avatar
1    
박상호 committed
37
  return (
박상호's avatar
1247    
박상호 committed
38
    <Container className="px-3">
박상호's avatar
647    
박상호 committed
39
      <h3 className="my-4 mx-3 font-weight-bold">My Page</h3>
박상호's avatar
1111    
박상호 committed
40
41
42
      <Card md={3} className="pt-3 mb-4" style={{ background: '#F7F3F3' }}>
        <Row>
          <Col md={4} className="text-center">
박상호's avatar
qwe    
박상호 committed
43
            <Image src={person && `/image/${profile.avatarUrl}`} roundedCircle className="img-thumbnail" width={"170rem"} />
박상호's avatar
1111    
박상호 committed
44
45
46
47
48
          </Col>
          <Col>
            <Row className="mt-4 text-center">
              <Col>
                <h2>
박상호's avatar
qwe    
박상호 committed
49
                  <strong>{user.name}</strong> <small>님</small>
박상호's avatar
1111    
박상호 committed
50
51
52
53
54
                </h2>
              </Col>
            </Row>
            <Row className="px-3">
              <Card.Body className="text-center">
박상호's avatar
1247    
박상호 committed
55
56
57
58
59
60
61
                <h4><Link to="/">
                  <strong title="홈으로">
                    <Image src={mypagetiger} width={"30rem"} roundedCircle className="img-thumbnail" >
                    </Image>KU#
                  </strong>
                </Link>
                  {/* 홈페이지로 돌아가기 */}
박상호's avatar
qwe    
박상호 committed
62
                   오신 <em>{user.name}</em> 님,<br></br>
박상호's avatar
1247    
박상호 committed
63
                진심으로 환영합니다! 즐거운 쇼핑 되세요.</h4>
박상호's avatar
1111    
박상호 committed
64
                <Row className="mr-1 text-muted d-flex justify-content-end">
박상호's avatar
1247    
박상호 committed
65
66
67
68
                  <a href="mailto:shoppingmall_KU@korea.ac.kr">
                    <small title="메일보내기"> 문의 : shoppingmall_KU@korea.ac.kr </small>
                  </a>
                  {/* 쇼핑몰 문의 메일보내기 */}
박상호's avatar
1111    
박상호 committed
69
70
71
72
                </Row>
              </Card.Body>
            </Row>
          </Col>
박상호's avatar
647    
박상호 committed
73
        </Row>
박상호's avatar
1111    
박상호 committed
74
      </Card>
박상호's avatar
1247    
박상호 committed
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
      <Accordion>
        <Row className="my-3 px-3">
          <Table>
            <thead className="text-center" style={{ background: '#F7F3F3' }}>
              <tr>
                <th scope="col">주문현황</th>
                <th scope="col">배송중</th>
                <th scope="col">배송완료</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <th scope="row">케이시앵글부츠(SH)</th>
                <td>Mark</td>
                <td>Otto</td>
              </tr>
              <tr>
                <th scope="row">2</th>
                <td>Jacob</td>
                <td>Thornton</td>
              </tr>
              <tr>
                <th scope="row">3</th>
                <td colspan="2">Larry the Bird</td>
              </tr>
            </tbody>
          </Table>
        </Row>
      </Accordion>
박상호's avatar
1    
박상호 committed
104
105
106
107

    </Container >

  )
박상호's avatar
0106    
박상호 committed
108
109
110
111
112

}



박상호's avatar
647    
박상호 committed
113
export default Mypage