Skip to content

Commit

Permalink
add last 24h option to date filters
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspergrom committed Oct 19, 2023
1 parent 9baa1c2 commit cfc6178
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export const dateApiFilterRenderer = (property: string, { value, operator }: Dat
} else {
let parsedValue = moment.utc(mappedValue).startOf('day').toISOString();

if ([FilterDateOperator.GT].includes(operator)) {
if (['last24h'].includes(value as string)) {
parsedValue = mappedValue as string;
} else if ([FilterDateOperator.GT].includes(operator)) {
parsedValue = moment.utc(mappedValue).endOf('day').toISOString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ export const dateFilterOperators: FilterOperator[] = [
];

export const dateFilterTimePickerOptions: FilterTimeOptions[] = [
{
value: 'last24h',
label: 'Last 24 hours',
getDate: () => moment().subtract(24, 'hour').toISOString(),
},
{
value: 'last7days',
label: 'Last 7 days',
getDate: () => moment().subtract(1, 'week').format('YYYY-MM-DD'),
getDate: () => moment().subtract(7, 'day').format('YYYY-MM-DD'),
},
{
value: 'last14days',
Expand Down

0 comments on commit cfc6178

Please sign in to comment.