fix(dashboard): table inclusive date filter (#13053)

**What**
- make end date inclusive for search results

---

https://github.com/user-attachments/assets/8367ffd1-e882-44a9-a876-a8e4731a6cd5

---

CLOSES CMRC-1072
This commit is contained in:
Frane Polić
2025-08-18 14:55:39 +02:00
committed by GitHub
parent 6d8e4acdc7
commit 20b8187e2a
2 changed files with 26 additions and 3 deletions
@@ -69,12 +69,19 @@ export const DateFilter = ({
const handleCustomDateChange = (value: Date | null, pos: "start" | "end") => {
const key = pos === "start" ? "$gte" : "$lte"
const dateValue = value ? value.toISOString() : undefined
let dateValue = value
// offset to the end of the day so the results include the selected end date
if (key === "$lte" && value) {
dateValue = new Date(value.getTime())
dateValue.setHours(23, 59, 59, 999)
}
selectedParams.add(
JSON.stringify({
...(currentDateComparison || {}),
[key]: dateValue,
[key]: dateValue?.toISOString(),
})
)
}
@@ -306,5 +313,16 @@ const getDateFromComparison = (
comparison: DateComparisonOperator | null,
key: "$gte" | "$lte"
) => {
return comparison?.[key] ? new Date(comparison[key] as string) : undefined
if (!comparison?.[key]) {
return undefined
}
const compareDate = new Date(comparison[key] as string)
if (key === "$lte") {
// offset back to the display date
compareDate.setHours(0, 0, 0, 0)
}
return compareDate
}