Skip to content

Commit

Permalink
Merge pull request #242 from anheejeong/fix/235-memberBug
Browse files Browse the repository at this point in the history
Week11/issue#235 member bug
  • Loading branch information
ppochaco authored Nov 13, 2024
2 parents 8dc6fb4 + f7392de commit c7fa7dd
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 c7fa7dd

Please sign in to comment.