From f5149a17106aafddbffacc0b1a5b6d156f25436b Mon Sep 17 00:00:00 2001 From: Julian Bez Date: Mon, 17 Jun 2024 20:25:28 +0100 Subject: [PATCH] feat(insights): Use current date as rolling date range default (#23012) Use current date as date range default --- .../DateFilter/rollingDateRangeFilterLogic.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/lib/components/DateFilter/rollingDateRangeFilterLogic.ts b/frontend/src/lib/components/DateFilter/rollingDateRangeFilterLogic.ts index 65a44b4537560..6c71f0fe622c8 100644 --- a/frontend/src/lib/components/DateFilter/rollingDateRangeFilterLogic.ts +++ b/frontend/src/lib/components/DateFilter/rollingDateRangeFilterLogic.ts @@ -25,8 +25,8 @@ export type RollingDateFilterLogicPropsType = { pageKey?: string } -const counterDefault = (inUse: boolean | undefined, dateFrom: Dayjs | string | null | undefined): number => { - if (inUse && dateFrom && typeof dateFrom === 'string') { +const counterDefault = (dateFrom: Dayjs | string | null | undefined): number => { + if (dateFrom && typeof dateFrom === 'string') { const counter = parseInt(dateFrom.slice(1, -1)) if (counter) { return counter @@ -35,8 +35,8 @@ const counterDefault = (inUse: boolean | undefined, dateFrom: Dayjs | string | n return 3 } -const dateOptionDefault = (inUse: boolean | undefined, dateFrom: Dayjs | string | null | undefined): DateOption => { - if (inUse && dateFrom && typeof dateFrom === 'string') { +const dateOptionDefault = (dateFrom: Dayjs | string | null | undefined): DateOption => { + if (dateFrom && typeof dateFrom === 'string') { const dateOption = dateOptionsMap[dateFrom.slice(-1)] if (dateOption) { return dateOption @@ -59,7 +59,7 @@ export const rollingDateRangeFilterLogic = kea( }), reducers(({ props }) => ({ counter: [ - counterDefault(props.inUse, props.dateFrom) as number | null, + counterDefault(props.dateFrom) as number | null, { increaseCounter: (state) => (state ? (!props.max || state < props.max ? state + 1 : state) : 1), decreaseCounter: (state) => { @@ -73,7 +73,7 @@ export const rollingDateRangeFilterLogic = kea( }, ], dateOption: [ - dateOptionDefault(props.inUse, props.dateFrom), + dateOptionDefault(props.dateFrom), { setDateOption: (_, { option }) => option, },