Skip to content

Commit

Permalink
✨ Feat: phone number api
Browse files Browse the repository at this point in the history
  • Loading branch information
ilp-sys committed May 16, 2024
1 parent bbddd28 commit d4a35a9
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions aeye/app/(nav)/my/profileMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useState } from "react";
import { useRecoilState } from "recoil";
import { memberState } from "@/app/recoil-states";
import {
Expand All @@ -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 (
Expand All @@ -57,6 +50,8 @@ export default function ProfileMenu() {
size="small"
fullWidth
autoFocus
value={phone}
onChange={(e) => setPhone(e.target.value)}
/>
</Box>
<Box
Expand Down

0 comments on commit d4a35a9

Please sign in to comment.