diff --git a/frontend/src/app/components/containers/complaints/complaint-filter.tsx b/frontend/src/app/components/containers/complaints/complaint-filter.tsx index bb080652a..48f66d3fd 100644 --- a/frontend/src/app/components/containers/complaints/complaint-filter.tsx +++ b/frontend/src/app/components/containers/complaints/complaint-filter.tsx @@ -82,7 +82,6 @@ export const ComplaintFilter: FC = ({ type }) => { const handleDateRangeChange = (dates: [Date, Date]) => { const [start, end] = dates; - setFilter("startDate", start); //set the time to be end of day to ensure that we also search for records after the beginning of the selected day. if (start) { start.setHours(0, 0, 0); @@ -93,6 +92,7 @@ export const ComplaintFilter: FC = ({ type }) => { end.setMilliseconds(999); } + setFilter("startDate", start); setFilter("endDate", end); }; diff --git a/frontend/src/app/providers/complaint-filter-provider.tsx b/frontend/src/app/providers/complaint-filter-provider.tsx index 309ba4aa4..9f4678565 100644 --- a/frontend/src/app/providers/complaint-filter-provider.tsx +++ b/frontend/src/app/providers/complaint-filter-provider.tsx @@ -52,13 +52,24 @@ const mapFilters = (complaintFilters: Partial) => { natureOfComplaintFilter, outcomeAnimalFilter, } = complaintFilters; + + // Parse the start and end date filters into Date objects if they exist. + const parsedStartDate = startDateFilter ? new Date(startDateFilter) : undefined; + // If start date is set and end date is not, default to current date for end date. + let parsedEndDate = undefined; + if (endDateFilter) { + parsedEndDate = new Date(endDateFilter); + } else if (parsedStartDate) { + parsedEndDate = new Date(); + } + const allFilters: Partial = { region: regionCodeFilter, zone: zoneCodeFilter, community: areaCodeFilter, officer: officerFilter, - startDate: startDateFilter, - endDate: endDateFilter, + startDate: parsedStartDate, + endDate: parsedEndDate, status: complaintStatusFilter, species: speciesCodeFilter, complaintMethod: complaintMethodFilter, diff --git a/frontend/src/app/store/reducers/complaints.ts b/frontend/src/app/store/reducers/complaints.ts index a782ed69c..ab21563ce 100644 --- a/frontend/src/app/store/reducers/complaints.ts +++ b/frontend/src/app/store/reducers/complaints.ts @@ -371,6 +371,7 @@ export const getMappedComplaints = try { dispatch(setComplaint(null)); + dispatch(setComplaintSearchParameters(payload)); let parameters = generateApiParameters(`${config.API_BASE_URL}/v1/complaint/map/search/${complaintType}`, { sortBy: sortColumn,