fix: stats on /insights/routing (#18985)
* fix: replace filter implementation on /insights/routing * remove unused functions * fix type error * refactor: extract insights parameters * remove FiltersProvider
This commit is contained in:
1 parent
195e645f24
commit
fdc8e084ea
16 files changed
+357
-327
No files matched your search
@@ -111,6 +111,20 @@ export const numberFilter = (cellValue: unknown, filterValue: NumberFilterValue)
|
||||
return false;
|
||||
};
|
||||
|
||||
export const dateRangeFilter = (cellValue: unknown, filterValue: DateRangeFilterValue) => {
|
||||
if (!(cellValue instanceof Date)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!filterValue.data.startDate || !filterValue.data.endDate) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const cellValueStr = cellValue.toISOString();
|
||||
|
||||
return filterValue.data.startDate <= cellValueStr && filterValue.data.endDate >= cellValueStr;
|
||||
};
|
||||
|
||||
export const isNumberFilterValue = (filterValue: unknown): filterValue is NumberFilterValue => {
|
||||
return ZNumberFilterValue.safeParse(filterValue).success;
|
||||
};
|
||||
@@ -128,6 +142,8 @@ export const dataTableFilter = (cellValue: unknown, filterValue: FilterValue) =>
|
||||
return textFilter(cellValue, filterValue);
|
||||
} else if (isNumberFilterValue(filterValue)) {
|
||||
return numberFilter(cellValue, filterValue);
|
||||
} else if (isDateRangeFilterValue(filterValue)) {
|
||||
return dateRangeFilter(cellValue, filterValue);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Reference in new issue
Block a user