diff --git a/frontend/app/components/BugFinder/SessionList/SessionListHeader.js b/frontend/app/components/BugFinder/SessionList/SessionListHeader.js
index bf4bf8b55..5e2702639 100644
--- a/frontend/app/components/BugFinder/SessionList/SessionListHeader.js
+++ b/frontend/app/components/BugFinder/SessionList/SessionListHeader.js
@@ -4,7 +4,10 @@ import SortDropdown from '../Filters/SortDropdown';
import { numberWithCommas } from 'App/utils';
import SelectDateRange from 'Shared/SelectDateRange';
import { applyFilter } from 'Duck/search';
-import Period from 'Types/app/period';
+import Record from 'Types/app/period';
+import { useStore } from 'App/mstore';
+import { useObserver } from 'mobx-react-lite';
+import { moment } from 'App/dateRange';
const sortOptionsMap = {
'startTs-desc': 'Newest',
@@ -15,13 +18,30 @@ const sortOptionsMap = {
const sortOptions = Object.entries(sortOptionsMap).map(([value, label]) => ({ value, label }));
function SessionListHeader({ activeTab, count, applyFilter, filter }) {
+ const { settingsStore } = useStore();
+
+ const label = useObserver(() => settingsStore.sessionSettings.timezone.label);
+ const getTimeZoneOffset = React.useCallback(() => {
+ return label.slice(-6);
+ }, [label]);
+
const { startDate, endDate, rangeValue } = filter;
- const period = new Period({ start: startDate, end: endDate, rangeName: rangeValue });
+ const period = new Record({ start: startDate, end: endDate, rangeName: rangeValue });
const onDateChange = (e) => {
const dateValues = e.toJSON();
+ dateValues.startDate = moment(dateValues.startDate).utcOffset(getTimeZoneOffset(), true).valueOf();
+ dateValues.endDate = moment(dateValues.endDate).utcOffset(getTimeZoneOffset(), true).valueOf();
applyFilter(dateValues);
};
+
+ React.useEffect(() => {
+ const dateValues = period.toJSON();
+ dateValues.startDate = moment(dateValues.startDate).startOf('day').utcOffset(getTimeZoneOffset(), true).valueOf();
+ dateValues.endDate = moment(dateValues.endDate).endOf('day').utcOffset(getTimeZoneOffset(), true).valueOf();
+ applyFilter(dateValues);
+ }, [label]);
+
return (
@@ -32,7 +52,7 @@ function SessionListHeader({ activeTab, count, applyFilter, filter }) {
{
Sessions Captured in
-
+
}
diff --git a/frontend/app/components/shared/SelectDateRange/SelectDateRange.tsx b/frontend/app/components/shared/SelectDateRange/SelectDateRange.tsx
index 12b6ba016..da8a940a5 100644
--- a/frontend/app/components/shared/SelectDateRange/SelectDateRange.tsx
+++ b/frontend/app/components/shared/SelectDateRange/SelectDateRange.tsx
@@ -6,17 +6,19 @@ import { components } from 'react-select';
import DateRangePopup from 'Shared/DateRangeDropdown/DateRangePopup';
import OutsideClickDetectingDiv from 'Shared/OutsideClickDetectingDiv';
import cn from 'classnames';
+import { observer } from 'mobx-react-lite';
interface Props {
period: any;
onChange: (data: any) => void;
disableCustom?: boolean;
right?: boolean;
+ timezone?: string;
[x: string]: any;
}
function SelectDateRange(props: Props) {
const [isCustom, setIsCustom] = React.useState(false);
- const { right = false, period, disableCustom = false, ...rest } = props;
+ const { right = false, period, disableCustom = false, timezone, ...rest } = props;
let selectedValue = DATE_RANGE_OPTIONS.find((obj: any) => obj.value === period.rangeName);
const options = DATE_RANGE_OPTIONS.filter((obj: any) => (disableCustom ? obj.value !== CUSTOM_RANGE : true));
@@ -24,15 +26,20 @@ function SelectDateRange(props: Props) {
if (value === CUSTOM_RANGE) {
setIsCustom(true);
} else {
+ // @ts-ignore
props.onChange(new Period({ rangeName: value }));
}
};
const onApplyDateRange = (value: any) => {
- props.onChange(new Period({ rangeName: CUSTOM_RANGE, start: value.start, end: value.end }));
+ // @ts-ignore
+ const range = new Period({ rangeName: CUSTOM_RANGE, start: value.start, end: value.end })
+ props.onChange(range);
setIsCustom(false);
};
+ const isCustomRange = period.rangeName === CUSTOM_RANGE;
+ const customRange = isCustomRange ? period.rangeFormatted(undefined, timezone) : '';
return (