style: fix linting issues met Prettier
This commit is contained in:
parent
87366b2821
commit
899af4dec5
20 changed files with 117 additions and 118 deletions
|
@ -11,10 +11,10 @@ import {
|
||||||
updateClassJoinRequestStatus,
|
updateClassJoinRequestStatus,
|
||||||
} from '../services/teachers.js';
|
} from '../services/teachers.js';
|
||||||
import { requireFields } from './error-helper.js';
|
import { requireFields } from './error-helper.js';
|
||||||
import {TeacherDTO} from "dwengo-1-common/src/interfaces/teacher";
|
import { TeacherDTO } from 'dwengo-1-common/src/interfaces/teacher';
|
||||||
import {ClassDTO} from "dwengo-1-common/src/interfaces/class";
|
import { ClassDTO } from 'dwengo-1-common/src/interfaces/class';
|
||||||
import {StudentDTO} from "dwengo-1-common/src/interfaces/student";
|
import { StudentDTO } from 'dwengo-1-common/src/interfaces/student';
|
||||||
import {QuestionDTO, QuestionId} from "dwengo-1-common/src/interfaces/question";
|
import { QuestionDTO, QuestionId } from 'dwengo-1-common/src/interfaces/question';
|
||||||
|
|
||||||
export async function getAllTeachersHandler(req: Request, res: Response): Promise<void> {
|
export async function getAllTeachersHandler(req: Request, res: Response): Promise<void> {
|
||||||
const full = req.query.full === 'true';
|
const full = req.query.full === 'true';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {Theme} from "dwengo-1-common/src/interfaces/theme";
|
import { Theme } from 'dwengo-1-common/src/interfaces/theme';
|
||||||
|
|
||||||
export const themes: Theme[] = [
|
export const themes: Theme[] = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Question } from '../entities/questions/question.entity.js';
|
import { Question } from '../entities/questions/question.entity.js';
|
||||||
import { mapToStudentDTO } from './student.js';
|
import { mapToStudentDTO } from './student.js';
|
||||||
import { QuestionDTO, QuestionId } from 'dwengo-1-common/src/interfaces/question';
|
import { QuestionDTO, QuestionId } from 'dwengo-1-common/src/interfaces/question';
|
||||||
import {LearningObjectIdentifier} from "../entities/content/learning-object-identifier";
|
import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier';
|
||||||
|
|
||||||
function getLearningObjectIdentifier(question: Question): LearningObjectIdentifier {
|
function getLearningObjectIdentifier(question: Question): LearningObjectIdentifier {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -3,8 +3,7 @@ import { ClassJoinRequest, ClassJoinRequestStatus } from '../entities/classes/cl
|
||||||
import { getClassJoinRequestRepository } from '../data/repositories.js';
|
import { getClassJoinRequestRepository } from '../data/repositories.js';
|
||||||
import { Student } from '../entities/users/student.entity.js';
|
import { Student } from '../entities/users/student.entity.js';
|
||||||
import { Class } from '../entities/classes/class.entity.js';
|
import { Class } from '../entities/classes/class.entity.js';
|
||||||
import {ClassJoinRequestDTO} from "dwengo-1-common/src/interfaces/class-join-request";
|
import { ClassJoinRequestDTO } from 'dwengo-1-common/src/interfaces/class-join-request';
|
||||||
|
|
||||||
|
|
||||||
export function mapToStudentRequestDTO(request: ClassJoinRequest): ClassJoinRequestDTO {
|
export function mapToStudentRequestDTO(request: ClassJoinRequest): ClassJoinRequestDTO {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { getAnswerRepository, getQuestionRepository } from '../data/repositories.js';
|
import { getAnswerRepository, getQuestionRepository } from '../data/repositories.js';
|
||||||
import {mapToQuestionDTO, mapToQuestionDTOId } from '../interfaces/question.js';
|
import { mapToQuestionDTO, mapToQuestionDTOId } from '../interfaces/question.js';
|
||||||
import { Question } from '../entities/questions/question.entity.js';
|
import { Question } from '../entities/questions/question.entity.js';
|
||||||
import { Answer } from '../entities/questions/answer.entity.js';
|
import { Answer } from '../entities/questions/answer.entity.js';
|
||||||
import {mapToAnswerDTO, mapToAnswerDTOId} from '../interfaces/answer.js';
|
import { mapToAnswerDTO, mapToAnswerDTOId } from '../interfaces/answer.js';
|
||||||
import { QuestionRepository } from '../data/questions/question-repository.js';
|
import { QuestionRepository } from '../data/questions/question-repository.js';
|
||||||
import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js';
|
import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js';
|
||||||
import { mapToStudent } from '../interfaces/student.js';
|
import { mapToStudent } from '../interfaces/student.js';
|
||||||
import {QuestionDTO, QuestionId} from "dwengo-1-common/src/interfaces/question";
|
import { QuestionDTO, QuestionId } from 'dwengo-1-common/src/interfaces/question';
|
||||||
import {AnswerDTO, AnswerId} from "dwengo-1-common/src/interfaces/answer";
|
import { AnswerDTO, AnswerId } from 'dwengo-1-common/src/interfaces/answer';
|
||||||
|
|
||||||
export async function getAllQuestions(id: LearningObjectIdentifier, full: boolean): Promise<QuestionDTO[] | QuestionId[]> {
|
export async function getAllQuestions(id: LearningObjectIdentifier, full: boolean): Promise<QuestionDTO[] | QuestionId[]> {
|
||||||
const questionRepository: QuestionRepository = getQuestionRepository();
|
const questionRepository: QuestionRepository = getQuestionRepository();
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { NotFoundException } from '../../src/exceptions/not-found-exception.js';
|
||||||
import { BadRequestException } from '../../src/exceptions/bad-request-exception.js';
|
import { BadRequestException } from '../../src/exceptions/bad-request-exception.js';
|
||||||
import { ConflictException } from '../../src/exceptions/conflict-exception.js';
|
import { ConflictException } from '../../src/exceptions/conflict-exception.js';
|
||||||
import { EntityAlreadyExistsException } from '../../src/exceptions/entity-already-exists-exception.js';
|
import { EntityAlreadyExistsException } from '../../src/exceptions/entity-already-exists-exception.js';
|
||||||
import {StudentDTO} from "dwengo-1-common/src/interfaces/student";
|
import { StudentDTO } from 'dwengo-1-common/src/interfaces/student';
|
||||||
|
|
||||||
describe('Student controllers', () => {
|
describe('Student controllers', () => {
|
||||||
let req: Partial<Request>;
|
let req: Partial<Request>;
|
||||||
|
|
|
@ -15,8 +15,7 @@ import {
|
||||||
import { BadRequestException } from '../../src/exceptions/bad-request-exception.js';
|
import { BadRequestException } from '../../src/exceptions/bad-request-exception.js';
|
||||||
import { EntityAlreadyExistsException } from '../../src/exceptions/entity-already-exists-exception.js';
|
import { EntityAlreadyExistsException } from '../../src/exceptions/entity-already-exists-exception.js';
|
||||||
import { getStudentRequestsHandler } from '../../src/controllers/students.js';
|
import { getStudentRequestsHandler } from '../../src/controllers/students.js';
|
||||||
import {TeacherDTO} from "dwengo-1-common/src/interfaces/teacher";
|
import { TeacherDTO } from 'dwengo-1-common/src/interfaces/teacher';
|
||||||
|
|
||||||
|
|
||||||
describe('Teacher controllers', () => {
|
describe('Teacher controllers', () => {
|
||||||
let req: Partial<Request>;
|
let req: Partial<Request>;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {StudentDTO} from "./student";
|
import { StudentDTO } from './student';
|
||||||
|
|
||||||
export interface ClassJoinRequestDTO {
|
export interface ClassJoinRequestDTO {
|
||||||
requester: StudentDTO;
|
requester: StudentDTO;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
import type {AssignmentDTO} from "dwengo-1-common/src/interfaces/assignment";
|
import type { AssignmentDTO } from "dwengo-1-common/src/interfaces/assignment";
|
||||||
|
|
||||||
export interface AssignmentsResponse { assignments: AssignmentDTO[] } // TODO ID
|
export interface AssignmentsResponse {
|
||||||
|
assignments: AssignmentDTO[];
|
||||||
|
} // TODO ID
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
import type {ClassDTO} from "dwengo-1-common/src/interfaces/class";
|
import type { ClassDTO } from "dwengo-1-common/src/interfaces/class";
|
||||||
|
|
||||||
export interface ClassesResponse { classes: ClassDTO[] | string[] }
|
export interface ClassesResponse {
|
||||||
|
classes: ClassDTO[] | string[];
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
import type {GroupDTO} from "dwengo-1-common/src/interfaces/group";
|
import type { GroupDTO } from "dwengo-1-common/src/interfaces/group";
|
||||||
|
|
||||||
export interface GroupsResponse { groups: GroupDTO[] } // | TODO id
|
export interface GroupsResponse {
|
||||||
|
groups: GroupDTO[];
|
||||||
|
} // | TODO id
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
import type {QuestionDTO, QuestionId} from "dwengo-1-common/src/interfaces/question";
|
import type { QuestionDTO, QuestionId } from "dwengo-1-common/src/interfaces/question";
|
||||||
|
|
||||||
export interface QuestionsResponse { questions: QuestionDTO[] | QuestionId[] }
|
export interface QuestionsResponse {
|
||||||
|
questions: QuestionDTO[] | QuestionId[];
|
||||||
|
}
|
||||||
|
|
|
@ -1,17 +1,24 @@
|
||||||
import { BaseController } from "@/controllers/base-controller.ts";
|
import { BaseController } from "@/controllers/base-controller.ts";
|
||||||
import type {StudentDTO} from "dwengo-1-common/src/interfaces/student";
|
import type { StudentDTO } from "dwengo-1-common/src/interfaces/student";
|
||||||
import type {ClassesResponse} from "@/controllers/classes.ts";
|
import type { ClassesResponse } from "@/controllers/classes.ts";
|
||||||
import type {AssignmentsResponse} from "@/controllers/assignments.ts";
|
import type { AssignmentsResponse } from "@/controllers/assignments.ts";
|
||||||
import type {GroupsResponse} from "@/controllers/groups.ts";
|
import type { GroupsResponse } from "@/controllers/groups.ts";
|
||||||
import type {SubmissionsResponse} from "@/controllers/submissions.ts";
|
import type { SubmissionsResponse } from "@/controllers/submissions.ts";
|
||||||
import type {QuestionsResponse} from "@/controllers/questions.ts";
|
import type { QuestionsResponse } from "@/controllers/questions.ts";
|
||||||
import type {ClassJoinRequestDTO} from "dwengo-1-common/src/interfaces/class-join-request";
|
import type { ClassJoinRequestDTO } from "dwengo-1-common/src/interfaces/class-join-request";
|
||||||
|
|
||||||
export interface StudentsResponse { students: StudentDTO[] | string[] }
|
|
||||||
export interface StudentResponse { student: StudentDTO }
|
|
||||||
export interface JoinRequestsResponse { requests: ClassJoinRequestDTO[] }
|
|
||||||
export interface JoinRequestResponse { request: ClassJoinRequestDTO }
|
|
||||||
|
|
||||||
|
export interface StudentsResponse {
|
||||||
|
students: StudentDTO[] | string[];
|
||||||
|
}
|
||||||
|
export interface StudentResponse {
|
||||||
|
student: StudentDTO;
|
||||||
|
}
|
||||||
|
export interface JoinRequestsResponse {
|
||||||
|
requests: ClassJoinRequestDTO[];
|
||||||
|
}
|
||||||
|
export interface JoinRequestResponse {
|
||||||
|
request: ClassJoinRequestDTO;
|
||||||
|
}
|
||||||
|
|
||||||
export class StudentController extends BaseController {
|
export class StudentController extends BaseController {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
import {type SubmissionDTO, SubmissionDTOId} from "dwengo-1-common/src/interfaces/submission";
|
import { type SubmissionDTO, SubmissionDTOId } from "dwengo-1-common/src/interfaces/submission";
|
||||||
|
|
||||||
export interface SubmissionsResponse { submissions: SubmissionDTO[] | SubmissionDTOId[] }
|
export interface SubmissionsResponse {
|
||||||
|
submissions: SubmissionDTO[] | SubmissionDTOId[];
|
||||||
|
}
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
import { BaseController } from "@/controllers/base-controller.ts";
|
import { BaseController } from "@/controllers/base-controller.ts";
|
||||||
import type {JoinRequestResponse, JoinRequestsResponse, StudentsResponse} from "@/controllers/students.ts";
|
import type { JoinRequestResponse, JoinRequestsResponse, StudentsResponse } from "@/controllers/students.ts";
|
||||||
import type {QuestionsResponse} from "@/controllers/questions.ts";
|
import type { QuestionsResponse } from "@/controllers/questions.ts";
|
||||||
import type {ClassesResponse} from "@/controllers/classes.ts";
|
import type { ClassesResponse } from "@/controllers/classes.ts";
|
||||||
import type {TeacherDTO} from "dwengo-1-common/src/interfaces/teacher";
|
import type { TeacherDTO } from "dwengo-1-common/src/interfaces/teacher";
|
||||||
|
|
||||||
export interface TeachersResponse { teachers: TeacherDTO[] | string[] }
|
|
||||||
export interface TeacherResponse { teacher: TeacherDTO }
|
|
||||||
|
|
||||||
|
export interface TeachersResponse {
|
||||||
|
teachers: TeacherDTO[] | string[];
|
||||||
|
}
|
||||||
|
export interface TeacherResponse {
|
||||||
|
teacher: TeacherDTO;
|
||||||
|
}
|
||||||
|
|
||||||
export class TeacherController extends BaseController {
|
export class TeacherController extends BaseController {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -45,8 +48,16 @@ export class TeacherController extends BaseController {
|
||||||
return this.get<JoinRequestsResponse>(`/${username}/joinRequests/${classId}`);
|
return this.get<JoinRequestsResponse>(`/${username}/joinRequests/${classId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateStudentJoinRequest(teacherUsername: string, classId: string, studentUsername: string, accepted: boolean): Promise<JoinRequestResponse> {
|
async updateStudentJoinRequest(
|
||||||
return this.put<JoinRequestResponse>(`/${teacherUsername}/joinRequests/${classId}/${studentUsername}`, accepted);
|
teacherUsername: string,
|
||||||
|
classId: string,
|
||||||
|
studentUsername: string,
|
||||||
|
accepted: boolean,
|
||||||
|
): Promise<JoinRequestResponse> {
|
||||||
|
return this.put<JoinRequestResponse>(
|
||||||
|
`/${teacherUsername}/joinRequests/${classId}/${studentUsername}`,
|
||||||
|
accepted,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetInvitations(id: string) {return this.get<{ invitations: string[] }>(`/${id}/invitations`);}
|
// GetInvitations(id: string) {return this.get<{ invitations: string[] }>(`/${id}/invitations`);}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { BaseController } from "@/controllers/base-controller.ts";
|
import { BaseController } from "@/controllers/base-controller.ts";
|
||||||
import type {Theme} from "dwengo-1-common/src/interfaces/theme";
|
import type { Theme } from "dwengo-1-common/src/interfaces/theme";
|
||||||
|
|
||||||
export class ThemeController extends BaseController {
|
export class ThemeController extends BaseController {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -5,21 +5,21 @@ import {
|
||||||
type UseMutationReturnType,
|
type UseMutationReturnType,
|
||||||
useQuery,
|
useQuery,
|
||||||
useQueryClient,
|
useQueryClient,
|
||||||
type UseQueryReturnType
|
type UseQueryReturnType,
|
||||||
} from "@tanstack/vue-query";
|
} from "@tanstack/vue-query";
|
||||||
import {
|
import {
|
||||||
type JoinRequestResponse,
|
type JoinRequestResponse,
|
||||||
type JoinRequestsResponse,
|
type JoinRequestsResponse,
|
||||||
StudentController,
|
StudentController,
|
||||||
type StudentResponse,
|
type StudentResponse,
|
||||||
type StudentsResponse
|
type StudentsResponse,
|
||||||
} from "@/controllers/students.ts";
|
} from "@/controllers/students.ts";
|
||||||
import type {ClassesResponse} from "@/controllers/classes.ts";
|
import type { ClassesResponse } from "@/controllers/classes.ts";
|
||||||
import type {AssignmentsResponse} from "@/controllers/assignments.ts";
|
import type { AssignmentsResponse } from "@/controllers/assignments.ts";
|
||||||
import type {GroupsResponse} from "@/controllers/groups.ts";
|
import type { GroupsResponse } from "@/controllers/groups.ts";
|
||||||
import type {SubmissionsResponse} from "@/controllers/submissions.ts";
|
import type { SubmissionsResponse } from "@/controllers/submissions.ts";
|
||||||
import type {QuestionsResponse} from "@/controllers/questions.ts";
|
import type { QuestionsResponse } from "@/controllers/questions.ts";
|
||||||
import type {StudentDTO} from "dwengo-1-common/src/interfaces/student";
|
import type { StudentDTO } from "dwengo-1-common/src/interfaces/student";
|
||||||
|
|
||||||
const studentController = new StudentController();
|
const studentController = new StudentController();
|
||||||
|
|
||||||
|
@ -52,9 +52,7 @@ export function studentJoinRequestQueryKey(username: string, classId: string): [
|
||||||
return ["student-join-request", username, classId];
|
return ["student-join-request", username, classId];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useStudentsQuery(
|
export function useStudentsQuery(full: MaybeRefOrGetter<boolean> = true): UseQueryReturnType<StudentsResponse, Error> {
|
||||||
full: MaybeRefOrGetter<boolean> = true
|
|
||||||
): UseQueryReturnType<StudentsResponse, Error> {
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => studentsQueryKey(toValue(full))),
|
queryKey: computed(() => studentsQueryKey(toValue(full))),
|
||||||
queryFn: async () => studentController.getAll(toValue(full)),
|
queryFn: async () => studentController.getAll(toValue(full)),
|
||||||
|
@ -62,7 +60,7 @@ export function useStudentsQuery(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useStudentQuery(
|
export function useStudentQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
): UseQueryReturnType<StudentResponse, Error> {
|
): UseQueryReturnType<StudentResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => studentQueryKey(toValue(username)!)),
|
queryKey: computed(() => studentQueryKey(toValue(username)!)),
|
||||||
|
@ -73,7 +71,7 @@ export function useStudentQuery(
|
||||||
|
|
||||||
export function useStudentClassesQuery(
|
export function useStudentClassesQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>,
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
full: MaybeRefOrGetter<boolean> = true
|
full: MaybeRefOrGetter<boolean> = true,
|
||||||
): UseQueryReturnType<ClassesResponse, Error> {
|
): UseQueryReturnType<ClassesResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => studentClassesQueryKey(toValue(username)!, toValue(full))),
|
queryKey: computed(() => studentClassesQueryKey(toValue(username)!, toValue(full))),
|
||||||
|
@ -84,7 +82,7 @@ export function useStudentClassesQuery(
|
||||||
|
|
||||||
export function useStudentAssignmentsQuery(
|
export function useStudentAssignmentsQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>,
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
full: MaybeRefOrGetter<boolean> = true
|
full: MaybeRefOrGetter<boolean> = true,
|
||||||
): UseQueryReturnType<AssignmentsResponse, Error> {
|
): UseQueryReturnType<AssignmentsResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => studentAssignmentsQueryKey(toValue(username)!, toValue(full))),
|
queryKey: computed(() => studentAssignmentsQueryKey(toValue(username)!, toValue(full))),
|
||||||
|
@ -95,7 +93,7 @@ export function useStudentAssignmentsQuery(
|
||||||
|
|
||||||
export function useStudentGroupsQuery(
|
export function useStudentGroupsQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>,
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
full: MaybeRefOrGetter<boolean> = true
|
full: MaybeRefOrGetter<boolean> = true,
|
||||||
): UseQueryReturnType<GroupsResponse, Error> {
|
): UseQueryReturnType<GroupsResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => studentGroupsQueryKeys(toValue(username)!, toValue(full))),
|
queryKey: computed(() => studentGroupsQueryKeys(toValue(username)!, toValue(full))),
|
||||||
|
@ -105,7 +103,7 @@ export function useStudentGroupsQuery(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useStudentSubmissionsQuery(
|
export function useStudentSubmissionsQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
): UseQueryReturnType<SubmissionsResponse, Error> {
|
): UseQueryReturnType<SubmissionsResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => studentSubmissionsQueryKey(toValue(username)!)),
|
queryKey: computed(() => studentSubmissionsQueryKey(toValue(username)!)),
|
||||||
|
@ -116,7 +114,7 @@ export function useStudentSubmissionsQuery(
|
||||||
|
|
||||||
export function useStudentQuestionsQuery(
|
export function useStudentQuestionsQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>,
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
full: MaybeRefOrGetter<boolean> = true
|
full: MaybeRefOrGetter<boolean> = true,
|
||||||
): UseQueryReturnType<QuestionsResponse, Error> {
|
): UseQueryReturnType<QuestionsResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => studentQuestionsQueryKey(toValue(username)!, toValue(full))),
|
queryKey: computed(() => studentQuestionsQueryKey(toValue(username)!, toValue(full))),
|
||||||
|
@ -126,7 +124,7 @@ export function useStudentQuestionsQuery(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useStudentJoinRequestsQuery(
|
export function useStudentJoinRequestsQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
): UseQueryReturnType<JoinRequestsResponse, Error> {
|
): UseQueryReturnType<JoinRequestsResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => studentJoinRequestsQueryKey(toValue(username)!)),
|
queryKey: computed(() => studentJoinRequestsQueryKey(toValue(username)!)),
|
||||||
|
@ -137,7 +135,7 @@ export function useStudentJoinRequestsQuery(
|
||||||
|
|
||||||
export function useStudentJoinRequestQuery(
|
export function useStudentJoinRequestQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>,
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
classId: MaybeRefOrGetter<string | undefined>
|
classId: MaybeRefOrGetter<string | undefined>,
|
||||||
): UseQueryReturnType<JoinRequestResponse, Error> {
|
): UseQueryReturnType<JoinRequestResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => studentJoinRequestQueryKey(toValue(username)!, toValue(classId)!)),
|
queryKey: computed(() => studentJoinRequestQueryKey(toValue(username)!, toValue(classId)!)),
|
||||||
|
@ -146,12 +144,7 @@ export function useStudentJoinRequestQuery(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useCreateStudentMutation(): UseMutationReturnType<
|
export function useCreateStudentMutation(): UseMutationReturnType<StudentResponse, Error, StudentDTO, unknown> {
|
||||||
StudentResponse,
|
|
||||||
Error,
|
|
||||||
StudentDTO,
|
|
||||||
unknown
|
|
||||||
> {
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
|
@ -162,12 +155,7 @@ export function useCreateStudentMutation(): UseMutationReturnType<
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useDeleteStudentMutation(): UseMutationReturnType<
|
export function useDeleteStudentMutation(): UseMutationReturnType<StudentResponse, Error, string, unknown> {
|
||||||
StudentResponse,
|
|
||||||
Error,
|
|
||||||
string,
|
|
||||||
unknown
|
|
||||||
> {
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
|
@ -190,7 +178,9 @@ export function useCreateJoinRequestMutation(): UseMutationReturnType<
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async ({ username, classId }) => studentController.createJoinRequest(username, classId),
|
mutationFn: async ({ username, classId }) => studentController.createJoinRequest(username, classId),
|
||||||
onSuccess: async (newJoinRequest) => {
|
onSuccess: async (newJoinRequest) => {
|
||||||
await queryClient.invalidateQueries({ queryKey: studentJoinRequestsQueryKey(newJoinRequest.request.requester) });
|
await queryClient.invalidateQueries({
|
||||||
|
queryKey: studentJoinRequestsQueryKey(newJoinRequest.request.requester),
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,12 @@
|
||||||
import { computed, toValue } from "vue";
|
import { computed, toValue } from "vue";
|
||||||
import type { MaybeRefOrGetter } from "vue";
|
import type { MaybeRefOrGetter } from "vue";
|
||||||
import {
|
import { useMutation, useQuery, useQueryClient, UseMutationReturnType, UseQueryReturnType } from "@tanstack/vue-query";
|
||||||
useMutation,
|
import { TeacherController, type TeacherResponse, type TeachersResponse } from "@/controllers/teachers.ts";
|
||||||
useQuery,
|
import type { ClassesResponse } from "@/controllers/classes.ts";
|
||||||
useQueryClient,
|
import type { JoinRequestResponse, JoinRequestsResponse, StudentsResponse } from "@/controllers/students.ts";
|
||||||
UseMutationReturnType,
|
import type { QuestionsResponse } from "@/controllers/questions.ts";
|
||||||
UseQueryReturnType,
|
import type { TeacherDTO } from "dwengo-1-common/src/interfaces/teacher";
|
||||||
} from "@tanstack/vue-query";
|
import { studentJoinRequestQueryKey, studentJoinRequestsQueryKey } from "@/queries/students.ts";
|
||||||
import {TeacherController, type TeacherResponse, type TeachersResponse} from "@/controllers/teachers.ts";
|
|
||||||
import type {ClassesResponse} from "@/controllers/classes.ts";
|
|
||||||
import type {JoinRequestResponse, JoinRequestsResponse, StudentsResponse} from "@/controllers/students.ts";
|
|
||||||
import type {QuestionsResponse} from "@/controllers/questions.ts";
|
|
||||||
import type {TeacherDTO} from "dwengo-1-common/src/interfaces/teacher";
|
|
||||||
import {studentJoinRequestQueryKey, studentJoinRequestsQueryKey} from "@/queries/students.ts";
|
|
||||||
|
|
||||||
const teacherController = new TeacherController();
|
const teacherController = new TeacherController();
|
||||||
|
|
||||||
|
@ -37,10 +31,7 @@ function teacherQuestionsQueryKey(username: string, full: boolean): [string, str
|
||||||
return ["teacher-questions", username, full];
|
return ["teacher-questions", username, full];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useTeachersQuery(full: MaybeRefOrGetter<boolean> = false): UseQueryReturnType<TeachersResponse, Error> {
|
||||||
export function useTeachersQuery(
|
|
||||||
full: MaybeRefOrGetter<boolean> = false
|
|
||||||
): UseQueryReturnType<TeachersResponse, Error> {
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => teachersQueryKey(toValue(full))),
|
queryKey: computed(() => teachersQueryKey(toValue(full))),
|
||||||
queryFn: async () => teacherController.getAll(toValue(full)),
|
queryFn: async () => teacherController.getAll(toValue(full)),
|
||||||
|
@ -48,7 +39,7 @@ export function useTeachersQuery(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useTeacherQuery(
|
export function useTeacherQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
): UseQueryReturnType<TeacherResponse, Error> {
|
): UseQueryReturnType<TeacherResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => teacherQueryKey(toValue(username)!)),
|
queryKey: computed(() => teacherQueryKey(toValue(username)!)),
|
||||||
|
@ -59,7 +50,7 @@ export function useTeacherQuery(
|
||||||
|
|
||||||
export function useTeacherClassesQuery(
|
export function useTeacherClassesQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>,
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
full: MaybeRefOrGetter<boolean> = false
|
full: MaybeRefOrGetter<boolean> = false,
|
||||||
): UseQueryReturnType<ClassesResponse, Error> {
|
): UseQueryReturnType<ClassesResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => teacherClassesQueryKey(toValue(username)!, toValue(full))),
|
queryKey: computed(() => teacherClassesQueryKey(toValue(username)!, toValue(full))),
|
||||||
|
@ -70,7 +61,7 @@ export function useTeacherClassesQuery(
|
||||||
|
|
||||||
export function useTeacherStudentsQuery(
|
export function useTeacherStudentsQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>,
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
full: MaybeRefOrGetter<boolean> = false
|
full: MaybeRefOrGetter<boolean> = false,
|
||||||
): UseQueryReturnType<StudentsResponse, Error> {
|
): UseQueryReturnType<StudentsResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => teacherStudentsQueryKey(toValue(username)!, toValue(full))),
|
queryKey: computed(() => teacherStudentsQueryKey(toValue(username)!, toValue(full))),
|
||||||
|
@ -81,7 +72,7 @@ export function useTeacherStudentsQuery(
|
||||||
|
|
||||||
export function useTeacherQuestionsQuery(
|
export function useTeacherQuestionsQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>,
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
full: MaybeRefOrGetter<boolean> = false
|
full: MaybeRefOrGetter<boolean> = false,
|
||||||
): UseQueryReturnType<QuestionsResponse, Error> {
|
): UseQueryReturnType<QuestionsResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => teacherQuestionsQueryKey(toValue(username)!, toValue(full))),
|
queryKey: computed(() => teacherQuestionsQueryKey(toValue(username)!, toValue(full))),
|
||||||
|
@ -92,7 +83,7 @@ export function useTeacherQuestionsQuery(
|
||||||
|
|
||||||
export function useTeacherJoinRequestsQuery(
|
export function useTeacherJoinRequestsQuery(
|
||||||
username: MaybeRefOrGetter<string | undefined>,
|
username: MaybeRefOrGetter<string | undefined>,
|
||||||
classId: MaybeRefOrGetter<string | undefined>
|
classId: MaybeRefOrGetter<string | undefined>,
|
||||||
): UseQueryReturnType<JoinRequestsResponse, Error> {
|
): UseQueryReturnType<JoinRequestsResponse, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: computed(() => JOIN_REQUESTS_QUERY_KEY(toValue(username)!, toValue(classId)!)),
|
queryKey: computed(() => JOIN_REQUESTS_QUERY_KEY(toValue(username)!, toValue(classId)!)),
|
||||||
|
@ -101,12 +92,7 @@ export function useTeacherJoinRequestsQuery(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useCreateTeacherMutation(): UseMutationReturnType<
|
export function useCreateTeacherMutation(): UseMutationReturnType<TeacherResponse, Error, TeacherDTO, unknown> {
|
||||||
TeacherResponse,
|
|
||||||
Error,
|
|
||||||
TeacherDTO,
|
|
||||||
unknown
|
|
||||||
> {
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
|
@ -117,12 +103,7 @@ export function useCreateTeacherMutation(): UseMutationReturnType<
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useDeleteTeacherMutation(): UseMutationReturnType<
|
export function useDeleteTeacherMutation(): UseMutationReturnType<TeacherResponse, Error, string, unknown> {
|
||||||
TeacherResponse,
|
|
||||||
Error,
|
|
||||||
string,
|
|
||||||
unknown
|
|
||||||
> {
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {useQuery, type UseQueryReturnType} from "@tanstack/vue-query";
|
import { useQuery, type UseQueryReturnType } from "@tanstack/vue-query";
|
||||||
import { type MaybeRefOrGetter, toValue } from "vue";
|
import { type MaybeRefOrGetter, toValue } from "vue";
|
||||||
import { ThemeController } from "@/controllers/themes.ts";
|
import { ThemeController } from "@/controllers/themes.ts";
|
||||||
import type {Theme} from "dwengo-1-common/src/interfaces/theme";
|
import type { Theme } from "dwengo-1-common/src/interfaces/theme";
|
||||||
|
|
||||||
const themeController = new ThemeController();
|
const themeController = new ThemeController();
|
||||||
|
|
||||||
|
@ -16,7 +16,9 @@ export function useThemeQuery(language: MaybeRefOrGetter<string | undefined>): U
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useThemeHruidsQuery(themeKey: MaybeRefOrGetter<string | undefined>): UseQueryReturnType<string[], Error> {
|
export function useThemeHruidsQuery(
|
||||||
|
themeKey: MaybeRefOrGetter<string | undefined>,
|
||||||
|
): UseQueryReturnType<string[], Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ["theme-hruids", themeKey],
|
queryKey: ["theme-hruids", themeKey],
|
||||||
queryFn: async () => themeController.getHruidsByKey(toValue(themeKey)!),
|
queryFn: async () => themeController.getHruidsByKey(toValue(themeKey)!),
|
||||||
|
|
|
@ -120,6 +120,6 @@
|
||||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
/* Skip type checking all .d.ts files. */
|
/* Skip type checking all .d.ts files. */
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue