Skip to content

Commit

Permalink
Merge pull request #214 from sullog-official/feat/delete-member
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinho1011 authored Sep 22, 2023
2 parents be677c4 + ec4dce4 commit 7dde521
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,10 @@
height: 110px;
padding: 0 4px;
}

.delete-button {
margin-top: 12px;
font-weight: 300;
text-decoration: underline;
@include themes.typography('caption9');
}
28 changes: 26 additions & 2 deletions src/features/home/components/DrawerContents/DrawerContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import classNames from 'classnames/bind';

import { mapoFlowerIsland } from '@/assets/styles/fonts';
import DoughnutChart from '@/features/home/components/DoughnutChart';
import { deleteUser } from '@/shared/apis/auth/delete';
import { Button } from '@/shared/components';
import useAuth from '@/shared/hooks/useAuth';
import useConfirm from '@/shared/hooks/useConfirm';
import { Statistics } from '@/shared/types/record/statistics';

import styles from './DrawerContents.module.scss';
Expand All @@ -16,6 +18,7 @@ type DrawerContentsProps = {

const DrawerContents = ({ statistics }: DrawerContentsProps) => {
const { logout } = useAuth();
const { confirm } = useConfirm();

const recordsCount = Object?.values(statistics?.recordStatisticsMap).reduce(
(acc, cur) => acc + cur,
Expand All @@ -26,6 +29,18 @@ const DrawerContents = ({ statistics }: DrawerContentsProps) => {
window.location.href = 'mailto:[email protected]';
};

const handleClickDelete = async () => {
if (
await confirm({
message: '정말 회원탈퇴를 하시겠어요?',
okText: '확인',
})
) {
await deleteUser();
logout();
}
};

return (
<div className={cx('wrapper')}>
<div className={cx('title-box')}>
Expand All @@ -51,11 +66,20 @@ const DrawerContents = ({ statistics }: DrawerContentsProps) => {
</div>
)}
<div className={cx('button-container')}>
<Button onClick={onClickContact}>문의하기</Button>
<Button type="outline" onClick={logout}>
<Button buttonType="button" onClick={onClickContact}>
문의하기
</Button>
<Button buttonType="button" type="outline" onClick={logout}>
로그아웃
</Button>
</div>
<button
type="button"
className={cx('delete-button')}
onClick={handleClickDelete}
>
회원탈퇴
</button>
</div>
);
};
Expand Down
8 changes: 8 additions & 0 deletions src/shared/apis/auth/delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import axios from 'axios';

export const deleteUser = async () => {
return await axios({
url: '/members/me',
method: 'delete',
});
};

0 comments on commit 7dde521

Please sign in to comment.