11import React , { useState , useEffect } from "react" ;
2- import { useRouter } from "next/router" ;
32import { useAuthGuard } from "@/hooks/useAuthGuard" ;
3+ import useUserStore from "@/store/useUserStore" ;
44import HeaderMyPage from "@/components/gnb/HeaderDashboard" ;
55import SideMenu from "@/components/sideMenu/SideMenu" ;
6- import ProfileCard from "@/components/card/Profile" ;
6+ import { ProfileCard } from "@/components/card/Profile" ;
77import ChangePassword from "@/components/card/ChangePassword" ;
88import BackButton from "@/components/button/BackButton" ;
99import { Dashboard , getDashboards } from "@/api/dashboards" ;
10+ import { getUserInfo } from "@/api/users" ;
1011import { TEAM_ID } from "@/constants/team" ;
1112import LoadingSpinner from "@/components/common/LoadingSpinner" ;
13+ import { toast } from "react-toastify" ;
1214
1315export default function MyPage ( ) {
1416 const { user, isInitialized } = useAuthGuard ( ) ;
15- const router = useRouter ( ) ;
17+ const { setUser } = useUserStore ( ) ;
1618 const [ dashboards , setDashboards ] = useState < Dashboard [ ] > ( [ ] ) ;
1719
20+ // 사이드메뉴 대시보드 목록 api 호출
1821 const fetchDashboards = async ( ) => {
1922 try {
2023 const res = await getDashboards ( { } ) ;
21- setDashboards ( res . dashboards ) ; // 👉 정상 저장
24+ setDashboards ( res . dashboards ) ;
2225 } catch ( error ) {
2326 console . error ( "대시보드 불러오기 실패:" , error ) ;
27+ toast . error ( "대시보드를 불러오는 데 실패했습니다" ) ;
28+ }
29+ } ;
30+
31+ // 프로필 변경 섹션 유저 정보 api 호출
32+ const fetchUserData = async ( ) => {
33+ try {
34+ const res = await getUserInfo ( ) ;
35+ setUser ( res ) ;
36+ } catch ( error ) {
37+ console . error ( "유저 정보 불러오기 실패:" , error ) ;
38+ toast . error ( "유저 정보를 불러오는 데 실패했습니다." ) ;
2439 }
2540 } ;
2641
2742 useEffect ( ( ) => {
2843 if ( isInitialized && user ) {
2944 fetchDashboards ( ) ;
45+ fetchUserData ( ) ;
3046 }
3147 } , [ isInitialized , user ] ) ;
3248
@@ -43,10 +59,13 @@ export default function MyPage() {
4359 />
4460 < div className = "flex flex-col flex-1 overflow-hidden bg-[#F5F2FC]" >
4561 < HeaderMyPage variant = "mypage" />
46- < div className = "flex flex-col justify-start overflow-auto w-full px-6 mt-6 pb-10" >
47- < BackButton />
62+ < div className = "flex flex-col justify-start overflow-auto w-full mt-6 pb-10" >
63+ { /* 백버튼 여백 */ }
64+ < div className = "sm:px-8 lg:px-6 px-2.5" >
65+ < BackButton />
66+ </ div >
4867 { /* 백버튼 아래 전체 아이템 컨테이너 */ }
49- < div className = "flex flex-col items-center lg:items-start mt-6 gap-6" >
68+ < div className = "flex flex-col items-center lg:items-start px-6 mt-6 gap-6" >
5069 < ProfileCard />
5170 < ChangePassword />
5271 </ div >
0 commit comments