diff --git a/app/components/ui/Dashboard.tsx b/app/components/ui/Dashboard.tsx index 3fe0a7ea..3f125159 100644 --- a/app/components/ui/Dashboard.tsx +++ b/app/components/ui/Dashboard.tsx @@ -1,4 +1,4 @@ -import React, { useRef } from "react"; +import React, { useRef, useState } from "react"; import GraphCard from "./GraphCard"; import { Household } from "@/app/models/Household"; @@ -8,6 +8,9 @@ interface DashboardProps { const Dashboard: React.FC = ({ data }) => { const scrollContainerRef = useRef(null); + const [currentPage, setCurrentPage] = useState(0); + const totalPages = 6; + const handleNext = () => { if (scrollContainerRef.current) { scrollContainerRef.current.scrollBy({ @@ -15,6 +18,16 @@ const Dashboard: React.FC = ({ data }) => { behavior: "smooth", }); } + setCurrentPage((prev) => Math.min(prev + 1, totalPages - 1)); + }; + + const handleScroll = () => { + if (scrollContainerRef.current) { + const scrollTop = scrollContainerRef.current.scrollTop; + const pageHeight = window.innerHeight; + const newPage = Math.round(scrollTop / pageHeight); + setCurrentPage(newPage); + } }; // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -22,7 +35,11 @@ const Dashboard: React.FC = ({ data }) => { return (
-
+
Not much @@ -35,15 +52,16 @@ const Dashboard: React.FC = ({ data }) => {
- -
- -
+ {currentPage < totalPages - 1 && ( +
+ +
+ )}
); };