-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/#142/store-page-api' of https://github.com/SOPT-alβ¦
β¦l/35-APPJAM-WEB-CAKEY into feat/#142/store-page-api
- Loading branch information
Showing
17 changed files
with
144 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { usePostStoreLikes } from './usePostStoreLikes'; | ||
import { usePostCakeLikes } from './usePostCakeLikes'; | ||
|
||
export { usePostStoreLikes, usePostCakeLikes }; |
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,22 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
import { instance } from '@apis/instance'; | ||
|
||
import { END_POINT } from '@constants'; | ||
|
||
import { MutateResposneType } from '@types'; | ||
|
||
const postCakeLikes = async (cakeId: number): Promise<MutateResposneType> => { | ||
try { | ||
const response = await instance.post(END_POINT.POST_CAKE_LIKES(cakeId)); | ||
return response.data; | ||
} catch (error) { | ||
console.log(error); | ||
throw error; | ||
} | ||
}; | ||
export const usePostCakeLikes = () => { | ||
return useMutation({ | ||
mutationFn: (cakeId: number) => postCakeLikes(cakeId), | ||
}); | ||
}; |
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,23 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
import { instance } from '@apis/instance'; | ||
|
||
import { END_POINT } from '@constants'; | ||
|
||
import { MutateResposneType } from '@types'; | ||
|
||
const postStoreLikes = async (storeId: number): Promise<MutateResposneType> => { | ||
try { | ||
const response = await instance.post(END_POINT.POST_STORE_LIKES(storeId)); | ||
return response.data; | ||
} catch (error) { | ||
console.log(error); | ||
throw error; | ||
} | ||
}; | ||
|
||
export const usePostStoreLikes = () => { | ||
return useMutation({ | ||
mutationFn: (storeId: number) => postStoreLikes(storeId), | ||
}); | ||
}; |
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,3 @@ | ||
import { useFetchUser } from './useFetchUser'; | ||
|
||
export { useFetchUser }; |
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
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,22 +1,19 @@ | ||
import { useFetchUser } from '@apis/myPage'; | ||
|
||
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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface UserResponse { | ||
userName: string; | ||
userEmail: string; | ||
} |