diff --git a/frontend/src/composables/services/teachers.service.ts b/frontend/src/composables/services/teachers.service.ts index 1b5d7252..085039bd 100644 --- a/frontend/src/composables/services/teachers.service.ts +++ b/frontend/src/composables/services/teachers.service.ts @@ -1,7 +1,7 @@ import {Teacher} from '@/types/Teacher.ts'; import {ref} from 'vue'; import {endpoints} from '@/config/endpoints.ts'; -import { get, getList } from '@/composables/services/helpers.ts'; +import { get, getList, create, delete_id } from '@/composables/services/helpers.ts'; import { useToast } from 'primevue/usetoast'; export function useTeacher() { @@ -21,10 +21,23 @@ export function useTeacher() { console.log(teachers.value ? teachers.value.map((teacher, index) => `Teacher ${index + 1}: ${JSON.stringify(teacher)}`) : 'Teachers is null'); } + async function createTeacher(teacher_data: any) { + const endpoint = endpoints.teachers.index; + create(endpoint, teacher_data, teacher, Teacher.fromJSON, toast); + } + + async function deleteTeacher(id: string) { + const endpoint = endpoints.students.retrieve.replace('{id}', id.toString()); + delete_id(endpoint, teacher, Teacher.fromJSON, toast); + } + return { teachers, teacher, getTeacherByID, - getTeachers + getTeachers, + + createTeacher, + deleteTeacher }; } \ No newline at end of file