fix: response types en import errors gefixt

This commit is contained in:
Adriaan Jacquet 2025-04-03 12:40:32 +02:00
parent 7f7df53d79
commit beb3bacfa7
9 changed files with 66 additions and 49 deletions

View file

@ -1,9 +1,15 @@
import { BaseController } from "./base-controller";
import type { GroupDTO } from "@dwengo-1/interfaces/group";
import type { GroupDTO } from "@dwengo-1/common/interfaces/group";
import type { SubmissionsResponse } from "./submissions";
import type { QuestionsResponse } from "./questions";
export interface GroupsResponse {
groups: GroupDTO[];
} // | TODO id
}
export interface GroupResponse {
group: GroupDTO;
}
export class GroupController extends BaseController {
constructor(classid: string, assignmentNumber: number) {
@ -11,26 +17,26 @@ export class GroupController extends BaseController {
}
async getAll(full = true) {
return this.get<{ groups: any[] }>(`/`, { full });
return this.get<GroupsResponse>(`/`, { full });
}
async getByNumber(num: number) {
return this.get<{ group: any }>(`/${num}`);
return this.get<GroupResponse>(`/${num}`);
}
async createGroup(data: any) {
return this.post<{ group: any }>(`/`, data);
return this.post<GroupResponse>(`/`, data);
}
async deleteClass(num: number) {
return this.delete<{ group: any }>(`/${num}`);
async deleteGroup(num: number) {
return this.delete<GroupResponse>(`/${num}`);
}
async getSubmissions(groupNumber: number, full = true) {
return this.get<{ groups: any[] }>(`/${groupNumber}/submissions`, { full });
return this.get<SubmissionsResponse>(`/${groupNumber}/submissions`, { full });
}
async getQuestions(groupNumber: number, full = true) {
return this.get<{ questions: any[] }>(`/${groupNumber}/questions`, { full });
return this.get<QuestionsResponse>(`/${groupNumber}/questions`, { full });
}
}