'use client'; import './style.scss'; import Link from 'next/link'; import { useState, useEffect, useRef } from 'react'; import { fetchApi, throwError } from '@/lib/utils/client'; import useAuth from '@/hooks/useAuth'; import Loading from '@/app/component/Loading'; import NavTabs from '../navTabs'; export default function Withdraw() { const { member } = useAuth(); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const [isComplete, setComplete] = useState(false); const [agree, setAgree] = useState(false); const [password, setPassword] = useState(''); const passwordRef = useRef(null); useEffect(() => { if (error) { alert(error); setError(''); } }, [error]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!member) { return; } if (!password) { alert('비밀번호를 입력해주세요.'); passwordRef.current?.focus(); return; } if (!agree) { alert('탈퇴에 동의해주세요.'); return; } if (confirm('정말 탈퇴하시겠습니까?')) { setLoading(true); fetchApi('/api/mypage/withdraw', { method: 'POST', body: { password } }).then((res) => { throwError(res); setComplete(true); localStorage.removeItem('member'); }).catch(err => { setError(err.message); }).finally(() => { setLoading(false); }); } } const handleChange = (e: React.ChangeEvent) => { setAgree(e.target.checked); }; useEffect(() => { if (isComplete) { alert('탈퇴가 완료되었습니다.'); setComplete(false); location.replace('/'); } }, [isComplete]); if (!member) { return null; } return ( <>
{ loading && }

회원탈퇴

사용하고 계신 계정({member.email})은 탈퇴할 경우 재사용 및 복구가 불가능합니다. 탈퇴한 계정은 본인과 타인 모두 재사용 및 복구가 불가하오니 신중하게 선택하시기 바랍니다.

추가 회원가입은 탈퇴일로부터 90일 후에 가능합니다. 탈퇴 후 회원정보와 주요 서비스 이용기록은 모두 삭제되며, 삭제된 데이터는 복구되지 않습니다.

삭제되는 내용을 확인하시고 필요한 데이터는 미리 백업을 해주세요. 탈퇴 후 게시판, 댓글은은 등록한 게시물은 삭제되지 않고 유지됩니다.

탈퇴하기 전에 이메일 인증이 필요합니다.
setPassword(e.target.value)} autoFocus />
취소
); }