fix: refactor filter UIs on /bookings (#19532)
* Reapply "fix: replace filter implementations on bookings (#19445)" (#19506)
This reverts commit f6af6e34bd.
* force custom date range selector for bookings except for Past tab
* fix e2e test
* add e2e tests
* fix e2e test
This commit is contained in:
1 parent
ca1f84c827
commit
3d3acba82a
19 files changed
+658
-215
No files matched your search
@@ -116,11 +116,21 @@ export const ZFilterValue = z.union([
|
||||
ZDateRangeFilterValue,
|
||||
]);
|
||||
|
||||
export type ColumnFilterMeta = {
|
||||
type?: ColumnFilterType;
|
||||
icon?: IconName;
|
||||
export type DateRangeFilterOptions = {
|
||||
range: "past" | "custom";
|
||||
};
|
||||
|
||||
export type ColumnFilterMeta =
|
||||
| {
|
||||
type: ColumnFilterType.DATE_RANGE;
|
||||
icon?: IconName;
|
||||
dateRangeOptions: DateRangeFilterOptions;
|
||||
}
|
||||
| {
|
||||
type?: Exclude<ColumnFilterType, ColumnFilterType.DATE_RANGE>;
|
||||
icon?: IconName;
|
||||
};
|
||||
|
||||
export type FilterableColumn = {
|
||||
id: string;
|
||||
title: string;
|
||||
@@ -128,11 +138,11 @@ export type FilterableColumn = {
|
||||
} & (
|
||||
| {
|
||||
type: ColumnFilterType.SINGLE_SELECT;
|
||||
options: Array<{ label: string; value: string | number }>;
|
||||
options: FacetedValue[];
|
||||
}
|
||||
| {
|
||||
type: ColumnFilterType.MULTI_SELECT;
|
||||
options: Array<{ label: string; value: string | number }>;
|
||||
options: FacetedValue[];
|
||||
}
|
||||
| {
|
||||
type: ColumnFilterType.TEXT;
|
||||
@@ -142,6 +152,7 @@ export type FilterableColumn = {
|
||||
}
|
||||
| {
|
||||
type: ColumnFilterType.DATE_RANGE;
|
||||
dateRangeOptions?: DateRangeFilterOptions;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -186,4 +197,5 @@ export const ZColumnVisibility = z.record(z.string(), z.boolean());
|
||||
export type FacetedValue = {
|
||||
label: string;
|
||||
value: string | number;
|
||||
section?: string;
|
||||
};
|
||||
@@ -151,7 +151,7 @@ export const dataTableFilter = (cellValue: unknown, filterValue: FilterValue) =>
|
||||
|
||||
export const convertFacetedValuesToMap = (array: FacetedValue[]) => {
|
||||
return new Map<FacetedValue, number>(
|
||||
array.map((option) => [{ label: option.label, value: option.value }, 1])
|
||||
array.map((option) => [{ label: option.label, value: option.value, section: option.section }, 1])
|
||||
);
|
||||
};
|
||||
|
||||
@@ -161,8 +161,8 @@ export const convertMapToFacetedValues = (map: Map<FacetedValue, number> | undef
|
||||
}
|
||||
return Array.from(map.keys()).map((option) => {
|
||||
if (typeof option === "string") {
|
||||
return { label: option, value: option };
|
||||
return { label: option, value: option, section: undefined };
|
||||
}
|
||||
return { label: option.label as string, value: option.value as string | number };
|
||||
return { label: option.label as string, value: option.value as string | number, section: option.section };
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user