mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
Date & Time: only show date for date filters
This commit is contained in:
@@ -75,7 +75,7 @@ export default function FiltersPopover({
|
||||
);
|
||||
|
||||
const formattedValue = availableFilters?.valueFormatter
|
||||
? availableFilters.valueFormatter(filter.value)
|
||||
? availableFilters.valueFormatter(filter.value, filter.operator)
|
||||
: filter.value.toString();
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { format } from "date-fns";
|
||||
import { DATE_TIME_FORMAT } from "@src/constants/dates";
|
||||
import { DATE_TIME_FORMAT, DATE_FORMAT } from "@src/constants/dates";
|
||||
import { IFilterOperator } from "@src/components/fields/types";
|
||||
|
||||
export const filterOperators: IFilterOperator[] = [
|
||||
@@ -71,7 +71,11 @@ export const filterOperators: IFilterOperator[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const valueFormatter = (value: any) => {
|
||||
if (value && value.toDate) return format(value.toDate(), DATE_TIME_FORMAT);
|
||||
export const valueFormatter = (value: any, operator: string) => {
|
||||
if (value && value.toDate)
|
||||
return format(
|
||||
value.toDate(),
|
||||
operator.startsWith("date") ? DATE_FORMAT : DATE_TIME_FORMAT
|
||||
);
|
||||
return "";
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ export interface IFieldConfig {
|
||||
operators: IFilterOperator[];
|
||||
customInput?: React.ComponentType<IFilterCustomInputProps>;
|
||||
defaultValue?: any;
|
||||
valueFormatter?: (value: any) => string;
|
||||
valueFormatter?: (value: any, operator: TableFilter["operator"]) => string;
|
||||
};
|
||||
sortKey?: string;
|
||||
csvExportFormatter?: (value: any, config?: any) => string;
|
||||
|
||||
Reference in New Issue
Block a user