traxxx/assets/js/get-date-range.js

34 lines
684 B
JavaScript
Executable File

import utc from 'dayjs/plugin/utc';
import dayjs from 'dayjs';
dayjs.extend(utc);
const dateRanges = {
latest: () => ({
after: '1900-01-01',
before: dayjs.utc().toDate(),
orderBy: ['EFFECTIVE_DATE_DESC'],
}),
upcoming: () => ({
after: dayjs.utc().toDate(),
before: '2100-01-01',
orderBy: ['EFFECTIVE_DATE_DESC'],
}),
new: () => ({
after: '1900-01-01 00:00:00',
before: '2100-01-01',
orderBy: ['CREATED_AT_DESC', 'EFFECTIVE_DATE_ASC'],
}),
all: () => ({
after: '1900-01-01',
before: '2100-01-01',
orderBy: ['EFFECTIVE_DATE_DESC'],
}),
};
function getDateRange(range) {
return (dateRanges[range] || dateRanges.all)();
}
export default getDateRange;