From 3d7acb5cb36a2cd82a38e88daf851eb114bfefcb Mon Sep 17 00:00:00 2001 From: Ryan Rondeau Date: Thu, 12 Dec 2024 15:54:51 -0800 Subject: [PATCH 1/2] Update complaint-map-with-server-side-clustering.tsx --- ...plaint-map-with-server-side-clustering.tsx | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/components/containers/complaints/complaint-map-with-server-side-clustering.tsx b/frontend/src/app/components/containers/complaints/complaint-map-with-server-side-clustering.tsx index aa43457d6..d047f51b8 100644 --- a/frontend/src/app/components/containers/complaints/complaint-map-with-server-side-clustering.tsx +++ b/frontend/src/app/components/containers/complaints/complaint-map-with-server-side-clustering.tsx @@ -1,13 +1,20 @@ import { FC, useState, useContext, useEffect, useCallback } from "react"; -import { useAppDispatch } from "@hooks/hooks"; +import { useAppDispatch, useAppSelector } from "@hooks/hooks"; import COMPLAINT_TYPES from "@apptypes/app/complaint-types"; +import { SORT_TYPES } from "@constants/sort-direction"; import { ComplaintFilterContext } from "@providers/complaint-filter-provider"; import { ComplaintFilters } from "@apptypes/complaints/complaint-filters/complaint-filters"; import { ComplaintRequestPayload } from "@/app/types/complaints/complaint-filters/complaint-request-payload"; import LeafletMapWithServerSideClustering from "@components/mapping/leaflet-map-with-server-side-clustering"; import { generateApiParameters, get } from "@common/api"; import config from "@/config"; -import { setComplaint, setComplaintSearchParameters, setMappedComplaintsCount } from "@/app/store/reducers/complaints"; +import { + selectComplaintSearchParameters, + setComplaint, + setComplaintSearchParameters, + setMappedComplaintsCount, +} from "@/app/store/reducers/complaints"; +import { selectDefaultPageSize } from "@/app/store/reducers/app"; type Props = { type: string; @@ -17,11 +24,13 @@ type Props = { export const generateMapComplaintRequestPayload = ( complaintType: string, filters: ComplaintFilters, + page: number, + pageSize: number, + sortColumn: string, + sortOrder: string, searchQuery: string, ): ComplaintRequestPayload => { const { - sortColumn, - sortOrder, region, zone, community, @@ -53,6 +62,8 @@ export const generateMapComplaintRequestPayload = ( outcomeAnimalStartDateFilter: outcomeAnimalStartDate, outcomeAnimalEndDateFilter: outcomeAnimalEndDate, query: searchQuery, + page, + pageSize, }; switch (complaintType) { @@ -84,6 +95,8 @@ export const ComplaintMapWithServerSideClustering: FC = ({ type, searchQu //-- the state from the context is not the same state as used in the rest of the application //-- this is self-contained, rename the state locally to make clear const { state: filters } = useContext(ComplaintFilterContext); + const defaultPageSize = useAppSelector(selectDefaultPageSize); + const storedSearchParams = useAppSelector(selectComplaintSearchParameters); const fetchMapData = useCallback( async ( @@ -100,7 +113,15 @@ export const ComplaintMapWithServerSideClustering: FC = ({ type, searchQu }, ) => { setLoadingMapData(true); - let payload = generateMapComplaintRequestPayload(type, filters, searchQuery); + let payload = generateMapComplaintRequestPayload( + type, + filters, + storedSearchParams.page || 1, + storedSearchParams.pageSize || defaultPageSize, + storedSearchParams.sortColumn, + storedSearchParams.sortOrder, + searchQuery, + ); dispatch(setComplaint(null)); dispatch(setComplaintSearchParameters(payload)); From 4a803b5f135a9097c9062b5771b02f2c40363c5c Mon Sep 17 00:00:00 2001 From: Ryan Rondeau Date: Thu, 12 Dec 2024 16:09:20 -0800 Subject: [PATCH 2/2] Update complaint-map-with-server-side-clustering.tsx --- .../complaints/complaint-map-with-server-side-clustering.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/app/components/containers/complaints/complaint-map-with-server-side-clustering.tsx b/frontend/src/app/components/containers/complaints/complaint-map-with-server-side-clustering.tsx index d047f51b8..194a2a213 100644 --- a/frontend/src/app/components/containers/complaints/complaint-map-with-server-side-clustering.tsx +++ b/frontend/src/app/components/containers/complaints/complaint-map-with-server-side-clustering.tsx @@ -1,7 +1,6 @@ import { FC, useState, useContext, useEffect, useCallback } from "react"; import { useAppDispatch, useAppSelector } from "@hooks/hooks"; import COMPLAINT_TYPES from "@apptypes/app/complaint-types"; -import { SORT_TYPES } from "@constants/sort-direction"; import { ComplaintFilterContext } from "@providers/complaint-filter-provider"; import { ComplaintFilters } from "@apptypes/complaints/complaint-filters/complaint-filters"; import { ComplaintRequestPayload } from "@/app/types/complaints/complaint-filters/complaint-request-payload";