fix: response types en import errors gefixt
This commit is contained in:
parent
7f7df53d79
commit
beb3bacfa7
9 changed files with 66 additions and 49 deletions
|
@ -1,40 +1,47 @@
|
|||
import { BaseController } from "./base-controller";
|
||||
import type { ClassDTO } from "@dwengo-1/interfaces/class";
|
||||
import type { ClassDTO } from "@dwengo-1/common/interfaces/class";
|
||||
import type { StudentsResponse } from "./students";
|
||||
import type { AssignmentsResponse } from "./assignments";
|
||||
|
||||
export interface ClassesResponse {
|
||||
classes: ClassDTO[] | string[];
|
||||
}
|
||||
|
||||
export interface ClassResponse {
|
||||
class: ClassDTO;
|
||||
}
|
||||
|
||||
export class ClassController extends BaseController {
|
||||
constructor() {
|
||||
super("class");
|
||||
}
|
||||
|
||||
async getAll(full = true) {
|
||||
return this.get<{ classes: any[] }>(`/`, { full });
|
||||
return this.get<ClassesResponse>(`/`, { full });
|
||||
}
|
||||
|
||||
async getById(id: string) {
|
||||
return this.get<{ class: any }>(`/${id}`);
|
||||
return this.get<ClassResponse>(`/${id}`);
|
||||
}
|
||||
|
||||
async createClass(data: any) {
|
||||
return this.post<{ class: any }>(`/`, data);
|
||||
return this.post<ClassResponse>(`/`, data);
|
||||
}
|
||||
|
||||
async deleteClass(id: string) {
|
||||
return this.delete<{ class: any }>(`/${id}`);
|
||||
return this.delete<ClassResponse>(`/${id}`);
|
||||
}
|
||||
|
||||
async getStudents(id: string, full = true) {
|
||||
return this.get<{ students: any[] }>(`/${id}/students`, { full });
|
||||
return this.get<StudentsResponse>(`/${id}/students`, { full });
|
||||
}
|
||||
|
||||
// TODO
|
||||
async getTeacherInvitations(id: string, full = true) {
|
||||
return this.get<{ invitations: any[] }>(`/${id}/teacher-invitations`, { full });
|
||||
return this.get<any>(`/${id}/teacher-invitations`, { full });
|
||||
}
|
||||
|
||||
async getAssignments(id: string, full = true) {
|
||||
return this.get<{ assignments: any[] }>(`/${id}/assignments`, { full });
|
||||
return this.get<AssignmentsResponse>(`/${id}/assignments`, { full });
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue