From d4a35a9eb5233823f4f99050f7d303f4faf2d50a Mon Sep 17 00:00:00 2001 From: Jiwoo Ahn Date: Thu, 16 May 2024 17:59:16 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Feat:=20phone=20number=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aeye/app/(nav)/my/profileMenu.tsx | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/aeye/app/(nav)/my/profileMenu.tsx b/aeye/app/(nav)/my/profileMenu.tsx index d716679..30439a7 100644 --- a/aeye/app/(nav)/my/profileMenu.tsx +++ b/aeye/app/(nav)/my/profileMenu.tsx @@ -1,3 +1,4 @@ +import { useState } from "react"; import { useRecoilState } from "recoil"; import { memberState } from "@/app/recoil-states"; import { @@ -14,24 +15,16 @@ import GoogleIcon from "@/app/google"; export default function ProfileMenu() { const [member, setMember] = useRecoilState(memberState); + const [phone, setPhone] = useState(""); const handleClick = async () => { - const newPhoneNumber = prompt("Enter your new phone number:"); - if (newPhoneNumber) { - const response = await fetchWithInterception("/api/member/phone", { - method: "PUT", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ phone: newPhoneNumber }), - }); - if (response.ok) { - //setMember({ ...member, phone: newPhoneNumber }); - alert("Phone number updated successfully!"); - } else { - alert("Failed to update phone number. Please try again."); - } - } + fetchWithInterception("https://api.a-eye.live/member/phone", { + method: "PUT", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ phone }), + }).catch((error) => console.error(error)); }; return ( @@ -57,6 +50,8 @@ export default function ProfileMenu() { size="small" fullWidth autoFocus + value={phone} + onChange={(e) => setPhone(e.target.value)} />