Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.setState(oldState => {
let oldTimeTo = oldState.queryParams.timeTo;
if (DateUtils.isDayAfter(new Date(e), new Date(oldTimeTo))) {
oldTimeTo = DateUtils.addMonths(new Date(e), 1);
}
return {
queryParams: {
...oldState.queryParams,
timeFrom: moment(e),
timeTo: moment(oldTimeTo),
},
};
});
}
this.setState(oldState => {
let oldTimeFrom = oldState.queryParams.timeFrom;
if (DateUtils.isDayBefore(new Date(e), new Date(oldTimeFrom))) {
oldTimeFrom = DateUtils.addMonths(new Date(e), -1);
}
return {
queryParams: {
...oldState.queryParams,
timeTo: moment(e),
timeFrom: moment(oldTimeFrom),
},
};
});
}