Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
render(){
const { onChange, value, disabled, before } = this.props;
// Let's use the static moment reference in the Datetime component
var today = Datetime.moment();
var valid = function (current) {
if (before) {
return current.isBefore(today);
} else {
return current.isAfter(today);
}
};
return (
<div>
<br>
</div>
it('should be false when current is after today and after the ttl', () => {
expect(TimeRangePicker.fromValid(DateTime.moment().add(1, 'day'))).to.equal(false);
});
getStateFromQueryString(props) {
const parsed = queryString.parse(props.location.search);
return {
locale: props.locale,
categories: appConfig.categories.list,
data: [],
loading: true,
error: null,
q: parsed.q,
fromDate: parsed.fromTimestamp ? Datetime.moment(new Date(parseInt(parsed.fromTimestamp, 10) * 1000)) : null,
toDate: parsed.toTimestamp ? Datetime.moment(new Date(parseInt(parsed.toTimestamp, 10) * 1000)) : null,
fromTimestamp: parsed.fromTimestamp && parseInt(parsed.fromTimestamp, 10),
toTimestamp: parsed.toTimestamp && parseInt(parsed.toTimestamp, 10),
pageSize: parseInt(localStorage.getItem(LOCAL_STORAGE_KEY_PLAY_PAGE_SIZE), 10) || 10,
page: parseInt(parsed.page, 10) || 1,
total: 0,
sortField: parsed.sortField || 'bidSum',
sortOrder: parsed.sortOrder || 'desc'
};
}
isValidDate(currentDate) {
return this.props.freeDateInterval || currentDate.isSameOrAfter(Datetime.moment().add(BIDDING_END_MINUTES, 'minute'), 'day');
}
return {
locale: parsed.locale ? parsed.locale: props.locale,
categories: appConfig.categories.list,
languages: appConfig.languages.list,
data: [],
loading: true,
error: null,
q: parsed.q,
category: parsed.category ? parseInt(parsed.category, 10) : null,
fromDate: parsed.fromTimestamp ? Datetime.moment(new Date(parseInt(parsed.fromTimestamp, 10) * 1000)) : null,
toDate: parsed.toTimestamp ? Datetime.moment(new Date(parseInt(parsed.toTimestamp, 10) * 1000)) : null,
fromTimestamp: parsed.fromTimestamp && parseInt(parsed.fromTimestamp, 10),
toTimestamp: parsed.toTimestamp && parseInt(parsed.toTimestamp, 10),
pageSize: parseInt(localStorage.getItem(LOCAL_STORAGE_KEY_PLAY_PAGE_SIZE), 10) || 10,
page: parseInt(parsed.page, 10) || 1,
total: 0,
sortField: parsed.sortField || 'bidSum',
sortOrder: parsed.sortOrder || 'desc'
};
}
parsed[field] = parsed['e_' + field];
}
});
return {
locale: props.locale,
categories: appConfig.categories.list,
data: [],
loading: true,
error: null,
q: parsed.q,
fromDate: parsed.fromTimestamp ? Datetime.moment(new Date(parseInt(parsed.fromTimestamp, 10) * 1000)) : null,
toDate: parsed.toTimestamp ? Datetime.moment(new Date(parseInt(parsed.toTimestamp, 10) * 1000)) : null,
fromTimestamp: parsed.fromTimestamp && parseInt(parsed.fromTimestamp, 10),
toTimestamp: parsed.toTimestamp && parseInt(parsed.toTimestamp, 10),
pageSize: parseInt(localStorage.getItem(LOCAL_STORAGE_KEY_PLAY_PAGE_SIZE), 10) || 10,
page: parseInt(parsed.page, 10) || 1,
total: 0,
sortField: parsed.sortField || 'bidSum',
sortOrder: parsed.sortOrder || 'desc'
};
}
isDateSelectable = current =>
current.isAfter(Datetime.moment().subtract(1, "day"));
const parsed = props.location && props.location.search ? queryString.parse(props.location.search) : {};
return {
locale: parsed.locale ? parsed.locale: props.locale,
categories: appConfig.categories.list,
languages: appConfig.languages.list,
data: [],
loading: true,
error: null,
q: parsed.q,
category: parsed.category ? parseInt(parsed.category, 10) : null,
fromDate: parsed.fromTimestamp ? Datetime.moment(new Date(parseInt(parsed.fromTimestamp, 10) * 1000)) : null,
toDate: parsed.toTimestamp ? Datetime.moment(new Date(parseInt(parsed.toTimestamp, 10) * 1000)) : null,
fromTimestamp: parsed.fromTimestamp && parseInt(parsed.fromTimestamp, 10),
toTimestamp: parsed.toTimestamp && parseInt(parsed.toTimestamp, 10),
pageSize: parseInt(localStorage.getItem(LOCAL_STORAGE_KEY_PLAY_PAGE_SIZE), 10) || 10,
page: parseInt(parsed.page, 10) || 1,
total: 0,
sortField: parsed.sortField || 'bidSum',
sortOrder: parsed.sortOrder || 'desc'
};
}
async update() {
const conditions = [];
const shouldConditions = [];
conditions.push({
term: {
locale: this.state.locale
}
});
if(this.props.routeName !== 'admin/event_results') {
conditions.push({
range: {
startDate: {
gte: parseInt(Datetime.moment().add(BIDDING_END_MINUTES, 'minute').unix(), 10),
}
}
});
}
if (this.state.q) {
shouldConditions.push({
query_string: {
analyzer: getLanguageAnalyzerByCode(this.props.locale),
fields: ['name', 'description'],
query: this.state.q
}
});
shouldConditions.push({
"nested": {