Skip to content

Commit

Permalink
Fix: 그룹 멤버 캐싱 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
anheejeong committed Nov 13, 2024
1 parent 9a3d8b9 commit f7392de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/pages/GroupMembersPage/ExpelBtn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export default function ExpelBtn({
mutationFn: () => expelMember({ groupId, userId }),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['expelMember'] })
queryClient.invalidateQueries({ queryKey: ['group', 'member', groupId] })
queryClient.invalidateQueries({ queryKey: ['membersManage', groupId] })
window.location.reload()
},
onError: () => {
Expand Down
5 changes: 5 additions & 0 deletions src/pages/GroupPage/ExitGroupButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ConfirmModalButton,
} from '@/components/Modal/ConfirmModal'
import { useMembersLengthStore } from '@/stores/members-length'
import { useSelectedGroupStore } from '@/stores/selected-group'
import { GroupRole } from '@/types'

interface ExitGroupButtonProps {
Expand All @@ -28,11 +29,15 @@ export const ExitGroupButton = ({
const warningAlert = useDisclosure()
const errorAlert = useDisclosure()
const navigate = useNavigate()
const setSelectedGroup = useSelectedGroupStore(
(state) => state.setSelectedGroup
)

const { mutate: exitGroup } = useMutation({
mutationFn: () => exitGroupMember(groupId),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['groups'] })
setSelectedGroup(undefined)
navigate('/')
},
})
Expand Down

0 comments on commit f7392de

Please sign in to comment.