From 13df1100156bdb0f25e7b5ed7fc805da75d72be1 Mon Sep 17 00:00:00 2001 From: majkshkurti Date: Tue, 22 Oct 2024 17:50:14 +0200 Subject: [PATCH] fix: goat-community/goat#3229 --- apps/web/app/[lng]/(dashboard)/datasets/page.tsx | 11 ++++++++++- apps/web/app/[lng]/(dashboard)/projects/page.tsx | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/web/app/[lng]/(dashboard)/datasets/page.tsx b/apps/web/app/[lng]/(dashboard)/datasets/page.tsx index 39a99e6..a3be99c 100644 --- a/apps/web/app/[lng]/(dashboard)/datasets/page.tsx +++ b/apps/web/app/[lng]/(dashboard)/datasets/page.tsx @@ -16,7 +16,7 @@ import { Typography, } from "@mui/material"; import { useRouter } from "next/navigation"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { ICON_NAME, Icon } from "@p4b/ui/components/Icon"; @@ -93,6 +93,15 @@ const Datasets = () => { }, ]; + useEffect(() => { + if (datasets?.pages && queryParams?.page && datasets?.pages < queryParams?.page) { + setQueryParams({ + ...queryParams, + page: datasets.pages, + }); + } + }, [datasets, queryParams]); + return ( {addDatasetModal === AddLayerSourceType.DatasourceUpload && ( diff --git a/apps/web/app/[lng]/(dashboard)/projects/page.tsx b/apps/web/app/[lng]/(dashboard)/projects/page.tsx index 5869fab..d1394c0 100644 --- a/apps/web/app/[lng]/(dashboard)/projects/page.tsx +++ b/apps/web/app/[lng]/(dashboard)/projects/page.tsx @@ -2,7 +2,7 @@ import { Box, Button, Container, Grid, Pagination, Paper, Stack, Typography } from "@mui/material"; import { useRouter } from "next/navigation"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { ICON_NAME, Icon } from "@p4b/ui/components/Icon"; @@ -34,6 +34,15 @@ const Projects = () => { const [openProjectModal, setOpenProjectModal] = useState(false); const { isOrgEditor } = useAuthZ(); + useEffect(() => { + if (projects?.pages && queryParams?.page && projects?.pages < queryParams?.page) { + setQueryParams({ + ...queryParams, + page: projects.pages, + }); + } + }, [projects, queryParams]); + return ( setOpenProjectModal(false)} />