Skip to content

Commit

Permalink
feat: 회원 탈퇴 api 추가 및 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
Somin committed Sep 24, 2023
1 parent 69b5fae commit 2635577
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 30 deletions.
2 changes: 2 additions & 0 deletions src/api/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ export const findPassowrd = (param: FindPasswordParams) => userApi.post('/passwo
});

export const checkPassword = (param: CheckPasswordParams) => userApi.post(`/check-password?password=${param.password}`);

export const secession = () => userApi.delete('/me');
6 changes: 4 additions & 2 deletions src/pages/Setting/Withdrawal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import { useState } from 'react';
import { createPortal } from 'react-dom';
import styles from './Withdrawal.module.scss';
import WithdrawalModal from './components/WithdrawalModal';
import useSecession from './useSecession';

export default function Withdrawal() {
const auth = useAuth();
const [isCheck, setIsCheck] = useState(0);
const [modal, open] = useBooleanState(false);
const deleteAccount = useSecession();
const checked = (event: React.ChangeEvent<HTMLInputElement>) => {
if (event.target.checked) {
setIsCheck(isCheck + 1);
} else { setIsCheck(isCheck - 1); }
};
const handleSubmit = (event:React.FormEvent<HTMLFormElement>) => {
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
withdrawUser();
event.preventDefault();
};
Expand Down Expand Up @@ -73,7 +75,7 @@ export default function Withdrawal() {
<li>추후 같은 계정으로 재가입해도 작성한 내역은 복구되지 않아요.</li>
</ul>
</div>
<button type="submit" className={styles.form__button} onClick={open} disabled={isCheck === 0}>
<button type="submit" className={styles.form__button} onClick={() => { open(); deleteAccount(); }} disabled={isCheck === 0}>
회원탈퇴
</button>
</form>
Expand Down
10 changes: 10 additions & 0 deletions src/pages/Setting/Withdrawal/useSecession.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { useMutation } from 'react-query';
import { secession } from 'api/user';

const useSecession = () => {
const { mutate: deleteAccount } = useMutation('secession', () => secession());

return deleteAccount;
};

export default useSecession;
28 changes: 0 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1890,16 +1890,6 @@
"@types/qs" "*"
"@types/range-parser" "*"

"@types/express-serve-static-core@^4.17.33":
version "4.17.36"
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.36.tgz#baa9022119bdc05a4adfe740ffc97b5f9360e545"
integrity sha512-zbivROJ0ZqLAtMzgzIUC4oNqDG9iF0lSsAqpOD9kbs5xcIM3dTiyuHvBc7R8MtWBp3AAWGaovJa+wzWPjLYW7Q==
dependencies:
"@types/node" "*"
"@types/qs" "*"
"@types/range-parser" "*"
"@types/send" "*"

"@types/express@*", "@types/express@^4.17.13":
version "4.17.13"
resolved "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz"
Expand All @@ -1910,16 +1900,6 @@
"@types/qs" "*"
"@types/serve-static" "*"

"@types/express@^4.17.17":
version "4.17.17"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.17.tgz#01d5437f6ef9cfa8668e616e13c2f2ac9a491ae4"
integrity sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==
dependencies:
"@types/body-parser" "*"
"@types/express-serve-static-core" "^4.17.33"
"@types/qs" "*"
"@types/serve-static" "*"

"@types/geojson@*":
version "7946.0.10"
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.10.tgz#6dfbf5ea17142f7f9a043809f1cd4c448cb68249"
Expand Down Expand Up @@ -2083,14 +2063,6 @@
resolved "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz"
integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==

"@types/send@*":
version "0.17.1"
resolved "https://registry.yarnpkg.com/@types/send/-/send-0.17.1.tgz#ed4932b8a2a805f1fe362a70f4e62d0ac994e301"
integrity sha512-Cwo8LE/0rnvX7kIIa3QHCkcuF21c05Ayb0ZfxPiv0W8VRiZiNW/WuRupHKpqqGVGf7SUA44QSOUKaEd9lIrd/Q==
dependencies:
"@types/mime" "^1"
"@types/node" "*"

"@types/serve-index@^1.9.1":
version "1.9.1"
resolved "https://registry.npmjs.org/@types/serve-index/-/serve-index-1.9.1.tgz"
Expand Down

0 comments on commit 2635577

Please sign in to comment.