diff --git a/src/components/Dashboard.tsx b/src/components/Dashboard.tsx index 361dd05..8e2e3bf 100644 --- a/src/components/Dashboard.tsx +++ b/src/components/Dashboard.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useState, useEffect, useCallback } from 'react'; +import { useState, useEffect, useCallback, useRef } from 'react'; import { User } from '@/lib/session'; import { fetchPreferences, @@ -34,7 +34,7 @@ import { HealthTimelineCard } from './HealthTimelineCard'; import { SavingsTrackerCard } from './SavingsTrackerCard'; import { MoodTracker } from './MoodTracker'; import { Button } from '@/components/ui/button'; -import { PlusCircle } from 'lucide-react'; +import { PlusCircle, ChevronLeft, ChevronRight } from 'lucide-react'; import { useTheme } from '@/lib/theme-context'; import { getTodayString } from '@/lib/date-utils'; @@ -53,8 +53,29 @@ export function Dashboard({ user }: DashboardProps) { const [newBadge, setNewBadge] = useState(null); const [isLoading, setIsLoading] = useState(true); const [refreshKey, setRefreshKey] = useState(0); + const [currentPage, setCurrentPage] = useState(0); + const swipeContainerRef = useRef(null); const { theme } = useTheme(); + const handleScroll = useCallback(() => { + if (!swipeContainerRef.current) return; + const scrollLeft = swipeContainerRef.current.scrollLeft; + const width = swipeContainerRef.current.offsetWidth; + const page = Math.round(scrollLeft / width); + if (page !== currentPage) { + setCurrentPage(page); + } + }, [currentPage]); + + const scrollToPage = (pageIndex: number) => { + if (!swipeContainerRef.current) return; + const width = swipeContainerRef.current.offsetWidth; + swipeContainerRef.current.scrollTo({ + left: pageIndex * width, + behavior: 'smooth' + }); + }; + const loadData = useCallback(async () => { const [prefs, usage, achvs, savings] = await Promise.all([ fetchPreferences(), @@ -235,10 +256,41 @@ export function Dashboard({ user }: DashboardProps) { {/* Dashboard Sections */} -
+
+ {/* Mobile Navigation Buttons */} +
+ {currentPage > 0 && ( + + )} + {currentPage < 3 && ( + + )} +
{/* SECTION: Mobile Swipe Ecosystem */} -
+
{/* SLIDE 1: Mindset (Mood & Personalized Plan) */}