Skip to content

Commit

Permalink
feat(insights): Use current date as rolling date range default (#23012)
Browse files Browse the repository at this point in the history
Use current date as date range default
  • Loading branch information
webjunkie authored Jun 17, 2024
1 parent 9497229 commit f5149a1
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -59,7 +59,7 @@ export const rollingDateRangeFilterLogic = kea<rollingDateRangeFilterLogicType>(
}),
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) => {
Expand All @@ -73,7 +73,7 @@ export const rollingDateRangeFilterLogic = kea<rollingDateRangeFilterLogicType>(
},
],
dateOption: [
dateOptionDefault(props.inUse, props.dateFrom),
dateOptionDefault(props.dateFrom),
{
setDateOption: (_, { option }) => option,
},
Expand Down

0 comments on commit f5149a1

Please sign in to comment.