forked from DebaucheryLibrarian/traxxx
				
			
		
			
				
	
	
		
			48 lines
		
	
	
		
			833 B
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			833 B
		
	
	
	
		
			JavaScript
		
	
	
	
| import dayjs from 'dayjs';
 | |
| 
 | |
| const dateRanges = {
 | |
| 	latest: () => ({
 | |
| 		after: '1900-01-01',
 | |
| 		before: dayjs(new Date()).add(1, 'day').format('YYYY-MM-DD'),
 | |
| 		orderBy: 'DATE_DESC',
 | |
| 	}),
 | |
| 	upcoming: () => ({
 | |
| 		after: dayjs(new Date()).format('YYYY-MM-DD'),
 | |
| 		before: '2100-01-01',
 | |
| 		orderBy: 'DATE_ASC',
 | |
| 	}),
 | |
| 	new: () => ({
 | |
| 		after: '1900-01-01',
 | |
| 		before: '2100-01-01',
 | |
| 		orderBy: 'CREATED_AT_DESC',
 | |
| 	}),
 | |
| 	all: () => ({
 | |
| 		after: '1900-01-01',
 | |
| 		before: '2100-01-01',
 | |
| 		orderBy: 'DATE_DESC',
 | |
| 	}),
 | |
| };
 | |
| 
 | |
| function rangeDates(state) {
 | |
| 	return dateRanges[state.range]();
 | |
| }
 | |
| 
 | |
| function before(state) {
 | |
| 	return dateRanges[state.range]().before;
 | |
| }
 | |
| 
 | |
| function after(state) {
 | |
| 	return dateRanges[state.range]().after;
 | |
| }
 | |
| 
 | |
| function orderBy(state) {
 | |
| 	return dateRanges[state.range]().orderBy;
 | |
| }
 | |
| 
 | |
| export default {
 | |
| 	rangeDates,
 | |
| 	before,
 | |
| 	after,
 | |
| 	orderBy,
 | |
| };
 |