Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CE-1276 1277 stored filter fixes #778

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export const ComplaintFilter: FC<Props> = ({ 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);
Expand All @@ -93,6 +92,7 @@ export const ComplaintFilter: FC<Props> = ({ type }) => {
end.setMilliseconds(999);
}

setFilter("startDate", start);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change didn't seem to be affecting the bug but I stumbled across it and it seems like if we're setting the time on start we should do so before setting the startDate filter.

setFilter("endDate", end);
};

Expand Down
10 changes: 8 additions & 2 deletions frontend/src/app/providers/complaint-filter-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@ const mapFilters = (complaintFilters: Partial<ComplaintFilters>) => {
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.
const parsedEndDate = endDateFilter ? new Date(endDateFilter) : parsedStartDate ? new Date() : undefined;
afwilcox marked this conversation as resolved.
Show resolved Hide resolved

const allFilters: Partial<ComplaintFilters> = {
region: regionCodeFilter,
zone: zoneCodeFilter,
community: areaCodeFilter,
officer: officerFilter,
startDate: startDateFilter,
endDate: endDateFilter,
startDate: parsedStartDate,
endDate: parsedEndDate,
status: complaintStatusFilter,
species: speciesCodeFilter,
complaintMethod: complaintMethodFilter,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/store/reducers/complaints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down