fix(frontend): Linting errors/warnings opgelost

This commit is contained in:
Gerald Schmittinger 2025-04-01 15:00:47 +02:00
parent b2e6b33716
commit 4d98be78c1
26 changed files with 272 additions and 258 deletions

View file

@ -1,22 +1,25 @@
<script setup lang="ts">
import { useRouter } from "vue-router";
import { onMounted } from "vue";
import {onMounted, ref, type Ref} from "vue";
import auth from "../services/auth/auth-service.ts";
const router = useRouter();
const errorMessage: Ref<string | null> = ref(null);
onMounted(async () => {
try {
await auth.handleLoginCallback();
await router.replace("/user"); // Redirect to theme page
} catch (_error) {
// FIXME console.error("OIDC callback error:", error);
} catch (error) {
errorMessage.value = `OIDC callback error: ${error}`;
}
});
</script>
<template>
<p>Logging you in...</p>
<p v-if="!errorMessage">Logging you in...</p>
<p v-else>{{ errorMessage }}</p>
</template>
<style scoped></style>

View file

@ -1,6 +1,4 @@
<script setup lang="ts">
import auth from "@/services/auth/auth-service.ts";
import apiClient from "@/services/api-client/api-client.ts";
import { ref } from "vue";
import dwengoLogo from "../../../assets/img/dwengo-groen-zwart.svg";
import { useI18n } from "vue-i18n";

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import type {LearningPath} from "@/data-objects/learning-path.ts";
import type {LearningPath} from "@/data-objects/learning-paths/learning-path.ts";
import LearningPathsGrid from "@/components/LearningPathsGrid.vue";
import UsingQueryResult from "@/components/UsingQueryResult.vue";
import {useGetAllLearningPathsByThemeQuery} from "@/queries/learning-paths.ts";
@ -23,7 +23,7 @@ const learningPathsForThemeQueryResult = useGetAllLearningPathsByThemeQuery(() =
const { t } = useI18n();
const searchFilter = ref("");
function filterLearningPaths(learningPaths: LearningPath[]) {
function filterLearningPaths(learningPaths: LearningPath[]): LearningPath[] {
return learningPaths.filter(it =>
it.title.toLowerCase().includes(searchFilter.value.toLowerCase())
|| it.description.toLowerCase().includes(searchFilter.value.toLowerCase)

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
import {Language} from "@/data-objects/language.ts";
import {type UseQueryReturnType} from "@tanstack/vue-query";
import type {UseQueryReturnType} from "@tanstack/vue-query";
import {useLearningObjectHTMLQuery} from "@/queries/learning-objects.ts";
import UsingQueryResult from "@/components/UsingQueryResult.vue";

View file

@ -1,10 +1,9 @@
<script setup lang="ts">
import {Language} from "@/data-objects/language.ts";
import {type LearningPath, LearningPathNode} from "@/data-objects/learning-path.ts";
import {computed, type ComputedRef, ref, watch} from "vue";
import type {LearningObject} from "@/data-objects/learning-object.ts";
import {useRoute, useRouter} from "vue-router";
import {type SuccessState} from "@/services/api-client/remote-resource.ts";
import type {LearningPath} from "@/data-objects/learning-paths/learning-path.ts";
import {computed, type ComputedRef, ref} from "vue";
import type {LearningObject} from "@/data-objects/learning-objects/learning-object.ts";
import {useRoute} from "vue-router";
import LearningObjectView from "@/views/learning-paths/LearningObjectView.vue";
import {useI18n} from "vue-i18n";
import LearningPathSearchField from "@/components/LearningPathSearchField.vue";
@ -12,8 +11,8 @@
import {useLearningObjectListForPathQuery} from "@/queries/learning-objects.ts";
import UsingQueryResult from "@/components/UsingQueryResult.vue";
import authService from "@/services/auth/auth-service.ts";
import {LearningPathNode} from "@/data-objects/learning-paths/learning-path-node.ts";
const router = useRouter();
const route = useRoute();
const { t } = useI18n();
@ -30,11 +29,11 @@
forStudent: route.query.forStudent,
forGroup: route.query.forGroup
} as Personalization
} else {
}
return {
forStudent: authService.authState.user?.profile?.preferred_username
} as Personalization
}
});
const learningPathQueryResult = useGetLearningPathQuery(
@ -51,61 +50,45 @@
const currentNode = computed(() => {
const currentHruid = props.learningObjectHruid;
if (nodesList.value) {
return nodesList.value.filter(it => it.learningobjectHruid === currentHruid)[0]
}
return nodesList.value?.find(it => it.learningobjectHruid === currentHruid);
});
const nextNode = computed(() => {
if (!currentNode.value || !nodesList.value)
return;
return undefined;
const currentIndex = nodesList.value?.indexOf(currentNode.value);
if (currentIndex < nodesList.value?.length) {
return nodesList.value?.[currentIndex + 1];
}
return currentIndex < nodesList.value?.length ? nodesList.value?.[currentIndex + 1] : undefined;
});
const previousNode = computed(() => {
if (!currentNode.value || !nodesList.value)
return;
return undefined;
const currentIndex = nodesList.value?.indexOf(currentNode.value);
if (currentIndex < nodesList.value?.length) {
return nodesList.value?.[currentIndex - 1];
}
});
watch(() => learningPathQueryResult, (newValue) => {
if (learningPathQueryResult.isSuccess && false) {
router.push({
path: router.currentRoute.value.path + "/" + (newValue as SuccessState<LearningPath>).data.startNode.learningobjectHruid,
query: route.query,
});
}
return currentIndex < nodesList.value?.length ? nodesList.value?.[currentIndex - 1] : undefined;
});
const navigationDrawerShown = ref(true);
function isLearningObjectCompleted(learningObject: LearningObject): boolean {
if (learningObjectListQueryResult.isSuccess) {
return learningPathQueryResult.data.value.nodesAsList.filter(it =>
return learningPathQueryResult.data.value.nodesAsList.find(it =>
it.learningobjectHruid === learningObject.key
&& it.version === learningObject.version
&& it.language == learningObject.language
)[0].done;
&& it.language === learningObject.language
).done;
}
return false;
}
type NavItemState = "teacherExclusive" | "completed" | "notCompleted";
const ICONS: {[key: NavItemState]: string} = {
const ICONS: Record<NavItemState, string> = {
teacherExclusive: "mdi-information",
completed: "mdi-checkbox-marked-circle-outline",
notCompleted: "mdi-checkbox-blank-circle-outline"
}
const COLORS: {[key: NavItemState]: string | undefined} = {
const COLORS: Record<NavItemState, string | undefined> = {
teacherExclusive: "info",
completed: "success",
notCompleted: undefined
@ -116,9 +99,9 @@
return "teacherExclusive";
} else if (isLearningObjectCompleted(learningObject)) {
return "completed";
} else {
return "notCompleted";
}
return "notCompleted";
}
</script>
@ -151,6 +134,7 @@
:to="{path: node.key, query: route.query}"
:title="node.title"
:active="node.key === props.learningObjectHruid"
:key="node.key"
v-if="!node.teacherExclusive || authService.authState.activeRole === 'teacher'"
>
<template v-slot:prepend>

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
import type {LearningPath} from "@/data-objects/learning-path.ts";
import {useRoute, useRouter} from "vue-router";
import type {LearningPath} from "@/data-objects/learning-paths/learning-path.ts";
import {useRoute} from "vue-router";
import {computed} from "vue";
import {useI18n} from "vue-i18n";
import LearningPathSearchField from "@/components/LearningPathSearchField.vue";
@ -9,7 +9,6 @@
import LearningPathsGrid from "@/components/LearningPathsGrid.vue";
const route = useRoute();
const router = useRouter();
const { t } = useI18n();
const query = computed(() => route.query.query as string | null);