diff --git a/client/src/pages/learningMentor/mentor/MentorOverviewPage.vue b/client/src/pages/learningMentor/mentor/MentorOverviewPage.vue index 88ce3616..7a0a9220 100644 --- a/client/src/pages/learningMentor/mentor/MentorOverviewPage.vue +++ b/client/src/pages/learningMentor/mentor/MentorOverviewPage.vue @@ -1,105 +1,59 @@ diff --git a/client/src/stores/learningMentor/assignmentTodoList.ts b/client/src/stores/learningMentor/assignmentTodoList.ts new file mode 100644 index 00000000..09cef137 --- /dev/null +++ b/client/src/stores/learningMentor/assignmentTodoList.ts @@ -0,0 +1,64 @@ +import { useCurrentCourseSession } from "@/composables"; +import { useLearningMentees } from "@/services/learningMentees"; +import { useTranslation } from "i18next-vue"; +import { defineStore } from "pinia"; +import { computed, ref } from "vue"; + +interface FilterOption { + name: string; + id: string | number; +} + +export const useAssignmentTodoListStore = defineStore("filters", () => { + const { t } = useTranslation(); + const courseSession = useCurrentCourseSession(); + const learningMentees = useLearningMentees(courseSession.value.id); + const summary = computed(() => learningMentees.summary.value); + + const statusOptions = ref([ + { name: t("Alle"), id: "_all" }, + { name: t("a.Zu erledigen"), id: "_todo" }, + ]); + + const selectedStatus = ref(statusOptions.value[1]); + + const allCircles = { name: t("a.AlleCircle"), id: "_all" }; + const circleOptions = computed(() => { + if (!summary.value) return [allCircles]; + return [ + allCircles, + ...summary.value.circles.map((circle) => ({ + name: `Circle: ${circle.title}`, + id: circle.id, + })), + ]; + }); + + const selectedCircle = ref(circleOptions.value[0]); + + const filteredAssignments = computed(() => { + if (!summary.value) return []; + + let filtered = summary.value.assignments; + + if (selectedStatus.value.id !== "_all") { + filtered = filtered.filter((item) => item.pending_evaluations > 0); + } + + if (selectedCircle.value.id !== "_all") { + filtered = filtered.filter( + (item) => item.circle_id === String(selectedCircle.value.id) + ); + } + + return filtered; + }); + + return { + selectedStatus, + statusOptions, + selectedCircle, + circleOptions, + filteredAssignments, + }; +});