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ć authored and GitHub committed 2025-08-18 12:55:39 +00:00
1 parent 6d8e4acdc7
commit 20b8187e2a
2 files changed
+26 -3

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/dashboard": patch
---
fix(dashboard): include end of the range date in filter results
@@ -69,12 +69,19 @@ export const DateFilter = ({
const handleCustomDateChange = (value: Date | null, pos: "start" | "end") => { const handleCustomDateChange = (value: Date | null, pos: "start" | "end") => {
const key = pos === "start" ? "$gte" : "$lte" 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( selectedParams.add(
JSON.stringify({ JSON.stringify({
...(currentDateComparison || {}), ...(currentDateComparison || {}),
[key]: dateValue, [key]: dateValue?.toISOString(),
}) })
) )
} }
@@ -306,5 +313,16 @@ const getDateFromComparison = (
comparison: DateComparisonOperator | null, comparison: DateComparisonOperator | null,
key: "$gte" | "$lte" 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
} }