From c27ff73ece0106a659526c6beb5f4b64a043de17 Mon Sep 17 00:00:00 2001 From: Jacob Boyles Date: Thu, 27 Mar 2025 11:16:33 -0400 Subject: [PATCH 1/2] stop update flood of stats ordering --- app/statistics/page.tsx | 21 ++++++++++++++------- components/Sidebar.tsx | 1 - 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/statistics/page.tsx b/app/statistics/page.tsx index c9e363b..e3b2585 100644 --- a/app/statistics/page.tsx +++ b/app/statistics/page.tsx @@ -19,6 +19,7 @@ import { import { Response } from "@/models/response"; import { Stats } from "@/models/stats"; import { getUserStatusString } from "@/utils/enums"; +import { set } from "date-fns"; import { ChevronLeft, ChevronRight } from "lucide-react"; import { useRouter, useSearchParams } from "next/navigation"; import { useContext, useEffect, useState } from "react"; @@ -36,6 +37,7 @@ export default function StaffingRequest() { const [year, setYear] = useState(parseInt(params.get("year") as string)); const [loading, setLoading] = useState(true); + const [updated, setUpdated] = useState(false); const [stats, setStats] = useState([] as Stats[]); useEffect(() => { @@ -65,17 +67,21 @@ export default function StaffingRequest() { setLoading(false); }); } - const currentParams = Object.fromEntries(params.entries()); - const newParams = { ...currentParams, month: `${month}`, year: `${year}` }; - const queryString = new URLSearchParams(newParams).toString(); - router.push(`?${queryString}`, { scroll: false }); - setLoading(false); - }, [authContext, month, params, router, year]); + if (updated) { + const currentParams = Object.fromEntries(params.entries()); + const newParams = { ...currentParams, month: `${month}`, year: `${year}` }; + const queryString = new URLSearchParams(newParams).toString(); + + router.push(`?${queryString}`, { scroll: false }); + setLoading(false); + setUpdated(false); + } + }, [authContext, month, params, router, updated, year]); const nextMonth = () => { setLoading(true); - + setUpdated(true); setMonth((prevMonth) => { let newMonth = prevMonth + 1; let newYear = year; @@ -90,6 +96,7 @@ export default function StaffingRequest() { const previousMonth = () => { setLoading(true); + setUpdated(true); setMonth((prevMonth) => { let newMonth = prevMonth - 1; let newYear = year; diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx index 6765f0a..f210431 100644 --- a/components/Sidebar.tsx +++ b/components/Sidebar.tsx @@ -34,7 +34,6 @@ const Sideabr = () => { fetchOnlineControllers() .then((response) => { - console.log(response); setOnlineControllers(response.data); }) .catch((error) => { From d619cc9e4ccb5781ea120e3fa19f011a6e8cf490 Mon Sep 17 00:00:00 2001 From: Jacob Boyles Date: Thu, 27 Mar 2025 11:17:20 -0400 Subject: [PATCH 2/2] remove unintended import --- app/statistics/page.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/statistics/page.tsx b/app/statistics/page.tsx index e3b2585..2113d8a 100644 --- a/app/statistics/page.tsx +++ b/app/statistics/page.tsx @@ -19,7 +19,6 @@ import { import { Response } from "@/models/response"; import { Stats } from "@/models/stats"; import { getUserStatusString } from "@/utils/enums"; -import { set } from "date-fns"; import { ChevronLeft, ChevronRight } from "lucide-react"; import { useRouter, useSearchParams } from "next/navigation"; import { useContext, useEffect, useState } from "react";