diff --git a/client/src/pages/dashboard/DashboardPersonsPage.vue b/client/src/pages/dashboard/DashboardPersonsPage.vue index f604bf0b..39cf4ad1 100644 --- a/client/src/pages/dashboard/DashboardPersonsPage.vue +++ b/client/src/pages/dashboard/DashboardPersonsPage.vue @@ -7,6 +7,7 @@ import { type DashboardPersonCourseSessionType, exportPersons, } from "@/services/dashboard"; +import { useCourseSessionsStore } from "@/stores/courseSessions"; import { useUserStore } from "@/stores/user"; import type { DashboardPersonsPageMode } from "@/types"; import { openDataAsXls } from "@/utils/export"; @@ -39,6 +40,7 @@ const userStore = useUserStore(); const { loading, dashboardPersons } = useDashboardPersonsDueDates(props.mode); const { CHOSEN_PROFILE_TO_NAME } = useChosenProfileMapping(); +const { allCourseSessionActions } = useCourseSessionsStore(); const courses = computed(() => { return [ @@ -300,6 +302,25 @@ const filtersVisible = computed(() => { ); }); +const canExport = computed(() => { + // If user is only member, he can't export + // member = has is_member property, but not is_expert or is_supervisor + if (!allCourseSessionActions.has("is_member")) { + // is berufsbildner or expert or supervisor + return true; + } + + if ( + allCourseSessionActions.has("is_expert") || + allCourseSessionActions.has("is_supervisor") + ) { + // is member + return true; + } + + return false; +}); + function personRoleDisplayValue(personCourseSession: DashboardPersonCourseSessionType) { if ( [ @@ -317,15 +338,9 @@ function personRoleDisplayValue(personCourseSession: DashboardPersonCourseSessio } async function exportData() { - const requestData = filteredPersons.value.reduce( - (acc, person) => { - acc.courseSessionUserIds.push(person.csu_id); - return acc; - }, - { - courseSessionUserIds: [] as string[], - } - ); + const requestData = { + courseSessionUserIds: filteredPersons.value.map((person) => person.csu_id), + }; const data = await exportPersons(requestData, userStore.language); openDataAsXls(data.encoded_data, data.file_name); } @@ -358,7 +373,12 @@ watch(selectedRegion, () => {