Skip to content

Commit

Permalink
X2-10394 Cannot filter by date range in Purchases tab for seller (#341)
Browse files Browse the repository at this point in the history
* X2-10394 fixing undefined getTime

* X2-10394 fixing undefined getTime

* X2-10394 fixing undefined getTime

* X2-10394 fixing undefined getTime

* X2-10394 adding comment

* X2-10394 adding comment
  • Loading branch information
shivbang authored Aug 21, 2024
1 parent 9289027 commit 5f3a2cc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/components/DatePicker/DatePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,17 @@ export const DatePicker = ({
const to = toDate(now(day, timezoneName).endOf("day"), false);

onChange({ from, to }, options, event);
} else if (DateUtils.isDayBefore(value.from, toDate(now(day, timezoneName)))) {
} else if (value.from && DateUtils.isDayBefore(value.from, toDate(now(day, timezoneName)))) {
// this works if the user first clicked on the date that will go to "from", and the second click to "to"
onChange(
DateUtils.addDayToRange(toDate(now(day, timezoneName).endOf("day"), false), value),
options,
event,
);
} else if (
DateUtils.isDayAfter(value.from, toDate(now(day, timezoneName))) ||
DateUtils.isSameDay(value.from, toDate(now(day, timezoneName)))
value.from &&
(DateUtils.isDayAfter(value.from, toDate(now(day, timezoneName))) ||
DateUtils.isSameDay(value.from, toDate(now(day, timezoneName))))
) {
// this works if the user first clicked on the date that will go to "to", and the second click to "from"
// also this works when the user has selected one date
Expand All @@ -166,6 +167,13 @@ export const DatePicker = ({
options,
event,
);
} else {
// Fallback when value.from is null
onChange(
DateUtils.addDayToRange(toDate(now(day, timezoneName).endOf("day"), false), value),
options,
event,
);
}
} else {
onChange(toDate(now(day, timezoneName)), options, event);
Expand Down

0 comments on commit 5f3a2cc

Please sign in to comment.