Skip to content

Commit

Permalink
[Fix]회원탈퇴기능 정상화
Browse files Browse the repository at this point in the history
회원 탈퇴 훅에서 아무 입력도 안받도록 변동
프로필 창 회원 탈퇴 탭에서 Codestates 문자열을 입력하고 버튼을 누르면 회원탈퇴
Issues #70
  • Loading branch information
김병현 authored and 김병현 committed Sep 16, 2023
1 parent caaa8f6 commit c9c3323
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
9 changes: 2 additions & 7 deletions client/src/components/Profile/memberWithdrawalModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ const MemberWithdrawalModal: React.FC<MemberWithdrawalModalProps> = ({ onClose }
const withdrawalButtonText = "회원탈퇴";

const handleWithdrawal = () => {
if (inputString === "Codestates/seb-45_main_008") {
deleteMemberMutation.mutate(inputString, {
onSuccess: () => {
alert('회원탈퇴 되었습니다!');
onClose();
}
});
if (inputString === "Codestates") {
deleteMemberMutation.mutate();
} else {
setErrorMsg(incorrectStringMsg);
}
Expand Down
10 changes: 6 additions & 4 deletions client/src/hooks/useDeleteMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { useMutation } from 'react-query';
import axios from 'axios';

export function useDeleteMember() {
return useMutation(async (password: string) => { // 비밀번호를 인자로 받음
const response = await axios.delete(`http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com/members/`, {
data: { password } // 비밀번호를 request body에 전송
});
return useMutation(async () => {
const response = await axios.delete(`http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com/members/`);

if (response.status !== 204) {
throw new Error('Failed to delete member');
}
}, {
onSuccess: () => {
alert('회원탈퇴 되었습니다!');
}
});
}

0 comments on commit c9c3323

Please sign in to comment.