From cfc61780627cd5551cd66c585c48f571cca933e2 Mon Sep 17 00:00:00 2001 From: Gasper Grom Date: Thu, 19 Oct 2023 17:53:00 +0700 Subject: [PATCH] add last 24h option to date filters --- .../config/apiFilterRenderer/date.filter.renderer.ts | 4 +++- .../modules/filters/config/constants/date.constants.ts | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/shared/modules/filters/config/apiFilterRenderer/date.filter.renderer.ts b/frontend/src/shared/modules/filters/config/apiFilterRenderer/date.filter.renderer.ts index d38b8ffca6..c7774d6129 100644 --- a/frontend/src/shared/modules/filters/config/apiFilterRenderer/date.filter.renderer.ts +++ b/frontend/src/shared/modules/filters/config/apiFilterRenderer/date.filter.renderer.ts @@ -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(); } diff --git a/frontend/src/shared/modules/filters/config/constants/date.constants.ts b/frontend/src/shared/modules/filters/config/constants/date.constants.ts index da2a16f519..3eaffcdd22 100644 --- a/frontend/src/shared/modules/filters/config/constants/date.constants.ts +++ b/frontend/src/shared/modules/filters/config/constants/date.constants.ts @@ -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',