Stuff with the new corporate
This commit is contained in:
@@ -33,6 +33,7 @@ import {
|
||||
} from "react-icons/bs";
|
||||
import { ToastContainer } from "react-toastify";
|
||||
import { useAllowedEntities } from "@/hooks/useEntityPermissions";
|
||||
import { isAdmin } from "@/utils/users";
|
||||
|
||||
interface Props {
|
||||
user: User;
|
||||
@@ -51,12 +52,12 @@ export const getServerSideProps = withIronSessionSsr(async ({ req, res }) => {
|
||||
if (!checkAccess(user, ["admin", "developer", "corporate"])) return redirect("/")
|
||||
|
||||
const entityIDS = mapBy(user.entities, "id") || [];
|
||||
const entities = await getEntitiesWithRoles(entityIDS);
|
||||
const entities = await getEntitiesWithRoles(isAdmin(user) ? undefined : entityIDS);
|
||||
const users = await filterAllowedUsers(user, entities)
|
||||
|
||||
const userCounts = await countAllowedUsers(user, entities)
|
||||
const assignmentsCount = await countEntitiesAssignments(entityIDS, { archived: { $ne: true } });
|
||||
const groupsCount = await countGroupsByEntities(entityIDS);
|
||||
const assignmentsCount = await countEntitiesAssignments(mapBy(entities, "id"), { archived: { $ne: true } });
|
||||
const groupsCount = await countGroupsByEntities(mapBy(entities, "id"));
|
||||
|
||||
const stats = await getStatsByUsers(users.map((u) => u.id));
|
||||
|
||||
@@ -132,7 +133,7 @@ export default function Dashboard({ user, users, userCounts, entities, assignmen
|
||||
<IconCard Icon={BsPersonFillGear}
|
||||
onClick={() => router.push("/users/performance")}
|
||||
label="Student Performance"
|
||||
value={students.length}
|
||||
value={userCounts.student}
|
||||
color="purple"
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user