Skip to content

Commit

Permalink
chore: did some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tyboro2002 committed Mar 25, 2024
1 parent 147b1a8 commit c7bdde9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions frontend/src/composables/services/assistant.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export function useAssistant() {
getList<Assistant>(endpoint, assistants, Assistant.fromJSON, toast);
}

async function assistantJoinCourse(course_id: string, teacher_id: string) {
async function assistantJoinCourse(course_id: string, assistant_id: string) {
const endpoint = endpoints.assistants.byCourse.replace('{course_id}', course_id);
create<Response>(endpoint, {teacher_id: teacher_id}, response, Response.fromJSON, toast);
create<Response>(endpoint, {assistant_id: assistant_id}, response, Response.fromJSON, toast);
}

async function createAssistant(assistant_data: any) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/composables/services/courses.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export function useCourses() {
create<Course>(endpoint, course_data, course, Course.fromJSON, toast);
}

async function cloneCourse(data: any, course_id: string) {
async function cloneCourse(course_id: string, clone_assistants: boolean) {
const endpoint = endpoints.courses.clone.replace('{course_id}', course_id);
create<Course>(endpoint, data, course, Course.fromJSON, toast);
create<Course>(endpoint, {clone_assistants: clone_assistants.toString() }, course, Course.fromJSON, toast);
}

async function deleteCourse(id: string) {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/composables/services/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export async function delete_id<T>(endpoint: string, ref: Ref<T|null>, fromJson:
});
}


export async function getList<T>(endpoint: string, ref: Ref<T[]|null>, fromJson: (data: any) => T, toast:any): Promise<void> {
await axios.get(endpoint).then(response => {
ref.value = response.data.map((data: T) => fromJson(data));
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/composables/services/students.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export function useStudents() {
create<Response>(endpoint, {student_id: student_id}, response, Response.fromJSON, toast);
}

async function studentLeaveCourse(course_id: string, student_id: string) {
const endpoint = endpoints.students.byCourse.replace('{course_id}', course_id);
delete_id<Response>(endpoint, {student_id: student_id}, response, Response.fromJSON, toast);
}

async function studentJoinGroup(group_id: string, student_id: string) {
const endpoint = endpoints.students.byGroup.replace('{group_id}', group_id);
create<Response>(endpoint, {student_id: student_id}, response, Response.fromJSON, toast);
Expand Down Expand Up @@ -66,6 +71,7 @@ export function useStudents() {
deleteStudent,

studentJoinCourse,
studentLeaveCourse,
studentJoinGroup
};
}

0 comments on commit c7bdde9

Please sign in to comment.