Skip to content

Commit

Permalink
Merge pull request #1 from the-bay-kay/diary_wsod_fix
Browse files Browse the repository at this point in the history
🗓️ Fixed WSOD on Metric Date Selector
  • Loading branch information
JGreenlee authored Jan 9, 2024
2 parents 68ae2bb + 5166bef commit 27e7a51
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions www/js/metrics/MetricsDateSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,24 @@ const MetricsDateSelect = ({ dateRange, setDateRange }: Props) => {

const onChoose = useCallback(
({ startDate, endDate }) => {
const dtStartDate = DateTime.fromJSDate(startDate).startOf('day');
let dtEndDate;

if (!endDate) {
// If no end date selected, pull range from then till present day
dtEndDate = DateTime.now();
} else if (
dtStartDate.toString() === DateTime.fromJSDate(endDate).startOf('day').toString()
) {
// For when only one day is selected
// NOTE: As written, this technically timestamp will technically fetch _two_ days.
// For more info, see: https://github.com/e-mission/e-mission-docs/issues/1027
dtEndDate = dtStartDate.endOf('day');
} else {
dtEndDate = DateTime.fromJSDate(endDate).startOf('day');
}
setOpen(false);
setDateRange([
DateTime.fromJSDate(startDate).startOf('day'),
DateTime.fromJSDate(endDate).startOf('day'),
]);
setDateRange([dtStartDate, dtEndDate]);
},
[setOpen, setDateRange],
);
Expand Down

0 comments on commit 27e7a51

Please sign in to comment.