Info.js 1.59 KB
Newer Older
이재연's avatar
aa    
이재연 committed
1
import userApi from "../../apis/user.api";
이재연's avatar
오잉    
이재연 committed
2
import { useEffect, useState } from "react";
이재연's avatar
aa    
이재연 committed
3

이재연's avatar
오잉    
이재연 committed
4
5
6
7
8
9
10
const userprofile = localStorage.getItem("user");
const INIT_PROFILE = {
  name: "",
  email: "a",
  id: "",
  phone: "",
};
이재연's avatar
aa    
이재연 committed
11

이재연's avatar
오잉    
이재연 committed
12
13
const Info = () => {
  const [profile, setProfile] = useState(INIT_PROFILE);
이재연's avatar
aa    
이재연 committed
14

이재연's avatar
오잉    
이재연 committed
15
16
17
18
19
20
21
22
23
24
  async function getProfile(userID) {
    try {
      const data = await userApi.getUser({id:userID});
      setProfile(data);
      console.log(data)
    } catch (error) {}
  }
  useEffect(() => {
    getProfile(userprofile);
  }, [userprofile]);
이재연's avatar
이재연 committed
25
26

  return (
이재연's avatar
오잉    
이재연 committed
27
    
이재연's avatar
이재연 committed
28
    <div className="container" style={{ background: "#FCF4FF" }}>
이재연's avatar
오잉    
이재연 committed
29
      
이재연's avatar
이재연 committed
30
      <div
이재연's avatar
이재연 committed
31
        className="row justify-content-center  my-4"
이재연's avatar
이재연 committed
32
33
        style={{ fontSize: "25px", fontWeight: "bold" }}
      >
이재연's avatar
오잉    
이재연 committed
34
        {profile.email} #{profile.id}
이재연's avatar
이재연 committed
35
36
37
      </div>
      <div className="row">
        <div className="col-3"></div>
이재연's avatar
이재연 committed
38
        <div className="col-6 my-2">
이재연's avatar
이재연 committed
39
40
41
          <h2 className="mb-3" style={{ fontSize: "13px", fontWeight: "bold" }}>
            이름
          </h2>
이재연's avatar
오잉    
이재연 committed
42
43
44
45
46
47
          <h2
            className="mb-4 mt-2"
            style={{ fontSize: "25px", fontWeight: "bold" }}
          >
            {profile.name}
          </h2>
이재연's avatar
이재연 committed
48
49
50
51
52
53
          <h2
            className="mb-3 mt-2"
            style={{ fontSize: "13px", fontWeight: "bold" }}
          >
            전화번호
          </h2>
이재연's avatar
오잉    
이재연 committed
54
55
56
57
58
59
          <h2
            className="mb-3 mt-2"
            style={{ fontSize: "25px", fontWeight: "bold" }}
          >
            {profile.phone}
          </h2>
Kim, Chaerin's avatar
Kim, Chaerin committed
60
        </div>
이재연's avatar
이재연 committed
61
62
63
64
        <div className="col"></div>
      </div>
    </div>
  );
Kim, Chaerin's avatar
Kim, Chaerin committed
65
66
67
};

export default Info;