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,15 +1,15 @@
|
|||
import { BaseController } from "./base-controller";
|
||||
import type { AssignmentDTO } from "@dwengo-1/interfaces/assignment";
|
||||
import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment";
|
||||
import type { SubmissionsResponse } from "./submissions";
|
||||
import type { QuestionsResponse } from "./questions";
|
||||
import type { GroupsResponse } from "./groups";
|
||||
|
||||
export interface AssignmentsResponse {
|
||||
assignments: AssignmentDTO[];
|
||||
assignments: AssignmentDTO[] | string[];
|
||||
}
|
||||
|
||||
export interface AssignmentResponse {
|
||||
assignments: AssignmentDTO;
|
||||
assignment: AssignmentDTO;
|
||||
}
|
||||
|
||||
export class AssignmentController extends BaseController {
|
||||
|
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { QuestionDTO, QuestionId } from "@dwengo-1/interfaces/question";
|
||||
import type { QuestionDTO, QuestionId } from "@dwengo-1/common/interfaces/question";
|
||||
|
||||
export interface QuestionsResponse {
|
||||
questions: QuestionDTO[] | QuestionId[];
|
||||
|
|
|
@ -4,8 +4,8 @@ import type { AssignmentsResponse } from "@/controllers/assignments.ts";
|
|||
import type { GroupsResponse } from "@/controllers/groups.ts";
|
||||
import type { SubmissionsResponse } from "@/controllers/submissions.ts";
|
||||
import type { QuestionsResponse } from "@/controllers/questions.ts";
|
||||
import type { StudentDTO } from "@dwengo-1/interfaces/student";
|
||||
import type { ClassJoinRequestDTO } from "@dwengo-1/interfaces/class-join-request";
|
||||
import type { StudentDTO } from "@dwengo-1/common/interfaces/student";
|
||||
import type { ClassJoinRequestDTO } from "@dwengo-1/common/interfaces/class-join-request";
|
||||
|
||||
export interface StudentsResponse {
|
||||
students: StudentDTO[] | string[];
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
import { BaseController } from "./base-controller";
|
||||
|
||||
export class SubmissionController extends BaseController {
|
||||
constructor(classid: string, assignmentNumber: number, groupNumber: number) {
|
||||
super(`class/${classid}/assignments/${assignmentNumber}/groups/${groupNumber}`);
|
||||
}
|
||||
|
||||
async getAll(full = true) {
|
||||
return this.get<any>(`/`, { full });
|
||||
}
|
||||
|
||||
async getByNumber(submissionNumber: number) {
|
||||
return this.get<any>(`/${submissionNumber}`);
|
||||
}
|
||||
|
||||
async createSubmission(data: any) {
|
||||
return this.post<any>(`/`, data);
|
||||
}
|
||||
|
||||
async deleteSubmission(submissionNumber: number) {
|
||||
return this.delete<any>(`/${submissionNumber}`);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,32 @@
|
|||
import { type SubmissionDTO, SubmissionDTOId } from "@dwengo-1/interfaces/submission";
|
||||
import { BaseController } from "./base-controller";
|
||||
import type { SubmissionDTO, SubmissionDTOId } from "@dwengo-1/common/interfaces/submission";
|
||||
|
||||
export interface SubmissionsResponse {
|
||||
submissions: SubmissionDTO[] | SubmissionDTOId[];
|
||||
}
|
||||
|
||||
export interface SubmissionResponse {
|
||||
submission: SubmissionDTO;
|
||||
};
|
||||
|
||||
export class SubmissionController extends BaseController {
|
||||
constructor(classid: string, assignmentNumber: number, groupNumber: number) {
|
||||
super(`class/${classid}/assignments/${assignmentNumber}/groups/${groupNumber}`);
|
||||
}
|
||||
|
||||
async getAll(full = true) {
|
||||
return this.get<SubmissionsResponse>(`/`, { full });
|
||||
}
|
||||
|
||||
async getByNumber(submissionNumber: number) {
|
||||
return this.get<SubmissionResponse>(`/${submissionNumber}`);
|
||||
}
|
||||
|
||||
async createSubmission(data: any) {
|
||||
return this.post<SubmissionResponse>(`/`, data);
|
||||
}
|
||||
|
||||
async deleteSubmission(submissionNumber: number) {
|
||||
return this.delete<SubmissionResponse>(`/${submissionNumber}`);
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ import { BaseController } from "@/controllers/base-controller.ts";
|
|||
import type { JoinRequestResponse, JoinRequestsResponse, StudentsResponse } from "@/controllers/students.ts";
|
||||
import type { QuestionsResponse } from "@/controllers/questions.ts";
|
||||
import type { ClassesResponse } from "@/controllers/classes.ts";
|
||||
import type { TeacherDTO } from "@dwengo-1/interfaces/teacher";
|
||||
import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher";
|
||||
|
||||
export interface TeachersResponse {
|
||||
teachers: TeacherDTO[] | string[];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { BaseController } from "@/controllers/base-controller.ts";
|
||||
import type { Theme } from "@dwengo-1/interfaces/theme";
|
||||
import type { Theme } from "@dwengo-1/common/interfaces/theme";
|
||||
|
||||
export class ThemeController extends BaseController {
|
||||
constructor() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue