40 lines
752 B
JavaScript
40 lines
752 B
JavaScript
import dayjs from 'dayjs';
|
|
|
|
const dateRanges = {
|
|
latest: () => ({
|
|
after: '1900-01-01',
|
|
before: dayjs(new Date()).add(1, 'day').format('YYYY-MM-DD'),
|
|
}),
|
|
upcoming: () => ({
|
|
after: dayjs(new Date()).format('YYYY-MM-DD'),
|
|
before: '2100-01-01',
|
|
}),
|
|
all: () => ({
|
|
after: '1900-01-01',
|
|
before: '2100-01-01',
|
|
}),
|
|
};
|
|
|
|
function rangeDates(state) {
|
|
return dateRanges[state.range]();
|
|
}
|
|
|
|
function before(state) {
|
|
return dateRanges[state.range]().before;
|
|
}
|
|
|
|
function after(state) {
|
|
return dateRanges[state.range]().after;
|
|
}
|
|
|
|
function isNew(state) {
|
|
return state.batch === 'new' ? [true] : [true, false];
|
|
}
|
|
|
|
export default {
|
|
rangeDates,
|
|
before,
|
|
after,
|
|
isNew,
|
|
};
|