-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from ppochaco/fix/137-main
Week10/issue#137 �쿠키 주기 버그 수정
- Loading branch information
Showing
8 changed files
with
133 additions
and
18 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
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,71 @@ | ||
import { BiSolidError } from 'react-icons/bi' | ||
import { useNavigate } from 'react-router-dom' | ||
|
||
import { Button, Flex, useDisclosure } from '@chakra-ui/react' | ||
import { useMutation } from '@tanstack/react-query' | ||
|
||
import { queryClient } from '@/api/instance' | ||
import { exitGroupMember } from '@/api/services/group/member.api' | ||
import { | ||
ConfirmModal, | ||
ConfirmModalButton, | ||
} from '@/components/Modal/ConfirmModal' | ||
import { GroupRole } from '@/types' | ||
|
||
interface ExitGroupButtonProps { | ||
groupId: number | ||
groupName: string | ||
role: GroupRole | ||
} | ||
|
||
export const ExitGroupButton = ({ | ||
groupId, | ||
groupName, | ||
role, | ||
}: ExitGroupButtonProps) => { | ||
const { isOpen, onOpen, onClose } = useDisclosure() | ||
const navigate = useNavigate() | ||
|
||
const { mutate: exitGroup } = useMutation({ | ||
mutationFn: () => exitGroupMember(groupId), | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: ['groups'] }) | ||
navigate('/') | ||
}, | ||
}) | ||
|
||
return ( | ||
<Flex justifyContent="end" paddingX={8} paddingBottom={5}> | ||
<Button | ||
variant="link" | ||
size="sm" | ||
color="brown.500" | ||
onClick={onOpen} | ||
_hover={{ color: 'brown.600' }} | ||
> | ||
그룹 탈퇴하기 | ||
</Button> | ||
<ConfirmModal | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
icon={<BiSolidError />} | ||
title={`정말로 ${groupName} 그룹에서 나가시겠습니까?`} | ||
description={ | ||
role === 'LEADER' | ||
? '그룹장이 그룹을 나가면 그룹이 삭제됩니다.' | ||
: '그룹에서의 모든 활동은 삭제됩니다.' | ||
} | ||
confirmButton={ | ||
<ConfirmModalButton | ||
onClick={() => { | ||
onClose() | ||
exitGroup() | ||
}} | ||
> | ||
확인 | ||
</ConfirmModalButton> | ||
} | ||
/> | ||
</Flex> | ||
) | ||
} |
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