@@ -8,27 +8,17 @@ import React, {
88 useMemo
99} from "react"
1010import { useRouter , useSearchParams } from "next/navigation"
11- import {
12- format ,
13- isSameDay ,
14- parseISO ,
15- startOfMonth ,
16- endOfMonth ,
17- startOfWeek ,
18- endOfWeek
19- } from "date-fns"
11+ import { format , isSameDay , parseISO } from "date-fns"
2012import { IconLoader , IconX , IconSparkles , IconCheck } from "@tabler/icons-react"
2113import { AnimatePresence , motion } from "framer-motion"
2214import toast from "react-hot-toast"
23- import { cn } from "@utils/cn"
2415import { Tooltip } from "react-tooltip"
2516import { calculateNextRun } from "@utils/taskUtils"
2617
2718import TaskDetailsPanel from "@components/tasks/TaskDetailsPanel"
2819import TaskViewSwitcher from "@components/tasks/TaskViewSwitcher"
2920import ListView from "@components/tasks/ListView"
3021import CalendarView from "@components/tasks/CalendarView"
31- import GCalEventDetailsPanel from "@components/tasks/GCalEventCardDetailsPanel"
3222import WelcomePanel from "@components/tasks/WelcomePanel"
3323import CreateTaskInput from "@components/tasks/CreateTaskInput"
3424import InteractiveNetworkBackground from "@components/ui/InteractiveNetworkBackground"
@@ -153,9 +143,7 @@ function TasksPageContent() {
153143 type : "initial" ,
154144 data : null
155145 } ) // { type: 'initial' | 'hidden' | 'welcome' | 'task' | 'day', data: any }
156- const [ gcalEvents , setGcalEvents ] = useState ( [ ] )
157- const [ isGcalConnected , setIsGcalConnected ] = useState ( false )
158- const [ currentCalendarDate , setCurrentCalendarDate ] = useState ( new Date ( ) ) // To track calendar view range
146+ const [ currentCalendarDate , setCurrentCalendarDate ] = useState ( new Date ( ) )
159147 const [ searchQuery , setSearchQuery ] = useState ( "" )
160148 const [ createTaskPrompt , setCreateTaskPrompt ] = useState ( "" )
161149 const [ isUpgradeModalOpen , setUpgradeModalOpen ] = useState ( false )
@@ -294,51 +282,6 @@ function TasksPageContent() {
294282 }
295283 } , [ ] )
296284
297- useEffect ( ( ) => {
298- const gcal = integrations . find ( ( i ) => i . name === "gcalendar" )
299- setIsGcalConnected ( gcal ?. connected || false )
300- } , [ integrations ] )
301-
302- // New useEffect for fetching GCal events
303- const fetchGcalEvents = useCallback (
304- async ( date ) => {
305- if ( ! isGcalConnected || view !== "calendar" ) return
306-
307- // Calculate the visible date range for the calendar view
308- const monthStart = startOfMonth ( date )
309- const monthEnd = endOfMonth ( date )
310- const startDate = startOfWeek ( monthStart )
311- const endDate = endOfWeek ( monthEnd )
312-
313- try {
314- const res = await fetch (
315- `/api/integrations/gcalendar/events?start_date=${ startDate . toISOString ( ) } &end_date=${ endDate . toISOString ( ) } `
316- )
317- if ( ! res . ok )
318- throw new Error ( "Failed to fetch Google Calendar events" )
319- const data = await res . json ( )
320-
321- // Add a type and parse dates
322- const formattedEvents = ( data . events || [ ] ) . map ( ( event ) => ( {
323- ...event ,
324- type : "gcal" ,
325- scheduled_date : parseISO ( event . start ) , // Use 'start' from GCal event
326- end_date : parseISO ( event . end ) ,
327- instance_id : `gcal-${ event . id } ` // Unique ID for React key
328- } ) )
329- setGcalEvents ( formattedEvents )
330- } catch ( error ) {
331- toast . error ( error . message )
332- setGcalEvents ( [ ] ) // Clear on error
333- }
334- } ,
335- [ isGcalConnected , view ]
336- )
337-
338- useEffect ( ( ) => {
339- fetchGcalEvents ( currentCalendarDate )
340- } , [ currentCalendarDate , fetchGcalEvents ] )
341-
342285 useEffect ( ( ) => {
343286 fetchTasks ( )
344287 } , [ fetchTasks ] )
@@ -412,24 +355,16 @@ function TasksPageContent() {
412355 }
413356
414357 const handleSelectItem = ( item ) => {
415- if ( item . type === "gcal" ) {
416- setRightPanelContent ( { type : "gcal" , data : item } )
417- } else {
418- setRightPanelContent ( { type : "task" , data : item } )
419- }
358+ setRightPanelContent ( { type : "task" , data : item } )
420359 }
421360
422361 const handleShowMoreClick = ( date ) => {
423362 const tasksForDay = filteredCalendarTasks . filter (
424363 ( task ) => isSameDay ( task . scheduled_date , date ) // prettier-ignore
425364 )
426- const eventsForDay = gcalEvents . filter ( ( event ) =>
427- isSameDay ( event . scheduled_date , date )
428- )
429- const allItemsForDay = [ ...tasksForDay , ...eventsForDay ]
430365 setRightPanelContent ( {
431366 type : "day" ,
432- data : { date, tasks : allItemsForDay }
367+ data : { date, tasks : tasksForDay }
433368 } )
434369 }
435370
@@ -585,7 +520,6 @@ Description: ${event.description || "No description."}`
585520 ) : (
586521 < CalendarView
587522 tasks = { filteredCalendarTasks } // prettier-ignore
588- gcalEvents = { gcalEvents }
589523 onSelectTask = { handleSelectItem }
590524 onDayClick = { handleDayClick }
591525 onShowMoreClick = {
@@ -759,23 +693,6 @@ Description: ${event.description || "No description."}`
759693 }
760694 />
761695 </ motion . div >
762- ) : rightPanelContent . type === "gcal" &&
763- rightPanelContent . data ? (
764- < motion . div
765- key = { `gcal-${ rightPanelContent . data . id } ` }
766- initial = { { opacity : 0 } }
767- animate = { { opacity : 1 } }
768- exit = { { opacity : 0 } }
769- className = "h-full"
770- >
771- < GCalEventDetailsPanel
772- event = { rightPanelContent . data }
773- onClose = { handleCloseRightPanel }
774- onCreateTask = {
775- handleCreateTaskFromEvent
776- }
777- />
778- </ motion . div >
779696 ) : rightPanelContent . type === "day" &&
780697 rightPanelContent . data ? (
781698 < motion . div
0 commit comments