From ba945b913d692af037232343280c8e70309672a5 Mon Sep 17 00:00:00 2001 From: ukkodeveloper Date: Thu, 19 Oct 2023 09:50:45 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20nickname=20=EC=82=AD=EC=A0=9C=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/features/member/hooks/useWithdrawal.ts | 7 ++++++- frontend/src/features/member/remotes/member.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/features/member/hooks/useWithdrawal.ts b/frontend/src/features/member/hooks/useWithdrawal.ts index f5571da5a..6b6a89770 100644 --- a/frontend/src/features/member/hooks/useWithdrawal.ts +++ b/frontend/src/features/member/hooks/useWithdrawal.ts @@ -7,7 +7,12 @@ import { useMutation } from '@/shared/hooks/useMutation'; const useWithdrawal = () => { const navigate = useNavigate(); const { user, logout } = useAuthContext(); - const { mutateData: withdrawMember } = useMutation(deleteMember(user?.memberId)); + // TODO: 피드백 반영하여 error throw. 그러나 error 핸들링 반드시 필요 + if (!user) { + throw new Error('현재 user 로그인된 정보가 없습니다.'); + } + + const { mutateData: withdrawMember } = useMutation(() => deleteMember(user.memberId)); const handleWithdrawal = async () => { await withdrawMember(); diff --git a/frontend/src/features/member/remotes/member.ts b/frontend/src/features/member/remotes/member.ts index b9df67e00..a3e4cec0f 100644 --- a/frontend/src/features/member/remotes/member.ts +++ b/frontend/src/features/member/remotes/member.ts @@ -1,5 +1,5 @@ import fetcher from '@/shared/remotes'; -export const deleteMember = (memberId: number | undefined) => () => { +export const deleteMember = (memberId: number) => { return fetcher(`/members/${memberId}`, 'DELETE'); };