Allowed assigners to release and start the assignment
This commit is contained in:
@@ -44,6 +44,20 @@ export default function AssignmentView({isOpen, assignment, onClose}: Props) {
|
|||||||
.finally(onClose);
|
.finally(onClose);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const startAssignment = () => {
|
||||||
|
if (assignment) {
|
||||||
|
axios
|
||||||
|
.post(`/api/assignments/${assignment.id}/start`)
|
||||||
|
.then(() => {
|
||||||
|
toast.success(`The assignment "${assignment.name}" has been started successfully!`);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.log(e);
|
||||||
|
toast.error("Something went wrong, please try again later!");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const formatTimestamp = (timestamp: string) => {
|
const formatTimestamp = (timestamp: string) => {
|
||||||
const date = moment(parseInt(timestamp));
|
const date = moment(parseInt(timestamp));
|
||||||
const formatter = "YYYY/MM/DD - HH:mm";
|
const formatter = "YYYY/MM/DD - HH:mm";
|
||||||
@@ -301,6 +315,11 @@ export default function AssignmentView({isOpen, assignment, onClose}: Props) {
|
|||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{assignment && (assignment.results.length === 0 || moment().isAfter(moment(assignment.startDate))) && (
|
||||||
|
<Button variant="outline" color="green" className="w-full max-w-[200px]" onClick={startAssignment}>
|
||||||
|
Start
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button onClick={onClose} className="w-full max-w-[200px]">
|
<Button onClick={onClose} className="w-full max-w-[200px]">
|
||||||
Close
|
Close
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,18 +1,10 @@
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { Assignment } from "@/interfaces/results";
|
import {Assignment} from "@/interfaces/results";
|
||||||
|
|
||||||
export const futureAssignmentFilter = (a: Assignment) =>
|
export const futureAssignmentFilter = (a: Assignment) => moment(a.startDate).isAfter(moment()) && !a.archived;
|
||||||
moment(a.startDate).isAfter(moment()) && !a.archived && !a.start;
|
|
||||||
|
export const pastAssignmentFilter = (a: Assignment) => moment(a.endDate).isBefore(moment()) && !a.archived;
|
||||||
|
|
||||||
export const pastAssignmentFilter = (a: Assignment) =>
|
|
||||||
(moment(a.endDate).isBefore(moment()) ||
|
|
||||||
a.assignees.length === a.results.length ||
|
|
||||||
(moment(a.startDate).isBefore(moment()) && !a.start)) &&
|
|
||||||
!a.archived;
|
|
||||||
export const archivedAssignmentFilter = (a: Assignment) => a.archived;
|
export const archivedAssignmentFilter = (a: Assignment) => a.archived;
|
||||||
|
|
||||||
export const activeAssignmentFilter = (a: Assignment) =>
|
export const activeAssignmentFilter = (a: Assignment) => moment(a.endDate).isAfter(moment()) && moment(a.startDate).isBefore(moment());
|
||||||
moment(a.endDate).isAfter(moment()) &&
|
|
||||||
// && moment(a.startDate).isBefore(moment())
|
|
||||||
a.start &&
|
|
||||||
a.assignees.length > a.results.length;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user