Skip to content

Commit

Permalink
✨ 그룹 삭제, 멤버 강퇴 query 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
LEEJW1953 committed Mar 21, 2024
1 parent 54f1ee4 commit f40b38e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/frontend/src/queries/hooks/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';

import { group } from '@/services';

export const useDeleteGroupQuery = () => {
const queryClient = useQueryClient();

return useMutation({
mutationFn: (id: string) => group.delete(id),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ['group'],
});
},
});
};

export const useJoinGroupQuery = () => {
const queryClient = useQueryClient();

Expand All @@ -15,6 +28,20 @@ export const useJoinGroupQuery = () => {
});
};

export const useKickMemberQuery = () => {
const queryClient = useQueryClient();

return useMutation({
mutationFn: ({ id, memberId }: { id: string; memberId: string }) =>
group.kick({ id, memberId }),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ['group'],
});
},
});
};

export const useLeaveGroupQuery = () => {
const queryClient = useQueryClient();

Expand Down
4 changes: 4 additions & 0 deletions app/frontend/src/services/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ export const group = {
morakAPI.post<null>(`${group.endPoint.default}/${id}/join`),
leave: async ({ id }: Pick<ResponseGroupsDto, 'id'>) =>
morakAPI.delete<null>(`${group.endPoint.default}/${id}/leave`),
kick: async ({ id, memberId }: { id: string; memberId: string }) =>
morakAPI.delete<null>(`${group.endPoint.default}/${id}/kick/${memberId}`),
delete: async (id: string) =>
morakAPI.delete<null>(`${group.endPoint.default}/${id}`),
};

0 comments on commit f40b38e

Please sign in to comment.