Skip to content

Commit

Permalink
feat: hook up occurrence event filter
Browse files Browse the repository at this point in the history
  • Loading branch information
juliannemarik committed Sep 19, 2024
1 parent 1def175 commit 6f52444
Showing 1 changed file with 34 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,14 @@ export async function processFilters(
"startDateRange"
);
if (startDateRange.length) {
processedFilters.startDateTimeBefore = new Date(
startDateRange[0].to
).toISOString();
processedFilters.startDateTimeAfter = new Date(
startDateRange[0].from
).toISOString();
startDateRange[0].to &&
(processedFilters.startDateTimeBefore = new Date(
startDateRange[0].to
).toISOString());
startDateRange[0].from &&
(processedFilters.startDateTimeAfter = new Date(
startDateRange[0].from
).toISOString());
}
const endDateRange = getPredicateValuesByKey<IDateRange<string | number>>(
filters,
Expand All @@ -124,14 +126,34 @@ export async function processFilters(
if (endDateRange.length) {
// TODO: remove below ts-ignore once https://devtopia.esri.com/dc/hub/issues/11097 is resolved
// @ts-ignore
processedFilters.endDateTimeBefore = new Date(
endDateRange[0].to
).toISOString();
endDateRange[0].to &&
(processedFilters.endDateTimeBefore = new Date(
endDateRange[0].to
).toISOString());
// TODO: remove below ts-ignore once https://devtopia.esri.com/dc/hub/issues/11097 is resolved
// @ts-ignore
processedFilters.endDateTimeAfter = new Date(
endDateRange[0].from
).toISOString();
endDateRange[0].from &&
(processedFilters.endDateTimeAfter = new Date(
endDateRange[0].from
).toISOString());
}

const occurrence = getPredicateValuesByKey<string>(filters, "occurrence");
if (occurrence.length) {
occurrence.forEach((o) => {
switch (o) {
case "upcoming":
processedFilters.startDateTimeAfter = new Date().toISOString();
break;
case "past":
processedFilters.endDateTimeBefore = new Date().toISOString();
break;
case "inProgress":
processedFilters.startDateTimeBefore = new Date().toISOString();
processedFilters.endDateTimeAfter = new Date().toISOString();
break;
}
});
}
return processedFilters;
}

0 comments on commit 6f52444

Please sign in to comment.