From ce50398bbc426ea1c212134c7f4cd6724e5304af Mon Sep 17 00:00:00 2001 From: Yuto Terada Date: Sun, 27 Oct 2024 12:43:54 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E9=9B=BB=E8=A9=B1=E7=95=AA=E5=8F=B7?= =?UTF-8?q?=E3=82=92=E8=A8=AD=E5=AE=9A=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task_yell/src/app/home/page.tsx | 36 +++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/task_yell/src/app/home/page.tsx b/task_yell/src/app/home/page.tsx index db2bd19..e18eeb0 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,7 @@ import { subMonths, } from "date-fns"; import { ja } from "date-fns/locale"; +import { addDoc, collection, doc, getDoc, setDoc, updateDoc } from "firebase/firestore"; import { AnimatePresence, motion, useDragControls } from "framer-motion"; import { ChevronLeft, @@ -586,11 +587,10 @@ export default function Home() { return ( handleDateSelect(day)} whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }} @@ -756,20 +756,34 @@ 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"), + }); + } + } + }}>
- +
+ onCheckedChange={setNotificationsEnabled} />
-
+ + )} ))} From a868dc998a18654b1aaadf077eb2fe5c94bec654 Mon Sep 17 00:00:00 2001 From: Yuto Terada Date: Sun, 27 Oct 2024 12:44:36 +0900 Subject: [PATCH 2/3] format --- task_yell/src/app/home/page.tsx | 58 +++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/task_yell/src/app/home/page.tsx b/task_yell/src/app/home/page.tsx index e18eeb0..6080a49 100644 --- a/task_yell/src/app/home/page.tsx +++ b/task_yell/src/app/home/page.tsx @@ -57,7 +57,14 @@ import { subMonths, } from "date-fns"; import { ja } from "date-fns/locale"; -import { addDoc, collection, doc, getDoc, setDoc, updateDoc } from "firebase/firestore"; +import { + addDoc, + collection, + doc, + getDoc, + setDoc, + updateDoc, +} from "firebase/firestore"; import { AnimatePresence, motion, useDragControls } from "framer-motion"; import { ChevronLeft, @@ -587,10 +594,11 @@ export default function Home() { return ( handleDateSelect(day)} whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }} @@ -756,30 +764,38 @@ 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"), - }); + { + 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"), + }); + } } - } - }}> + }} + >
- +
+ onCheckedChange={setNotificationsEnabled} + />
From bf2eea6fc59e69221209044f3d5989ed531c5ce9 Mon Sep 17 00:00:00 2001 From: Yuto Terada Date: Sun, 27 Oct 2024 12:49:20 +0900 Subject: [PATCH 3/3] format --- task_yell/src/app/home/page.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/task_yell/src/app/home/page.tsx b/task_yell/src/app/home/page.tsx index 6080a49..9b766bd 100644 --- a/task_yell/src/app/home/page.tsx +++ b/task_yell/src/app/home/page.tsx @@ -58,8 +58,6 @@ import { } from "date-fns"; import { ja } from "date-fns/locale"; import { - addDoc, - collection, doc, getDoc, setDoc,