Improved part of the assignments pages
This commit is contained in:
@@ -13,6 +13,7 @@ import {useAssignmentUnarchive} from "@/hooks/useAssignmentUnarchive";
|
|||||||
import {useAssignmentRelease} from "@/hooks/useAssignmentRelease";
|
import {useAssignmentRelease} from "@/hooks/useAssignmentRelease";
|
||||||
import {getUserName} from "@/utils/users";
|
import {getUserName} from "@/utils/users";
|
||||||
import {User} from "@/interfaces/user";
|
import {User} from "@/interfaces/user";
|
||||||
|
import { EntityWithRoles } from "@/interfaces/entity";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
users: User[];
|
users: User[];
|
||||||
@@ -22,6 +23,7 @@ interface Props {
|
|||||||
allowArchive?: boolean;
|
allowArchive?: boolean;
|
||||||
allowUnarchive?: boolean;
|
allowUnarchive?: boolean;
|
||||||
allowExcelDownload?: boolean;
|
allowExcelDownload?: boolean;
|
||||||
|
entityObj?: EntityWithRoles
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function AssignmentCard({
|
export default function AssignmentCard({
|
||||||
@@ -30,6 +32,7 @@ export default function AssignmentCard({
|
|||||||
assigner,
|
assigner,
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
|
entityObj,
|
||||||
assignees,
|
assignees,
|
||||||
results,
|
results,
|
||||||
exams,
|
exams,
|
||||||
@@ -115,6 +118,7 @@ export default function AssignmentCard({
|
|||||||
<span>{moment(endDate).format("DD/MM/YY, HH:mm")}</span>
|
<span>{moment(endDate).format("DD/MM/YY, HH:mm")}</span>
|
||||||
</span>
|
</span>
|
||||||
<span>Assigner: {getUserName(users.find((x) => x.id === assigner))}</span>
|
<span>Assigner: {getUserName(users.find((x) => x.id === assigner))}</span>
|
||||||
|
{entityObj && <span>Entity: {entityObj.label}</span>}
|
||||||
</div>
|
</div>
|
||||||
<div className="-md:mt-2 grid w-full grid-cols-4 place-items-start gap-2">
|
<div className="-md:mt-2 grid w-full grid-cols-4 place-items-start gap-2">
|
||||||
{uniqModules.map(({module}) => (
|
{uniqModules.map(({module}) => (
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import clsx from "clsx";
|
|||||||
import {capitalize, uniqBy} from "lodash";
|
import {capitalize, uniqBy} from "lodash";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import {useRouter} from "next/router";
|
import {useRouter} from "next/router";
|
||||||
import {BsBook, BsChevronLeft, BsClipboard, BsHeadphones, BsMegaphone, BsPen} from "react-icons/bs";
|
import {BsBook, BsBuilding, BsChevronLeft, BsClipboard, BsHeadphones, BsMegaphone, BsPen} from "react-icons/bs";
|
||||||
import {toast} from "react-toastify";
|
import {toast} from "react-toastify";
|
||||||
import {futureAssignmentFilter} from "@/utils/assignments";
|
import {futureAssignmentFilter} from "@/utils/assignments";
|
||||||
import {withIronSessionSsr} from "iron-session/next";
|
import {withIronSessionSsr} from "iron-session/next";
|
||||||
@@ -317,11 +317,18 @@ export default function AssignmentView({user, users, entity, assignment}: Props)
|
|||||||
</Head>
|
</Head>
|
||||||
<Layout user={user}>
|
<Layout user={user}>
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<div className="flex items-center gap-2">
|
<div className="w-full flex items-center justify-between">
|
||||||
<Link href="/assignments" className="text-mti-purple hover:text-mti-purple-dark transition ease-in-out duration-300 text-xl">
|
<div className="flex items-center gap-2">
|
||||||
<BsChevronLeft />
|
<Link href="/assignments" className="text-mti-purple hover:text-mti-purple-dark transition ease-in-out duration-300 text-xl">
|
||||||
</Link>
|
<BsChevronLeft />
|
||||||
<h2 className="font-bold text-2xl">{assignment.name}</h2>
|
</Link>
|
||||||
|
<h2 className="font-bold text-2xl">{assignment.name}</h2>
|
||||||
|
</div>
|
||||||
|
{!!entity && (
|
||||||
|
<span className="flex items-center gap-2">
|
||||||
|
<BsBuilding className="text-xl" /> {entity.label}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Separator />
|
<Separator />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {Assignment} from "@/interfaces/results";
|
|||||||
import {CorporateUser, Group, User} from "@/interfaces/user";
|
import {CorporateUser, Group, User} from "@/interfaces/user";
|
||||||
import {sessionOptions} from "@/lib/session";
|
import {sessionOptions} from "@/lib/session";
|
||||||
import {getUserCompanyName} from "@/resources/user";
|
import {getUserCompanyName} from "@/resources/user";
|
||||||
import {mapBy, redirect, serialize} from "@/utils";
|
import {findBy, mapBy, redirect, serialize} from "@/utils";
|
||||||
import { requestUser } from "@/utils/api";
|
import { requestUser } from "@/utils/api";
|
||||||
import {
|
import {
|
||||||
activeAssignmentFilter,
|
activeAssignmentFilter,
|
||||||
@@ -53,7 +53,7 @@ export const getServerSideProps = withIronSessionSsr(async ({req, res}) => {
|
|||||||
const groups =
|
const groups =
|
||||||
await (checkAccess(user, ["developer", "admin"]) ? getGroups() : getGroupsByEntities(mapBy(allowedEntities, 'id')));
|
await (checkAccess(user, ["developer", "admin"]) ? getGroups() : getGroupsByEntities(mapBy(allowedEntities, 'id')));
|
||||||
|
|
||||||
return {props: serialize({user, users, entities, assignments, groups})};
|
return {props: serialize({user, users, entities: allowedEntities, assignments, groups})};
|
||||||
}, sessionOptions);
|
}, sessionOptions);
|
||||||
|
|
||||||
const SEARCH_FIELDS = [["name"]];
|
const SEARCH_FIELDS = [["name"]];
|
||||||
@@ -131,7 +131,7 @@ export default function AssignmentsPage({assignments, corporateAssignments, enti
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
{activeItems.map((a) => (
|
{activeItems.map((a) => (
|
||||||
<AssignmentCard {...a} users={users} onClick={() => router.push(`/assignments/${a.id}`)} key={a.id} />
|
<AssignmentCard {...a} entityObj={findBy(entities, 'id', a.entity)} users={users} onClick={() => router.push(`/assignments/${a.id}`)} key={a.id} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -153,6 +153,7 @@ export default function AssignmentsPage({assignments, corporateAssignments, enti
|
|||||||
<AssignmentCard
|
<AssignmentCard
|
||||||
{...a}
|
{...a}
|
||||||
users={users}
|
users={users}
|
||||||
|
entityObj={findBy(entities, 'id', a.entity)}
|
||||||
onClick={
|
onClick={
|
||||||
mapBy(entitiesAllowEdit, 'id').includes(a.entity || "")
|
mapBy(entitiesAllowEdit, 'id').includes(a.entity || "")
|
||||||
? () => router.push(`/assignments/creator/${a.id}`)
|
? () => router.push(`/assignments/creator/${a.id}`)
|
||||||
@@ -175,6 +176,7 @@ export default function AssignmentsPage({assignments, corporateAssignments, enti
|
|||||||
<AssignmentCard
|
<AssignmentCard
|
||||||
{...a}
|
{...a}
|
||||||
users={users}
|
users={users}
|
||||||
|
entityObj={findBy(entities, 'id', a.entity)}
|
||||||
onClick={() => router.push(`/assignments/${a.id}`)}
|
onClick={() => router.push(`/assignments/${a.id}`)}
|
||||||
key={a.id}
|
key={a.id}
|
||||||
allowDownload
|
allowDownload
|
||||||
@@ -195,6 +197,7 @@ export default function AssignmentsPage({assignments, corporateAssignments, enti
|
|||||||
<AssignmentCard
|
<AssignmentCard
|
||||||
{...a}
|
{...a}
|
||||||
users={users}
|
users={users}
|
||||||
|
entityObj={findBy(entities, 'id', a.entity)}
|
||||||
onClick={() => router.push(`/assignments/${a.id}`)}
|
onClick={() => router.push(`/assignments/${a.id}`)}
|
||||||
key={a.id}
|
key={a.id}
|
||||||
allowDownload
|
allowDownload
|
||||||
@@ -217,6 +220,7 @@ export default function AssignmentsPage({assignments, corporateAssignments, enti
|
|||||||
users={users}
|
users={users}
|
||||||
onClick={() => router.push(`/assignments/${a.id}`)}
|
onClick={() => router.push(`/assignments/${a.id}`)}
|
||||||
key={a.id}
|
key={a.id}
|
||||||
|
entityObj={findBy(entities, 'id', a.entity)}
|
||||||
allowDownload
|
allowDownload
|
||||||
allowUnarchive
|
allowUnarchive
|
||||||
allowExcelDownload
|
allowExcelDownload
|
||||||
|
|||||||
Reference in New Issue
Block a user