Updated the assignments active filter to work with the startDate
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import moment from "moment";
|
||||
import {Assignment} from "@/interfaces/results";
|
||||
import { Assignment } from "@/interfaces/results";
|
||||
|
||||
// export const futureAssignmentFilter = (a: Assignment) => {
|
||||
// if(a.archived) return false;
|
||||
@@ -15,43 +15,38 @@ import {Assignment} from "@/interfaces/results";
|
||||
// }
|
||||
|
||||
export const futureAssignmentFilter = (a: Assignment) => {
|
||||
const currentDate = moment();
|
||||
if(moment(a.endDate).isBefore(currentDate)) return false;
|
||||
if(a.archived) return false;
|
||||
const currentDate = moment();
|
||||
if (moment(a.endDate).isBefore(currentDate)) return false;
|
||||
if (a.archived) return false;
|
||||
|
||||
if(a.autoStart && a.autoStartDate && moment(a.autoStartDate).isBefore(currentDate)) return false;
|
||||
if (a.autoStart && a.autoStartDate && moment(a.autoStartDate).isBefore(currentDate)) return false;
|
||||
|
||||
if(!a.start) {
|
||||
if(moment(a.startDate).isBefore(currentDate)) return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (!a.start) {
|
||||
if (moment(a.startDate).isBefore(currentDate)) return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export const pastAssignmentFilter = (a: Assignment) => {
|
||||
const currentDate = moment();
|
||||
if(a.archived) {
|
||||
return false;
|
||||
}
|
||||
const currentDate = moment();
|
||||
if (a.archived) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return moment(a.endDate).isBefore(currentDate);
|
||||
return moment(a.endDate).isBefore(currentDate);
|
||||
}
|
||||
|
||||
export const archivedAssignmentFilter = (a: Assignment) => a.archived;
|
||||
|
||||
export const activeAssignmentFilter = (a: Assignment) => {
|
||||
const currentDate = moment();
|
||||
if(moment(a.endDate).isBefore(currentDate)) return false;
|
||||
if(a.archived) return false;
|
||||
const currentDate = moment();
|
||||
if (moment(a.endDate).isBefore(currentDate) || a.archived) return false;
|
||||
|
||||
if(a.start) return true;
|
||||
if (a.start) return true;
|
||||
if (a.autoStart && a.autoStartDate) return moment(a.autoStartDate).isBefore(currentDate);
|
||||
|
||||
if(a.autoStart && a.autoStartDate) {
|
||||
return moment(a.autoStartDate).isBefore(currentDate);
|
||||
}
|
||||
|
||||
// if(currentDate.isAfter(moment(a.startDate))) return true;
|
||||
return false;
|
||||
return currentDate.isAfter(moment(a.startDate));
|
||||
};
|
||||
|
||||
// export const unstartedAssignmentFilter = (a: Assignment) => {
|
||||
@@ -69,9 +64,9 @@ export const activeAssignmentFilter = (a: Assignment) => {
|
||||
// }
|
||||
|
||||
export const startHasExpiredAssignmentFilter = (a: Assignment) => {
|
||||
const currentDate = moment();
|
||||
if(a.archived) return false;
|
||||
if(a.start) return false;
|
||||
if(currentDate.isAfter(moment(a.startDate)) && currentDate.isBefore(moment(a.endDate))) return true;
|
||||
return false;
|
||||
}
|
||||
const currentDate = moment();
|
||||
if (a.archived) return false;
|
||||
if (a.start) return false;
|
||||
if (currentDate.isAfter(moment(a.startDate)) && currentDate.isBefore(moment(a.endDate))) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user