From f876ce1807c12d0758e0f9bf0ca6641de399f625 Mon Sep 17 00:00:00 2001 From: Bram Reyniers Date: Fri, 3 May 2024 11:35:17 +0200 Subject: [PATCH] run formatter --- frontend/src/router/index.ts | 11 +++++++++-- frontend/src/router/middleware/canVisit.ts | 17 ++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 4f783c6d..1ec00919 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -2,7 +2,12 @@ import { createRouter, createWebHistory } from "vue-router"; import { type Middleware, type MiddlewareContext, nextFactory } from "./middleware/index"; import isAuthenticated from "./middleware/isAuthenticated"; import loginMiddleware from "./middleware/login"; -import useCanVisit, { useIsAdminCondition, useIsTeacherCondition, useIsPartOfSubjectCondition, useAndCondition } from "./middleware/canVisit"; +import useCanVisit, { + useIsAdminCondition, + useIsTeacherCondition, + useIsPartOfSubjectCondition, + useAndCondition, +} from "./middleware/canVisit"; import { ref } from "vue"; declare module "vue-router" { @@ -93,7 +98,9 @@ const router = createRouter({ component: () => import("../views/CreateProjectView.vue"), props: (route) => ({ subjectId: Number(route.params.subjectId) }), meta: { - middleware: useCanVisit(useAndCondition(useIsPartOfSubjectCondition, useIsTeacherCondition)), + middleware: useCanVisit( + useAndCondition(useIsPartOfSubjectCondition, useIsTeacherCondition) + ), }, }, { diff --git a/frontend/src/router/middleware/canVisit.ts b/frontend/src/router/middleware/canVisit.ts index 51cf3223..0496a9d5 100644 --- a/frontend/src/router/middleware/canVisit.ts +++ b/frontend/src/router/middleware/canVisit.ts @@ -6,7 +6,10 @@ import useIsTeacher from "@/composables/useIsTeacher"; import { useSubjectsQuery } from "@/queries/Subject"; export interface CanVisitCondition { - (queryClient: QueryClient, context: MiddlewareContext): { condition: Ref; isLoading: Ref }; + ( + queryClient: QueryClient, + context: MiddlewareContext + ): { condition: Ref; isLoading: Ref }; } function useCanVisit(useCondition: CanVisitCondition): Middleware { @@ -72,10 +75,10 @@ export const useIsTeacherCondition: CanVisitCondition = (qc) => { }; export const useIsPartOfSubjectCondition: CanVisitCondition = (qc, ctx) => { - const subjectId = Number(ctx.to.params.subjectId); - const {data: subjects, isLoading} = useSubjectsQuery(qc); - const condition = computed(() => { - return subjects.value?.findIndex((subject) => subject.id === subjectId) !== -1; - }) - return { condition, isLoading }; + const subjectId = Number(ctx.to.params.subjectId); + const { data: subjects, isLoading } = useSubjectsQuery(qc); + const condition = computed(() => { + return subjects.value?.findIndex((subject) => subject.id === subjectId) !== -1; + }); + return { condition, isLoading }; };