Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dashboard filters): add "previous quarter" as option #30506

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export const parseDttmToDate = (
now.setMonth(now.getMonth() - 1);
}
return now;
case 'previous quarter':
personofnorank marked this conversation as resolved.
Show resolved Hide resolved
quarter = Math.floor(now.getMonth() / 3);
now.setDate(now.getFullYear(), quarter * 3 - 3, 1);
return now;
case 'previous calendar year':
if (isEndDate) {
now.setFullYear(now.getFullYear(), 0, 1); // end date is the last day of the previous year
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ export type CommonRangeType =

export const PreviousCalendarWeek = 'previous calendar week';
export const PreviousCalendarMonth = 'previous calendar month';
export const PreviousQuarter = 'previous quarter';
personofnorank marked this conversation as resolved.
Show resolved Hide resolved
export const PreviousCalendarYear = 'previous calendar year';
export type CalendarRangeType =
| typeof PreviousCalendarWeek
| typeof PreviousCalendarMonth
| typeof PreviousQuarter
| typeof PreviousCalendarYear;

export const CurrentDay = 'Current day';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
SelectOptionType,
PreviousCalendarWeek,
PreviousCalendarMonth,
PreviousQuarter,
PreviousCalendarYear,
CommonRangeType,
CalendarRangeType,
Expand Down Expand Up @@ -56,6 +57,7 @@ export const COMMON_RANGE_VALUES_SET = new Set(
export const CALENDAR_RANGE_OPTIONS: SelectOptionType[] = [
{ value: PreviousCalendarWeek, label: t('previous calendar week') },
{ value: PreviousCalendarMonth, label: t('previous calendar month') },
{ value: PreviousQuarter, label: t('previous quarter') },
{ value: PreviousCalendarYear, label: t('previous calendar year') },
];
export const CALENDAR_RANGE_VALUES_SET = new Set(
Expand Down Expand Up @@ -119,6 +121,7 @@ export const COMMON_RANGE_SET: Set<CommonRangeType> = new Set([
export const CALENDAR_RANGE_SET: Set<CalendarRangeType> = new Set([
PreviousCalendarWeek,
PreviousCalendarMonth,
PreviousQuarter,
PreviousCalendarYear,
]);

Expand Down