Skip to content

Commit

Permalink
feat / 계정 삭제 버튼 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sonagi98 committed Jul 24, 2023
1 parent 8341a70 commit f60d31b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions client/src/pages/MyPage/MyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import axios from 'axios';
import MyBookmarks from './Bookmarks/MyBookmarks';
import MyReviews from './Reviews/MyReviews';
import UserInfo from './UserInfo/UserInfo';
import DeleteUserBtn from './UI/deleteUserBtn';
import { User } from './assets/types/User';

const MyPage = () => {
Expand Down Expand Up @@ -47,6 +48,7 @@ const MyPage = () => {
<UserInfo info={user} />
<MyBookmarks id={user.memberId} />
<MyReviews reviewCounter={user.reviews} setReviewCount={setReviewCounter} />
<DeleteUserBtn id={user.memberId} />
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/MyPage/Reviews/MyReviews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const MyReviews = ({ reviewCounter, setReviewCount }: MyReviewProps) => {
const fetchReviews = async () => {
try {
const res = await axios.get(
'http://ec2-54-180-85-209.ap-northeast-2.compute.amazonaws.com:8080/members/reviews?page=0'
'http://ec2-54-180-85-209.ap-northeast-2.compute.amazonaws.com:8080/members/reviews?page=1'
);
if (res.status === 200) {
const data = res.data;
Expand Down
36 changes: 36 additions & 0 deletions client/src/pages/MyPage/UI/deleteUserBtn.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import axios from 'axios';

interface DeleteBtnProps {
id: number;
}

const DeleteUserBtn = ({ id }: DeleteBtnProps) => {
const deleteUser = async () => {
try {
const res = await axios.delete(
`http://ec2-54-180-85-209.ap-northeast-2.compute.amazonaws.com:8080/members/${id}`
);
if (res.status === 200) {
console.log('user deleted');
} else {
console.log('failed to delete user:', res);
}
} catch (err) {
console.log(err);
}
};

const handleBtnClick = () => {
deleteUser();
};

return (
<div>
<button className="px-12 py-4" onClick={handleBtnClick}>
회원 탈퇴
</button>
</div>
);
};

export default DeleteUserBtn;

0 comments on commit f60d31b

Please sign in to comment.