diff --git a/frontend/src/components/GroupSelector.vue b/frontend/src/components/GroupSelector.vue index 487e4c2a..b0a96e32 100644 --- a/frontend/src/components/GroupSelector.vue +++ b/frontend/src/components/GroupSelector.vue @@ -4,37 +4,30 @@ import { useI18n } from 'vue-i18n'; const props = defineProps({ students: Array, // All students - availableClasses: Array, // Selected classes + availableClass: Object, // Selected class groups: Array, // All groups }); const emit = defineEmits(['groupCreated']); const { t } = useI18n(); -const selectedClass = ref(null); const selectedStudents = ref([]); // Filter students based on the selected class and exclude students already in a group const filteredStudents = computed(() => { - if (selectedClass.value) { - // Find the class based on selectedClass id - const selected = props.availableClasses.find(cl => cl.id === selectedClass.value.id); - if (selected) { - // Get all students from the selected class - const studentsInClass = selected.students.map(st => ({ - title: `${st.firstName} ${st.lastName}`, - value: st.username, - })); + if (props.availableClass) { + const studentsInClass = props.availableClass.students.map(st => ({ + title: `${st.firstName} ${st.lastName}`, + value: st.username, + })); - // Get the list of students already in any group - const studentsInGroups = props.groups.flat(); + const studentsInGroups = props.groups.flat(); - // Filter out students that are already in a group - return studentsInClass.filter(student => !studentsInGroups.includes(student.value)); - } + return studentsInClass.filter(student => !studentsInGroups.includes(student.value)); } return []; }); + const createGroup = () => { if (selectedStudents.value.length) { // Extract only usernames (student.value) @@ -48,19 +41,6 @@ const createGroup = () => {