diff --git a/src/app/page.tsx b/src/app/page.tsx index 3790bcc..04d5fcd 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,109 +1,9 @@ -"use client"; - -import axios from "axios"; -import { FormEvent, useState, ChangeEvent } from "react"; -import { Update, UpdateState } from "./types/update"; +import axios from 'axios'; export default function Home() { - const [editData, setEdit] = useState({ - username: "병주", - password: "4790", - phone: "010-7329-7895", - birth: "99-02-05", - }); - - const handleChange = (e: ChangeEvent) => { - const { name, value } = e.target; - setEdit((prevFormData) => ({ - ...prevFormData, - [name]: value, - })); - }; - - const handleSubmit = async (e: FormEvent) => { - e.preventDefault(); - - const request = new UpdateRequest( - editData.username, - editData.phone, - editData.birth, - editData.password - ); - const response = await request.send(); - }; return (
-

회원정보수정

-
-
- - -
-
- - -
-
- - -
-
- - -
- -
- ); -} - -export class UpdateRequest { - username?: string; - phone?: string; - password?: string; - birth?: string; - - constructor( - username?: string, - phone?: string, - birth?: string, - password?: string - ) { - this.username = username; - this.phone = phone; - this.password = password; - this.birth = birth; - } - - async send(): Promise { - const response = await axios.put( - "http://www.ideaconnect.online/user", - this - ); - const data: Update = response.data; - return data; - } + ) } diff --git a/src/pages/user/delete.tsx b/src/pages/user/delete.tsx new file mode 100644 index 0000000..b56c606 --- /dev/null +++ b/src/pages/user/delete.tsx @@ -0,0 +1,11 @@ +"use client"; +import Popup from '@/utils/popup'; + +export default function Delete() { + + return ( +
+ +
+ ) +} diff --git a/src/utils/popup.tsx b/src/utils/popup.tsx new file mode 100644 index 0000000..ba08c4d --- /dev/null +++ b/src/utils/popup.tsx @@ -0,0 +1,102 @@ +"use client"; +import axios, { AxiosResponse } from 'axios'; +import { useState } from 'react'; + + +export default function Popup() { + const [isOpen, setIsOpen] = useState(false); + const [pw, set_pw] = useState(""); + const [isS, set_isS] = useState(false); + const AUTH_API_BASE_URL = 'https://www.ideaconnect.online'; + const openPopup = () => { + setIsOpen(true); + }; + + const closePopup = () => { + setIsOpen(false); + }; + + const fetchDelete = async () => { + try { + const response: AxiosResponse = await axios.get(`${AUTH_API_BASE_URL}/auth`); + const status:number = response.status + if (status === 200) { + alert('정상적으로 탈퇴 되었습니다.'); + } + if (status === 401) { + alert('인증되지 않아 해당 작업을 수행할 수 없습니다.'); + } + } catch (error) { + alert('탈퇴 요청 실패') + } + }; + + const fetchAuthentication = async () =>{ + + try{ + const response: AxiosResponse = await axios.post(`${AUTH_API_BASE_URL}/login`,{ + 'id' : '쿠키에 저장되어있던 id', //로그인 구현시 인터페이스 정의 예정 + 'pw' : pw + }) + const status:number = response.status + if (status === 200) { + alert('인증에 성공했습니다'); + closePopup() + set_isS(true); + } + if (status === 401) { + alert('비밀번호를 확인해 주세요'); + + } + } catch (error) { + alert('인증 요청 실패, 다시 시도해 주세요') + closePopup() + } + } + + return ( +
+ { + isS ? : + } + + + {isOpen && ( +
+
+

본인 인증

+

확인을 위해 비밀번호를 입력해 주세요

+ { set_pw(e.target.value) }}/> +
+ +
+
+ )} + + +

현재 인증 상태

+ { + isS ?

인증 안됨

:

인증 됨

+ } + +
+ ); +} \ No newline at end of file