style: fix linting issues met Prettier
This commit is contained in:
parent
a824cdff94
commit
783c91b2e3
11 changed files with 112 additions and 93 deletions
|
@ -3,7 +3,7 @@ import type { ClassDTO } from "@dwengo-1/common/interfaces/class";
|
|||
import type { StudentsResponse } from "./students";
|
||||
import type { AssignmentsResponse } from "./assignments";
|
||||
import type { TeachersResponse } from "@/controllers/teachers.ts";
|
||||
import type {TeacherInvitationsResponse} from "@/controllers/teacher-invitations.ts";
|
||||
import type { TeacherInvitationsResponse } from "@/controllers/teacher-invitations.ts";
|
||||
|
||||
export interface ClassesResponse {
|
||||
classes: ClassDTO[] | string[];
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import {BaseController} from "@/controllers/base-controller.ts";
|
||||
import type {TeacherInvitationData, TeacherInvitationDTO} from "@dwengo-1/common/interfaces/teacher-invitation";
|
||||
import { BaseController } from "@/controllers/base-controller.ts";
|
||||
import type { TeacherInvitationData, TeacherInvitationDTO } from "@dwengo-1/common/interfaces/teacher-invitation";
|
||||
|
||||
export interface TeacherInvitationsResponse {
|
||||
invitations: TeacherInvitationDTO[]
|
||||
invitations: TeacherInvitationDTO[];
|
||||
}
|
||||
|
||||
export interface TeacherInvitationResponse {
|
||||
invitation: TeacherInvitationDTO
|
||||
invitation: TeacherInvitationDTO;
|
||||
}
|
||||
|
||||
export class TeacherInvitationController extends BaseController {
|
||||
|
|
|
@ -1,65 +1,80 @@
|
|||
import {
|
||||
useMutation,
|
||||
useQuery,
|
||||
type UseMutationReturnType,
|
||||
type UseQueryReturnType,
|
||||
} from "@tanstack/vue-query";
|
||||
import { useMutation, useQuery, type UseMutationReturnType, type UseQueryReturnType } from "@tanstack/vue-query";
|
||||
import { computed, toValue } from "vue";
|
||||
import type { MaybeRefOrGetter } from "vue";
|
||||
import {
|
||||
TeacherInvitationController,
|
||||
type TeacherInvitationResponse,
|
||||
type TeacherInvitationsResponse
|
||||
type TeacherInvitationsResponse,
|
||||
} from "@/controllers/teacher-invitations.ts";
|
||||
import type {TeacherInvitationData} from "@dwengo-1/common/dist/interfaces/teacher-invitation.ts";
|
||||
import type {TeacherDTO} from "@dwengo-1/common/dist/interfaces/teacher.ts";
|
||||
import type { TeacherInvitationData } from "@dwengo-1/common/dist/interfaces/teacher-invitation.ts";
|
||||
import type { TeacherDTO } from "@dwengo-1/common/dist/interfaces/teacher.ts";
|
||||
|
||||
const controller = new TeacherInvitationController();
|
||||
|
||||
/**
|
||||
All the invitations the teacher send
|
||||
**/
|
||||
export function useTeacherInvitationsByQuery(username: MaybeRefOrGetter<string | undefined>
|
||||
export function useTeacherInvitationsByQuery(
|
||||
username: MaybeRefOrGetter<string | undefined>,
|
||||
): UseQueryReturnType<TeacherInvitationsResponse, Error> {
|
||||
return useQuery({
|
||||
queryFn: computed(async () => controller.getAll(toValue(username), true)),
|
||||
enabled: () => Boolean(toValue(username)),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
All the pending invitations send to this teacher
|
||||
*/
|
||||
export function useTeacherInvitationsForQuery(username: MaybeRefOrGetter<string | undefined>
|
||||
export function useTeacherInvitationsForQuery(
|
||||
username: MaybeRefOrGetter<string | undefined>,
|
||||
): UseQueryReturnType<TeacherInvitationsResponse, Error> {
|
||||
return useQuery({
|
||||
queryFn: computed(async () => controller.getAll(toValue(username), false)),
|
||||
enabled: () => Boolean(toValue(username)),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateTeacherInvitationMutation(): UseMutationReturnType<TeacherInvitationResponse, Error, TeacherDTO, unknown>{
|
||||
export function useCreateTeacherInvitationMutation(): UseMutationReturnType<
|
||||
TeacherInvitationResponse,
|
||||
Error,
|
||||
TeacherDTO,
|
||||
unknown
|
||||
> {
|
||||
return useMutation({
|
||||
mutationFn: async (data: TeacherInvitationData) => controller.create(data)
|
||||
})
|
||||
mutationFn: async (data: TeacherInvitationData) => controller.create(data),
|
||||
});
|
||||
}
|
||||
|
||||
export function useAcceptTeacherInvitationMutation(): UseMutationReturnType<TeacherInvitationResponse, Error, TeacherDTO, unknown> {
|
||||
export function useAcceptTeacherInvitationMutation(): UseMutationReturnType<
|
||||
TeacherInvitationResponse,
|
||||
Error,
|
||||
TeacherDTO,
|
||||
unknown
|
||||
> {
|
||||
return useMutation({
|
||||
mutationFn: async (data: TeacherInvitationData) => controller.respond(data, true)
|
||||
})
|
||||
mutationFn: async (data: TeacherInvitationData) => controller.respond(data, true),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeclineTeacherInvitationMutation(): UseMutationReturnType<TeacherInvitationResponse, Error, TeacherDTO, unknown> {
|
||||
export function useDeclineTeacherInvitationMutation(): UseMutationReturnType<
|
||||
TeacherInvitationResponse,
|
||||
Error,
|
||||
TeacherDTO,
|
||||
unknown
|
||||
> {
|
||||
return useMutation({
|
||||
mutationFn: async (data: TeacherInvitationData) => controller.respond(data, false)
|
||||
})
|
||||
mutationFn: async (data: TeacherInvitationData) => controller.respond(data, false),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteTeacherInvitationMutation(): UseMutationReturnType<TeacherInvitationResponse, Error, TeacherDTO, unknown> {
|
||||
export function useDeleteTeacherInvitationMutation(): UseMutationReturnType<
|
||||
TeacherInvitationResponse,
|
||||
Error,
|
||||
TeacherDTO,
|
||||
unknown
|
||||
> {
|
||||
return useMutation({
|
||||
mutationFn: async (data: TeacherInvitationData) => controller.respond(data, false)
|
||||
})
|
||||
mutationFn: async (data: TeacherInvitationData) => controller.respond(data, false),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -279,7 +279,8 @@
|
|||
:key="i.classId"
|
||||
>
|
||||
<td>
|
||||
{{ i.classId }} <!-- TODO fetch display name via classId because db only returns classId field -->
|
||||
{{ i.classId }}
|
||||
<!-- TODO fetch display name via classId because db only returns classId field -->
|
||||
</td>
|
||||
<td>{{ (i.sender as TeacherDTO).firstName + " " + (i.sender as TeacherDTO).lastName }}</td>
|
||||
<td class="text-right">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue