Skip to content

Commit

Permalink
feat: add account delete button
Browse files Browse the repository at this point in the history
  • Loading branch information
ooooorobo committed Dec 29, 2024
1 parent ef23bba commit b23b6e6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
10 changes: 10 additions & 0 deletions src/features/DeleteAccount/useDeleteAccount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { useMutation } from '@tanstack/react-query';
import { quit } from 'src/types';

export const useDeleteAccount = () => {
const { mutateAsync } = useMutation({
mutationFn: quit,
});

return mutateAsync;
};
12 changes: 9 additions & 3 deletions src/pages/mypage/MyPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@
}
}

.Logout {
.SmallButtonsWrapper {
display: flex;
flex-direction: column;
gap: 32px;
margin: 0 20px;
}

.SmallButton {
font-weight: 600;
font-size: 14px;
color: var(--color-neutral-700);
color: var(--color-neutral-700) !important;

margin-left: 20px;
display: block;
}
42 changes: 35 additions & 7 deletions src/pages/mypage/MyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,23 @@ import styles from './MyPage.module.css';
import { UserInfoResponse } from 'src/types';
import { UserAvatar } from 'src/entities/user/ui/UserAvatar';
import { INQUIRY_URL, NOTICE_URL, PRIVACY_POLICY_URL, TERM_URL } from 'src/shared/constants/url';
import { useDeleteAccount } from 'src/features/DeleteAccount/useDeleteAccount';
import { Theme } from 'src/shared/styles/constants';
import { redirectToLoginPage } from 'src/shared/functions/redirectToLoginPage';

const ArrowIcon = () => <ArrowRight color={Theme.color.neutral40} />;

export const MyPage = ({ userInfo }: { userInfo: UserInfoResponse }) => {
const deleteAccount = useDeleteAccount();

const onClickDeleteAccount = async () => {
if (confirm('정말로 탈퇴하시겠어요?')) {
await deleteAccount({});
alert('탈퇴했습니다');
redirectToLoginPage();
}
};

return (
<>
<div className={styles.Header}>
Expand All @@ -28,7 +43,7 @@ export const MyPage = ({ userInfo }: { userInfo: UserInfoResponse }) => {
color={'neutral'}
variant={'ghost'}
widthType={'fill'}
suffixSlot={<ArrowRight />}
suffixSlot={<ArrowIcon />}
textAlign={'left'}
>
문의하기
Expand All @@ -39,7 +54,7 @@ export const MyPage = ({ userInfo }: { userInfo: UserInfoResponse }) => {
color={'neutral'}
variant={'ghost'}
widthType={'fill'}
suffixSlot={<ArrowRight />}
suffixSlot={<ArrowIcon />}
textAlign={'left'}
>
공지사항
Expand All @@ -55,7 +70,7 @@ export const MyPage = ({ userInfo }: { userInfo: UserInfoResponse }) => {
color={'neutral'}
variant={'ghost'}
widthType={'fill'}
suffixSlot={<ArrowRight />}
suffixSlot={<ArrowIcon />}
textAlign={'left'}
>
개인정보처리방침
Expand All @@ -66,17 +81,30 @@ export const MyPage = ({ userInfo }: { userInfo: UserInfoResponse }) => {
color={'neutral'}
variant={'ghost'}
widthType={'fill'}
suffixSlot={<ArrowRight />}
suffixSlot={<ArrowIcon />}
textAlign={'left'}
>
이용정책
</Button>
</Link>
</div>
</div>
<Link to={'/logout'} className={styles.Logout}>
로그아웃
</Link>
<div className={styles.SmallButtonsWrapper}>
<Link to={'/logout'} className={styles.SmallButton}>
로그아웃
</Link>
<Button
className={`${styles.SmallButton} ${styles.DeleteAccount}`}
size={'fit'}
color={'neutral'}
variant={'ghost'}
widthType={'fill'}
textAlign={'left'}
onClick={onClickDeleteAccount}
>
회원 탈퇴
</Button>
</div>
</div>
</>
);
Expand Down

0 comments on commit b23b6e6

Please sign in to comment.