Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/api/book-club/bookClubMainAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@ export const bookClubMainAPI = {

//μœ μ €κ°€ μ°Έκ°€ν•œ 뢁클럽 쑰회
userJoined: async (userId: number, params?: MyProfileParams) => {
const response = await apiClient.get(`/book-clubs/user/${userId}/joined`, {
const response = await apiClient.get(`/book-clubs/users/${userId}/joined`, {
params,
});
return response.data;
},

//μœ μ €κ°€ λ§Œλ“  뢁클럽 쑰회
userCreated: async (userId: number, params?: MyProfileParams) => {
const response = await apiClient.get(`/book-clubs/user/${userId}/created`, {
params,
});
const response = await apiClient.get(
`/book-clubs/users/${userId}/created`,
{
params,
},
);
return response.data;
},

Expand Down
12 changes: 12 additions & 0 deletions src/api/book-club/react-query/customHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ export function useLikeBookClub() {
onMutate: async (id) => {
return likeOnMutate(queryClient, id, true);
},
//TODO: 둜직 확인 ν›„ λ³€κ²½ ν•„μš”
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: bookClubs._def,
});
},

onError: (_error, id, context) => {
if (context) {
Expand All @@ -130,6 +136,12 @@ export function useUnLikeBookClub() {
onMutate: async (id) => {
return likeOnMutate(queryClient, id, false);
},
//TODO: 둜직 확인 ν›„ λ³€κ²½ ν•„μš”
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: bookClubs._def,
});
},

onError: (_error, id, context) => {
if (context) {
Expand Down
5 changes: 5 additions & 0 deletions src/api/book-club/react-query/likeOptimisticUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export const likeOnMutate = async (
});
}

//TODO: 둜직 확인 ν›„ λ³€κ²½ ν•„μš”
queryClient.invalidateQueries({
queryKey: bookClubs._def,
});

return { previousBookClubs, previousDetail };
};

Expand Down
Loading