Initial improvements on assets for assignments validation
This commit is contained in:
@@ -1,10 +1,37 @@
|
||||
import moment from "moment";
|
||||
import {Assignment} from "@/interfaces/results";
|
||||
|
||||
export const futureAssignmentFilter = (a: Assignment) => moment(a.startDate).isAfter(moment()) && !a.archived;
|
||||
export const futureAssignmentFilter = (a: Assignment) => {
|
||||
if(a.archived) return false;
|
||||
if(a.start) return false;
|
||||
|
||||
export const pastAssignmentFilter = (a: Assignment) => moment(a.endDate).isBefore(moment()) && !a.archived;
|
||||
const currentDate = moment();
|
||||
|
||||
if(moment(a.startDate).isBefore(currentDate)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export const pastAssignmentFilter = (a: Assignment) => {
|
||||
const currentDate = moment();
|
||||
if(a.archived) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return moment(a.endDate).isBefore(currentDate);
|
||||
}
|
||||
|
||||
export const archivedAssignmentFilter = (a: Assignment) => a.archived;
|
||||
|
||||
export const activeAssignmentFilter = (a: Assignment) => moment(a.endDate).isAfter(moment()) && moment(a.startDate).isBefore(moment());
|
||||
export const activeAssignmentFilter = (a: Assignment) => {
|
||||
const currentDate = moment();
|
||||
if(moment(a.endDate).isBefore(currentDate)) return false;
|
||||
if(a.archived) return false;
|
||||
|
||||
if(a.start) return true;
|
||||
|
||||
if(a.autoStart && a.autoStartDate) {
|
||||
return moment(a.autoStartDate).isBefore(currentDate);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user