-
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.
Merge pull request #214 from sullog-official/feat/delete-member
- Loading branch information
Showing
3 changed files
with
41 additions
and
2 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 |
---|---|---|
|
@@ -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'; | ||
|
@@ -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, | ||
|
@@ -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')}> | ||
|
@@ -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> | ||
); | ||
}; | ||
|
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,8 @@ | ||
import axios from 'axios'; | ||
|
||
export const deleteUser = async () => { | ||
return await axios({ | ||
url: '/members/me', | ||
method: 'delete', | ||
}); | ||
}; |