MyInfo.js 1.06 KB
Newer Older
한규민's avatar
한규민 committed
1
2
3
4
5
6
7
import styles from "./my-info.module.scss";
import { useAuth } from "../../context/auth_context";
import { useState, useEffect } from "react";
import authApi from "../../apis/auth.api";

const MyInfo = () => {
    const { user } = useAuth();
한규민's avatar
푸시    
한규민 committed
8
    const [userNickName, setUserNickName] = useState(user.nickname);
한규민's avatar
한규민 committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

    const getNickName = async (id) => {
        console.log(id);
        const nickname = await authApi.getNickName(id);
        console.log(nickname);
        return nickname
    }

    useEffect(() => {
        let name = getNickName(user.id);
        setUserNickName(name);
    }, [])

    return (
        <div className="d-flex flex-column">
            <span className={styles.title}>마이페이지</span>
            <div className="d-flex flex mh-100">
                <img src="/images/cat.jpg" className="img-thumbnail rounded-circle" />
                <div>
                    <span>{`${userNickName}`} 반갑습니다!</span>
                    <button>수정</button>
                </div>
            </div>
        </div>
    )
}

export default MyInfo