Mypage.js 3.26 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
7
import catchErrors from '../utils/catchErrors';
import { isAuthenticated } from '../utils/auth'
박상호's avatar
0106    
박상호 committed
8

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

function Mypage() {
박상호's avatar
123    
박상호 committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

  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])


박상호's avatar
1    
박상호 committed
35
  return (
박상호's avatar
1247    
박상호 committed
36
    <Container className="px-3">
박상호's avatar
647    
박상호 committed
37
      <h3 className="my-4 mx-3 font-weight-bold">My Page</h3>
박상호's avatar
1111    
박상호 committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
      <Card md={3} className="pt-3 mb-4" style={{ background: '#F7F3F3' }}>
        <Row>
          <Col md={4} className="text-center">
            <Image src={person} roundedCircle className="img-thumbnail" width={"170rem"} />
          </Col>
          <Col>
            <Row className="mt-4 text-center">
              <Col>
                <h2>
                  <strong>@Login.user</strong> <small>님</small>
                </h2>
              </Col>
            </Row>
            <Row className="px-3">
              <Card.Body className="text-center">
박상호's avatar
1247    
박상호 committed
53
54
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>
                  {/* 홈페이지로 돌아가기 */}
                   오신 <em>@Login.user</em> 님,<br></br>
                진심으로 환영합니다! 즐거운 쇼핑 되세요.</h4>
박상호's avatar
1111    
박상호 committed
62
                <Row className="mr-1 text-muted d-flex justify-content-end">
박상호's avatar
1247    
박상호 committed
63
64
65
66
                  <a href="mailto:shoppingmall_KU@korea.ac.kr">
                    <small title="메일보내기"> 문의 : shoppingmall_KU@korea.ac.kr </small>
                  </a>
                  {/* 쇼핑몰 문의 메일보내기 */}
박상호's avatar
1111    
박상호 committed
67
68
69
70
                </Row>
              </Card.Body>
            </Row>
          </Col>
박상호's avatar
647    
박상호 committed
71
        </Row>
박상호's avatar
1111    
박상호 committed
72
      </Card>
박상호's avatar
1247    
박상호 committed
73
74
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
      <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
102
103
104
105

    </Container >

  )
박상호's avatar
0106    
박상호 committed
106
107
108
109
110

}



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