Skip to content

Commit

Permalink
chore: teachers create and delete services added
Browse files Browse the repository at this point in the history
  • Loading branch information
tyboro2002 committed Mar 25, 2024
1 parent da63342 commit aced180
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions frontend/src/composables/services/teachers.service.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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<Teacher>(endpoint, teacher_data, teacher, Teacher.fromJSON, toast);
}

async function deleteTeacher(id: string) {
const endpoint = endpoints.students.retrieve.replace('{id}', id.toString());
delete_id<Teacher>(endpoint, teacher, Teacher.fromJSON, toast);
}

return {
teachers,
teacher,
getTeacherByID,
getTeachers
getTeachers,

createTeacher,
deleteTeacher
};
}

0 comments on commit aced180

Please sign in to comment.