More permissions

This commit is contained in:
Tiago Ribeiro
2024-12-02 17:12:23 +00:00
parent 2e5545f181
commit b6f61c6be1
2 changed files with 5 additions and 2 deletions

View File

@@ -68,7 +68,6 @@ const EXAM_MANAGEMENT: PermissionLayout[] = [
{ label: "Generate Level", key: "generate_level" }, { label: "Generate Level", key: "generate_level" },
{ label: "Delete Level", key: "delete_level" }, { label: "Delete Level", key: "delete_level" },
{ label: "View Statistics", key: "view_statistics" }, { label: "View Statistics", key: "view_statistics" },
{ label: "Download Statistics Report", key: "download_statistics_report" }
] ]
const CLASSROOM_MANAGEMENT: PermissionLayout[] = [ const CLASSROOM_MANAGEMENT: PermissionLayout[] = [
@@ -93,6 +92,7 @@ const ENTITY_MANAGEMENT: PermissionLayout[] = [
{ label: "Edit Role Permissions", key: "edit_role_permissions" }, { label: "Edit Role Permissions", key: "edit_role_permissions" },
{ label: "Assign Role to User", key: "assign_to_role" }, { label: "Assign Role to User", key: "assign_to_role" },
{ label: "Delete Entity Role", key: "delete_entity_role" }, { label: "Delete Entity Role", key: "delete_entity_role" },
{ label: "Download Statistics Report", key: "download_statistics_report" }
] ]
const ASSIGNMENT_MANAGEMENT: PermissionLayout[] = [ const ASSIGNMENT_MANAGEMENT: PermissionLayout[] = [

View File

@@ -3,6 +3,7 @@ import Layout from "@/components/High/Layout";
import Table from "@/components/High/Table"; import Table from "@/components/High/Table";
import Checkbox from "@/components/Low/Checkbox"; import Checkbox from "@/components/Low/Checkbox";
import Separator from "@/components/Low/Separator"; import Separator from "@/components/Low/Separator";
import { useAllowedEntities } from "@/hooks/useEntityPermissions";
import { Session } from "@/hooks/useSessions"; import { Session } from "@/hooks/useSessions";
import { Entity, EntityWithRoles } from "@/interfaces/entity"; import { Entity, EntityWithRoles } from "@/interfaces/entity";
import { Exam } from "@/interfaces/exam"; import { Exam } from "@/interfaces/exam";
@@ -84,6 +85,8 @@ export default function Statistical({ user, students, entities, assignments, ses
const [selectedEntities, setSelectedEntities] = useState<string[]>([]) const [selectedEntities, setSelectedEntities] = useState<string[]>([])
const [isDownloading, setIsDownloading] = useState(false) const [isDownloading, setIsDownloading] = useState(false)
const entitiesAllowDownload = useAllowedEntities(user, entities, 'download_statistics_report')
const resetDateRange = () => { const resetDateRange = () => {
const orderedAssignments = orderBy(assignments, ['startDate'], ['asc']) const orderedAssignments = orderBy(assignments, ['startDate'], ['asc'])
setStartDate(moment(orderedAssignments.shift()?.startDate || "2024-01-01T00:00:01.986Z").toDate()) setStartDate(moment(orderedAssignments.shift()?.startDate || "2024-01-01T00:00:01.986Z").toDate())
@@ -297,7 +300,7 @@ export default function Statistical({ user, students, entities, assignments, ses
data={sortedData} data={sortedData}
searchFields={[["student", "name"], ["student", "email"], ["student", "studentID"], ["exams", "id"], ["assignment", "name"]]} searchFields={[["student", "name"], ["student", "email"], ["student", "studentID"], ["exams", "id"], ["assignment", "name"]]}
searchPlaceholder="Search by student, assignment or exam..." searchPlaceholder="Search by student, assignment or exam..."
onDownload={downloadExcel} onDownload={entitiesAllowDownload.length > 0 ? downloadExcel : undefined}
isDownloadLoading={isDownloading} isDownloadLoading={isDownloading}
/> />
)} )}