@@ -8,20 +8,9 @@ import {
8
8
DialogTitle ,
9
9
} from "@/components/ui/dialog" ;
10
10
import { Input } from "@/components/ui/input" ;
11
- import { Label } from "@/components/ui/label" ;
12
- import {
13
- Sheet ,
14
- SheetContent ,
15
- SheetHeader ,
16
- SheetTitle ,
17
- SheetTrigger ,
18
- } from "@/components/ui/sheet" ;
19
- import { Switch } from "@/components/ui/switch" ;
20
- import { signOut } from "@/firebase/auth" ;
21
- import { auth , db } from "@/firebase/client-app" ;
11
+ import { auth } from "@/firebase/client-app" ;
22
12
import { createEvent , readEvents } from "@/lib/events" ;
23
13
import { createNotification } from "@/lib/notifications" ;
24
- import { subscribeNotification } from "@/lib/push-notification" ;
25
14
import {
26
15
createWantTodo ,
27
16
deleteWantTodo ,
@@ -41,29 +30,23 @@ import {
41
30
subMonths ,
42
31
} from "date-fns" ;
43
32
import { ja } from "date-fns/locale" ;
44
- import { doc , getDoc , setDoc , updateDoc } from "firebase/firestore" ;
45
33
import { AnimatePresence , motion , useDragControls } from "framer-motion" ;
46
34
import {
47
35
ChevronLeft ,
48
36
ChevronRight ,
49
37
ChevronUp ,
50
38
Edit ,
51
- Menu ,
52
39
Trash2 ,
53
40
X ,
54
- Bell ,
55
- Users ,
56
- Download ,
57
- LogOut ,
58
41
Brain ,
59
- PhoneCall ,
60
42
} from "lucide-react" ;
61
43
import { useRouter } from "next/navigation" ;
62
44
import { useEffect , useMemo , useRef , useState } from "react" ;
63
45
import { generateStickyNoteServer } from "./actions" ;
64
46
import { EventCreator } from "@/components/event-creator" ;
65
47
import { Event , Todo , StickyNote } from "@/components/types" ;
66
48
import { priorityColors } from "@/components/priority-colors" ;
49
+ import { Navigation } from "@/components/navigation" ;
67
50
68
51
export default function Home ( ) {
69
52
const [ todos ] = useState < Todo [ ] > ( [ ] ) ;
@@ -90,9 +73,6 @@ export default function Home() {
90
73
) ;
91
74
const dragControls = useDragControls ( ) ;
92
75
const modalRef = useRef < HTMLDivElement > ( null ) ;
93
- const [ isOpen , setIsOpen ] = useState ( false ) ;
94
- const [ isNotificationsOpen , setIsNotificationsOpen ] = useState ( false ) ;
95
- const [ notificationsEnabled , setNotificationsEnabled ] = useState ( false ) ;
96
76
const router = useRouter ( ) ;
97
77
98
78
useEffect ( ( ) => {
@@ -138,46 +118,6 @@ export default function Home() {
138
118
}
139
119
} , [ isDarkMode ] ) ;
140
120
141
- /**
142
- * ハンバーガーメニューの詳細
143
- */
144
- const menuItems = [
145
- {
146
- icon : PhoneCall ,
147
- label : "電話通知" ,
148
- onClick : ( ) => {
149
- return setIsNotificationsOpen ( ! isNotificationsOpen ) ;
150
- } ,
151
- } ,
152
- {
153
- icon : Bell ,
154
- label : "プッシュ通知" ,
155
- onClick : async ( ) => {
156
- await subscribeNotification ( ) ;
157
- } ,
158
- } ,
159
- { icon : Users , label : "友達" , onClick : ( ) => console . log ( "友達" ) } ,
160
- {
161
- icon : Download ,
162
- label : "インポート" ,
163
- onClick : ( ) => {
164
- if ( auth . currentUser ) {
165
- router . push (
166
- `/api/auth/google-cal?userId=${ encodeURIComponent ( auth . currentUser . uid ) } ` ,
167
- ) ;
168
- }
169
- } ,
170
- } ,
171
- {
172
- icon : LogOut ,
173
- label : "ログアウト" ,
174
- onClick : async ( ) => {
175
- await signOut ( ) ;
176
- router . refresh ( ) ;
177
- } ,
178
- } ,
179
- ] ;
180
-
181
121
const addStickyNote = async ( ) => {
182
122
if ( newStickyNote . trim ( ) ) {
183
123
const newNote : StickyNote = { id : "" , title : newStickyNote } ;
@@ -474,88 +414,7 @@ export default function Home() {
474
414
< div
475
415
className = { `relative h-screen bg-gray-100 dark:bg-gray-900 overflow-hidden ${ isDarkMode ? "dark" : "" } ` }
476
416
>
477
- < Sheet open = { isOpen } onOpenChange = { setIsOpen } >
478
- < SheetTrigger asChild >
479
- < Button
480
- variant = "ghost"
481
- size = "icon"
482
- className = "fixed top-4 left-4 z-50 w-12 h-12 bg-white dark:bg-gray-800 rounded-full shadow-md hover:bg-gray-100 dark:hover:bg-gray-700"
483
- >
484
- { /* CSS変更する必要あるかも */ }
485
- < Menu className = "h-6 w-6" />
486
- < span className = "sr-only" > メニューを開く</ span >
487
- </ Button >
488
- </ SheetTrigger >
489
- < SheetContent side = "left" className = "w-[300px] sm:w-[400px]" >
490
- < SheetHeader >
491
- < SheetTitle > 設定</ SheetTitle >
492
- </ SheetHeader >
493
- < div className = "mt-4 space-y-4" >
494
- < div className = "flex items-center space-x-2" >
495
- < Switch
496
- id = "dark-mode"
497
- checked = { isDarkMode }
498
- onCheckedChange = { setIsDarkMode }
499
- />
500
- < Label htmlFor = "dark-mode" > ダークモード</ Label >
501
- </ div >
502
- </ div >
503
- < nav className = "mt-8" >
504
- < ul className = "space-y-4" >
505
- { menuItems . map ( ( item , index ) => (
506
- < li key = { index } >
507
- < Button
508
- variant = "ghost"
509
- className = "w-full justify-start"
510
- onClick = { item . onClick }
511
- >
512
- < item . icon className = "mr-2 h-5 w-5" />
513
- { item . label }
514
- </ Button >
515
- { item . label === "電話通知" && isNotificationsOpen && (
516
- < form
517
- className = "ml-7 mt-2 space-y-4"
518
- action = { async ( data ) => {
519
- if ( auth . currentUser ) {
520
- const docRef = doc ( db , "users" , auth . currentUser . uid ) ;
521
- const snapshot = await getDoc ( docRef ) ;
522
- if ( snapshot . exists ( ) ) {
523
- await updateDoc ( docRef , {
524
- phoneNumber : data . get ( "phoneNumber" ) ,
525
- } ) ;
526
- } else {
527
- setDoc ( docRef , {
528
- phoneNumber : data . get ( "phoneNumber" ) ,
529
- } ) ;
530
- }
531
- }
532
- } }
533
- >
534
- < div className = "space-y-2" >
535
- < Label htmlFor = "phone" > 電話番号</ Label >
536
- < Input
537
- id = "phone"
538
- name = "phoneNumber"
539
- placeholder = "+8190XXXXYYYY"
540
- />
541
- </ div >
542
- < div className = "flex items-center space-x-2" >
543
- < Switch
544
- id = "notifications"
545
- checked = { notificationsEnabled }
546
- onCheckedChange = { setNotificationsEnabled }
547
- />
548
- < Label htmlFor = "notifications" > 通知を有効にする</ Label >
549
- </ div >
550
- < Button type = "submit" > 保存</ Button >
551
- </ form >
552
- ) }
553
- </ li >
554
- ) ) }
555
- </ ul >
556
- </ nav >
557
- </ SheetContent >
558
- </ Sheet >
417
+ < Navigation isDarkMode = { isDarkMode } setIsDarkMode = { setIsDarkMode } />
559
418
560
419
< div className = "flex flex-col lg:flex-row h-full pt-20 px-4" >
561
420
< div className = "w-full lg:w-1/2 pr-2 overflow-auto" >
0 commit comments