-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
157 additions
and
12 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,39 @@ | ||
'use client'; | ||
|
||
import ButtonWithDialogCheck from '@app/_components/common/WithDialogCheck'; | ||
import useWithdrawalMutation from '@app/_hooks/apis/user/useWithdrawalMutation'; | ||
import { Button } from '@app/_shadcn/components/ui/button'; | ||
import { myProfileState } from '@app/_store/permissionAtoms'; | ||
import { useRecoilValue } from 'recoil'; | ||
|
||
function AccountSettingSection() { | ||
const { mutate: withdrawMutate } = useWithdrawalMutation(); | ||
const myProfile = useRecoilValue(myProfileState); | ||
|
||
const onWithdrawalClick = () => { | ||
if (!myProfile?.id) { | ||
throw new Error('[개발자 문의 바람] myProfile id 상태를 확인해주세요.'); | ||
} | ||
withdrawMutate(myProfile.id); | ||
}; | ||
|
||
return ( | ||
<section className="flex justify-end gap-4"> | ||
<Button className="w-full" variant="secondary"> | ||
비밀번호 변경(개발 중이에요!) | ||
</Button> | ||
<ButtonWithDialogCheck | ||
title="회원 탈퇴" | ||
description="정말 탈퇴하시겠어요?" | ||
className="w-full" | ||
confirmVariant="destructive" | ||
variant="destructive" | ||
onClick={onWithdrawalClick} | ||
> | ||
회원 탈퇴 | ||
</ButtonWithDialogCheck> | ||
</section> | ||
); | ||
} | ||
|
||
export default AccountSettingSection; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
import { | ||
Dialog, | ||
DialogClose, | ||
DialogContent, | ||
DialogFooter, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from '@app/_shadcn/components/ui/dialog'; | ||
import { Button, ButtonProps } from '@app/_shadcn/components/ui/button'; | ||
|
||
interface Props extends ButtonProps { | ||
title: string; | ||
description: string; | ||
confirmVariant?: ButtonProps['variant']; | ||
cancelVariant?: ButtonProps['variant']; | ||
} | ||
|
||
function ButtonWithDialogCheck({ | ||
title, | ||
description, | ||
onClick, | ||
confirmVariant, | ||
cancelVariant, | ||
...props | ||
}: Props) { | ||
return ( | ||
<Dialog> | ||
<DialogTrigger asChild> | ||
<Button {...props} /> | ||
</DialogTrigger> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>{title}</DialogTitle> | ||
</DialogHeader> | ||
<div>{description}</div> | ||
<DialogFooter> | ||
<DialogClose asChild> | ||
<Button variant={cancelVariant || 'secondary'}>취소</Button> | ||
</DialogClose> | ||
<DialogClose asChild> | ||
<Button variant={confirmVariant || 'default'} onClick={onClick}> | ||
확인 | ||
</Button> | ||
</DialogClose> | ||
</DialogFooter> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
} | ||
|
||
export default ButtonWithDialogCheck; |
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,28 @@ | ||
import userService from '@app/_service/userService'; | ||
import { useToast } from '@app/_shadcn/components/ui/use-toast'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
function useWithdrawalMutation() { | ||
const { toast } = useToast(); | ||
|
||
return useMutation({ | ||
mutationFn: async (userId: string) => { | ||
await userService.withdrawal(userId); | ||
}, | ||
|
||
onSuccess: () => | ||
toast({ | ||
title: '회원 탈퇴', | ||
description: '회원 탈퇴에 성공했어요.', | ||
}), | ||
|
||
onError: () => | ||
toast({ | ||
variant: 'destructive', | ||
title: '회원 탈퇴', | ||
description: '회원 탈퇴에 실패했어요.', | ||
}), | ||
}); | ||
} | ||
|
||
export default useWithdrawalMutation; |
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