-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
79 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { MemberInfoDto } from '@src/types/user'; | ||
import jigumeAxios from './axios'; | ||
|
||
const getProfile = async () => { | ||
const getProfile = async (): Promise<MemberInfoDto> => { | ||
const response = await jigumeAxios.get('/api/member/profile'); | ||
|
||
return response; | ||
return response.data; | ||
}; | ||
|
||
export default getProfile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
import { MemberInfoDto } from '@src/types/user'; | ||
|
||
export type MyPageContextType = { | ||
setTitle: React.Dispatch<React.SetStateAction<string>>; | ||
setProfileHeader: React.Dispatch<React.SetStateAction<ProfileHeaderType>>; | ||
profile: MemberInfoDto; | ||
}; | ||
|
||
export type NewProfileType = { | ||
nickname: string; | ||
image: string | undefined; | ||
}; | ||
|
||
export type ProfileHeaderType = { | ||
title: string; | ||
isAlert: boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
import React, { useState } from 'react'; | ||
import { Outlet } from 'react-router-dom'; | ||
import getProfile from '@src/api/mypage'; | ||
import { useQuery } from 'react-query'; | ||
import MyPageHeader from './components/MyPageHeader'; | ||
import { ProfileHeaderType } from './index.d'; | ||
|
||
export default function Mypage() { | ||
const [title, setTitle] = useState('마이페이지'); | ||
// useQuery를 사용하여 fetch 함수 실행 (getProfile) | ||
const { data: profile } = useQuery('getProfile', () => getProfile(), { | ||
onSuccess: (data) => { | ||
console.log(data); | ||
}, | ||
}); | ||
|
||
const [profileHeader, setProfileHeader] = useState<ProfileHeaderType>({ | ||
title: '마이페이지', | ||
isAlert: true, | ||
}); | ||
return ( | ||
<> | ||
<MyPageHeader title={title} /> | ||
<Outlet context={{ setTitle }} /> | ||
<MyPageHeader | ||
title={profileHeader.title} | ||
isAlert={profileHeader.isAlert} | ||
/> | ||
<Outlet context={{ setProfileHeader, profile }} /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters