-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat/#151] 사용자 정보(이름, 이메일) 조회 API 연결 #155
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
import { instance } from '@apis/instance'; | ||
|
||
import { END_POINT, queryKey } from '@constants'; | ||
|
||
import { ApiResponseType, UserResponse } from '@types'; | ||
|
||
const fetchUser = async (): Promise<UserResponse> => { | ||
try { | ||
const response = await instance.get<ApiResponseType<UserResponse>>( | ||
END_POINT.FETCH_USER | ||
); | ||
return response.data.data; | ||
} catch (error) { | ||
console.log(error); | ||
throw error; | ||
} | ||
}; | ||
|
||
export const useFetchUser = () => { | ||
return useSuspenseQuery({ | ||
queryKey: [queryKey.USER], | ||
queryFn: fetchUser, | ||
}); | ||
}; |
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,22 +1,19 @@ | ||
import { useFetchUser } from '@apis/myPage/useFetchUser'; | ||
|
||
import { AuthModal, Modal, TextButton } from '@components'; | ||
import { WHIPEE_CONTACT_FORM } from '@constants'; | ||
import { useEasyNavigate, useModal } from '@hooks'; | ||
import { LetsGoButton, ProfileCard } from '@pages/myPage/components'; | ||
import { isLoggedIn } from '@utils'; | ||
|
||
import { | ||
letsGoButtonWrapper, | ||
loginButton, | ||
profileCardStyle, | ||
} from './MyPage.css'; | ||
|
||
const user = { | ||
userId: 1, | ||
userName: '쥬먐이', | ||
userEmail: '[email protected]', | ||
}; | ||
|
||
const MyPage = () => { | ||
const isLogin = true; //추후 삭제 후 localStorage.getItem로 수정할 예정 | ||
const isLogin = isLoggedIn(); | ||
|
||
const { isModalOpen, openModal, closeModal } = useModal(); | ||
|
||
|
@@ -26,13 +23,15 @@ const MyPage = () => { | |
window.open(WHIPEE_CONTACT_FORM, '_blank'); | ||
}; | ||
|
||
const { data: userData } = useFetchUser(); | ||
|
||
return ( | ||
<> | ||
<section className={profileCardStyle[isLogin ? 'login' : 'logout']}> | ||
<ProfileCard | ||
isLogin={isLogin} | ||
userName={user.userName} | ||
userEmail={user.userEmail} | ||
userName={userData.userName} | ||
userEmail={userData.userEmail} | ||
/> | ||
</section> | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface UserResponse { | ||
userName: string; | ||
userEmail: string; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 api는 메인 홈 화면에서 사용자 이름 불러올 때도 사용할 수 있을 것 같아서!
메인 페이지에서 호출하는 부분도 추가해주면 더 더 좋을 것 같단 생각이 들었습니닷 ! 😍