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:
+21
-3
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user