InfoUpdate.js 5.96 KB
Newer Older
이재연's avatar
이재연 committed
1
import { Link } from "react-router-dom";
이재연's avatar
aa    
이재연 committed
2
3
4
5
6
7
8
import React, { useEffect, useState } from "react";
import userApi from "../../apis/user.api";

const INIT_PROFILE = {
  id: "",
  avatarUrl: "",
};
이재연's avatar
이재연 committed
9

Kim, Chaerin's avatar
Kim, Chaerin committed
10
const InfoUpdate = () => {
11

이재연's avatar
aa    
이재연 committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  const [profile, setProfile] = useState(INIT_PROFILE);

  
  // useEffect(()=>{
  //   setProfile()
  // },[profile])

  const handleChange = async (event) => {
    const { name, files } = event.target;
    let formData = new FormData;
    formData.append("avatarUrl", files[0]);
    const res = await userApi.profileimg(formData);
    console.log(res.img)
    console.log(res.id)
    setProfile({ ...profile, avatarUrl: res.img})
    setProfile({ ...profile, id:res.id})
    };
29

이재연's avatar
aa    
이재연 committed
30
    const{id,avatarUrl}=profile;
이재연's avatar
이재연 committed
31

이재연's avatar
이재연 committed
32
  return (
우지원's avatar
우지원 committed
33
34
    <div className="container" style={{ background: "#FCF4FF" }}>
      <div className="row">
Kim, Chaerin's avatar
Kim, Chaerin committed
35
        <div>
이재연's avatar
이재연 committed
36
          <label
우지원's avatar
우지원 committed
37
            className="form-label mx-2 my-4"
이재연's avatar
이재연 committed
38
39
40
41
            style={{ fontSize: "18px", fontWeight: "bold" }}
          >
            프로필 정보
          </label>
이재연's avatar
aa    
이재연 committed
42
          <Link to={`/profile/${profile.id}`}>
43
44
            <button
              type="button"
우지원's avatar
우지원 committed
45
              className="btn btn-outline-white "
46
              style={{
seoyeon's avatar
0726    
seoyeon committed
47
                background: "#d4cafb",
48
49
50
51
                fontSize: "13px",
                fontWeight: "bold",
              }}
            >
이재연's avatar
이재연 committed
52
              돌아가기
53
            </button>
이재연's avatar
이재연 committed
54
          </Link>
이재연's avatar
이재연 committed
55
        </div>
56
      </div>
이재연's avatar
이재연 committed
57

우지원's avatar
우지원 committed
58
      <div className="col">
Kim, Chaerin's avatar
Kim, Chaerin committed
59
        <div>
우지원's avatar
우지원 committed
60
          <div className="row">
이재연's avatar
이재연 committed
61
62
63
64
            <div
              className="d-flex justify-content-center"
              style={{ position: "relative" }}
            >
65
              <img
이재연's avatar
aa    
이재연 committed
66
                src='/user.png'
이재연's avatar
이재연 committed
67
                id="imgfile"
이재연's avatar
이재연 committed
68
                className="rounded-circle mt-2"
69
70
                style={{ height: "320px", width: "320px" }}
              />
이재연's avatar
이재연 committed
71
72
73
74
              <div
                className="d-flex justify-content-end"
                style={{ position: "absolute", left: "295px", top: "30px" }}
              >
이재연's avatar
aa    
이재연 committed
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
                  <label for="inputfile">
                    <img
                      className="rounded-circle"
                      src="/infoimg.jpg"
                      style={{
                        width: "50px",
                        height: "50px",
                        backgroundColor: "white",
                      }}
                    />
                  </label>
                  <input
                    onChange={handleChange}
                    name="avatarUrl"
                    type="file"
                    accept="image/*"
                    id="inputfile"
                    style={{ display: "none" }}
이재연's avatar
이재연 committed
93
94
                  />
              </div>
95
            </div>
이재연's avatar
이재연 committed
96

이재연's avatar
이재연 committed
97
98
99
100
101
102
103
104
105
106
107
            <div className="col d-flex justify-content-center">
              <input
                type="text"
                className="form-control my-4 "
                placeholder="사용자명 입력"
                style={{
                  background: "#fcf4ff",
                  borderTop: "0",
                  borderRight: "0",
                  borderLeft: "0",
                  borderBottom: "1",
seoyeon's avatar
0726    
seoyeon committed
108
                  borderColor: "#d4cafb",
이재연's avatar
이재연 committed
109
110
111
112
113
114
115
116
                  height: "38px",
                  width: "130px",
                }}
              />
              <div
                className="justify-content-center ms-2 my-4"
                style={{ fontSize: "25px", fontWeight: "bold" }}
              >
이재연's avatar
aa    
이재연 committed
117
                #{profile.id}
이재연's avatar
이재연 committed
118
              </div>
119
            </div>
이재연's avatar
이재연 committed
120

이재연's avatar
이재연 committed
121
            <div className="d-flex justify-content-center">
이재연's avatar
이재연 committed
122
123
              <label
                class="form-label me-3"
이재연's avatar
이재연 committed
124
125
126
127
128
                style={{
                  outline: "none",
                  fontSize: "13px",
                  fontWeight: "bold",
                }}
이재연's avatar
이재연 committed
129
130
131
132
              >
                현재 비밀번호
              </label>
              <input
이재연's avatar
aa    
이재연 committed
133
                onChange={handleChange}
이재연's avatar
이재연 committed
134
135
136
137
138
                type="text"
                class="form-control"
                style={{ height: "38px", width: "200px" }}
              />
              <button
이재연's avatar
이재연 committed
139
140
141
                type="button"
                className="btn btn-outline-white ms-2"
                style={{
seoyeon's avatar
0726    
seoyeon committed
142
                  background: "#d4cafb",
이재연's avatar
이재연 committed
143
144
145
146
147
148
                  fontSize: "13px",
                  fontWeight: "bold",
                }}
              >
                수정하기
              </button>
이재연's avatar
이재연 committed
149
            </div>
이재연's avatar
이재연 committed
150
151
            <div class="col-6">
              <div class="input-group mx-2 my-3">
152
153
154
155
156
157
158
                <div>
                  <label
                    class="form-label"
                    style={{ fontSize: "13px", fontWeight: "bold" }}
                  >
                     비밀번호
                  </label>
우지원's avatar
우지원 committed
159
                  <input type="text" className="form-control" />
160
161
162
                </div>
                <div>
                  <label
우지원's avatar
우지원 committed
163
                    className="form-label"
164
165
166
167
                    style={{ fontSize: "13px", fontWeight: "bold" }}
                  >
                     비밀번호 확인
                  </label>
우지원's avatar
우지원 committed
168
                  <input type="text" className="form-control" />
이재연's avatar
이재연 committed
169
170
                </div>
              </div>
171
            </div>
우지원's avatar
우지원 committed
172
173
            <div className="col-6">
              <div className="input-group my-3 ">
174
175
                <div>
                  <label
우지원's avatar
우지원 committed
176
                    className="form-label"
177
178
179
180
                    style={{ fontSize: "13px", fontWeight: "bold" }}
                  >
                     전화번호
                  </label>
우지원's avatar
우지원 committed
181
                  <input type="text" className="form-control" />
182
183
184
                </div>
                <div>
                  <label
우지원's avatar
우지원 committed
185
                    className="form-label"
186
187
188
189
                    style={{ fontSize: "13px", fontWeight: "bold" }}
                  >
                     전화번호 확인
                  </label>
우지원's avatar
우지원 committed
190
                  <input type="text" className="form-control" />
이재연's avatar
이재연 committed
191
192
193
194
                </div>
              </div>
            </div>
          </div>
Kim, Chaerin's avatar
Kim, Chaerin committed
195
        </div>
이재연's avatar
이재연 committed
196
      </div>
197
    </div>
이재연's avatar
이재연 committed
198
  );
Kim, Chaerin's avatar
Kim, Chaerin committed
199
200
201
};

export default InfoUpdate;