ENCOA-172: Updated it so if an assignment has already been started, they can't start it again
This commit is contained in:
@@ -29,6 +29,7 @@ import {BsArrowRepeat, BsBook, BsClipboard, BsFileEarmarkText, BsHeadphones, BsM
|
||||
import {toast} from "react-toastify";
|
||||
import {activeAssignmentFilter} from "@/utils/assignments";
|
||||
import ModuleBadge from "@/components/ModuleBadge";
|
||||
import useSessions from "@/hooks/useSessions";
|
||||
|
||||
interface Props {
|
||||
user: User;
|
||||
@@ -38,6 +39,7 @@ interface Props {
|
||||
|
||||
export default function StudentDashboard({user, users, linkedCorporate}: Props) {
|
||||
const {gradingSystem} = useGradingSystem();
|
||||
const {sessions} = useSessions(user.id);
|
||||
const {data: stats} = useFilterRecordsByUser<Stat[]>(user.id, !user?.id);
|
||||
const {assignments, isLoading: isAssignmentsLoading, reload: reloadAssignments} = useAssignments({assignees: user?.id});
|
||||
const {invites, isLoading: isInvitesLoading, reload: reloadInvites} = useInvites({to: user.id});
|
||||
@@ -160,12 +162,20 @@ export default function StudentDashboard({user, users, linkedCorporate}: Props)
|
||||
Start
|
||||
</Button>
|
||||
</div>
|
||||
<div
|
||||
data-tip="You have already started this assignment!"
|
||||
className={clsx(
|
||||
"-md:hidden h-full w-full max-w-[50%] cursor-pointer",
|
||||
sessions.filter((x) => x.assignment?.id === assignment.id).length > 0 && "tooltip",
|
||||
)}>
|
||||
<Button
|
||||
className="-md:hidden h-full w-full max-w-[50%] !rounded-xl"
|
||||
className={clsx("w-full h-full !rounded-xl")}
|
||||
onClick={() => startAssignment(assignment)}
|
||||
variant="outline">
|
||||
variant="outline"
|
||||
disabled={sessions.filter((x) => x.assignment?.id === assignment.id).length > 0}>
|
||||
Start
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{assignment.results.map((r) => r.user).includes(user.id) && (
|
||||
|
||||
Reference in New Issue
Block a user