diff --git a/src/api/MyPageApi.ts b/src/api/MyPageApi.ts index a1fa678..896ad07 100644 --- a/src/api/MyPageApi.ts +++ b/src/api/MyPageApi.ts @@ -1,4 +1,4 @@ -import { ProfileInfo } from '../types/MyPage'; +import { ProfileInfo, ReturnData } from '../types/MyPage'; import { axiosInstance } from '../utils/apiConfig'; export const fetchData = async (): Promise => { @@ -9,3 +9,13 @@ export const fetchData = async (): Promise => { console.error('Error fetching data:', error); } }; + +export const fetchBlockData = async (): Promise => { + try { + const res = await axiosInstance.get('/members/mypage/dashboard-challenges'); + + return res.data as ReturnData; + } catch (error) { + console.error('Error fetching data:', error); + } +}; diff --git a/src/pages/MyPage.tsx b/src/pages/MyPage.tsx index 7391bf6..e64af84 100644 --- a/src/pages/MyPage.tsx +++ b/src/pages/MyPage.tsx @@ -4,15 +4,22 @@ import googleicon from '../img/googleicon.png'; import kakaologo from '../img/kakaologo.png'; import bell from '../img/bell.png'; import ChallengeBlock from '../components/ChallengeBlock'; -import ReactPaginate from 'react-paginate'; import * as S from '../styles/MyPageStyled'; import Profile from '../components/Profile'; import { useQuery } from '@tanstack/react-query'; -import { fetchData } from '../api/MyPageApi'; +import { fetchBlockData, fetchData } from '../api/MyPageApi'; +import { ChangeEvent, useState } from 'react'; +import Pagination from '@mui/material/Pagination'; +import { TeamDashboardInfoResDto } from '../types/TeamDashBoard'; const MyPage = () => { const { data } = useQuery({ queryKey: ['profile'], queryFn: fetchData }); + const { data: teamBlock } = useQuery({ queryKey: ['teamBlcok'], queryFn: fetchBlockData }); + + const [teamBool, setTeamBool] = useState(true); + const socialType = data?.data.socialType; + const SocialIcon = () => ( { - - - - - - + {teamBool + ? teamBlock?.data.teamDashboardList.teamDashboardInfoResDto.map((item, idx) => ( + + )) + : teamBlock?.data.challengeList.challengeInfoResDto.map((item, idx) => ( + + ))} - + {/* */} diff --git a/src/types/MyPage.ts b/src/types/MyPage.ts index 4052177..3dfd639 100644 --- a/src/types/MyPage.ts +++ b/src/types/MyPage.ts @@ -10,3 +10,42 @@ export interface ProfileInfo { introduction: 'string'; }; } + +interface PageInfoResDto { + currentPage: number; + totalPages: number; + totalItems: number; +} + +interface TeamDashboardInfoResDto { + // 팀 대시보드 정보에 맞는 속성들을 추가해야 합니다. 예시로는 아래와 같이 비워둡니다. +} + +interface ChallengeInfoResDto { + // 챌린지 정보에 맞는 속성들을 추가해야 합니다. 예시로는 아래와 같이 비워둡니다. +} + +interface TeamDashboardList { + teamDashboardInfoResDto: TeamDashboardInfoResDto[]; + pageInfoResDto: PageInfoResDto; +} + +interface ChallengeList { + challengeInfoResDto: ChallengeInfoResDto[]; + pageInfoResDto: PageInfoResDto; +} + +interface ApiResponse { + statusCode: number; + message: string; + data: { + teamDashboardList: TeamDashboardList; + challengeList: ChallengeList; + }; +} +export interface ReturnData { + data: { + teamDashboardList: TeamDashboardList; + challengeList: ChallengeList; + }; +}