diff --git a/task_yell/src/app/home/page.tsx b/task_yell/src/app/home/page.tsx index db2bd19..9b766bd 100644 --- a/task_yell/src/app/home/page.tsx +++ b/task_yell/src/app/home/page.tsx @@ -28,7 +28,7 @@ import { import { Switch } from "@/components/ui/switch"; import { Textarea } from "@/components/ui/textarea"; import { signOut } from "@/firebase/auth"; -import { auth } from "@/firebase/client-app"; +import { auth, db } from "@/firebase/client-app"; import { createEvent, readEvents } from "@/lib/events"; import { Category, Priority } from "@/lib/types"; import { @@ -57,6 +57,12 @@ import { subMonths, } from "date-fns"; import { ja } from "date-fns/locale"; +import { + doc, + getDoc, + setDoc, + updateDoc, +} from "firebase/firestore"; import { AnimatePresence, motion, useDragControls } from "framer-motion"; import { ChevronLeft, @@ -756,10 +762,31 @@ export default function Home() { {item.label} {item.label === "通知" && isNotificationsOpen && ( -
+
{ + if (auth.currentUser) { + const docRef = doc(db, "users", auth.currentUser.uid); + const snapshot = await getDoc(docRef); + if (snapshot.exists()) { + await updateDoc(docRef, { + phoneNumber: data.get("phoneNumber"), + }); + } else { + setDoc(docRef, { + phoneNumber: data.get("phoneNumber"), + }); + } + } + }} + >
- +
-
+ + )} ))}