Clean up code to make typechecker happy

This commit is contained in:
Ramon Wenger 2022-12-28 17:27:32 +01:00
parent a4a93a2214
commit 5bcfda9156
6 changed files with 13 additions and 57 deletions

View File

@ -182,6 +182,10 @@ const nextStep = () => {
const sendFeedback = () => {
log.info("sending feedback");
const courseSession = courseSessionsStore.courseSessionForRoute;
if (!courseSession || !courseSession.id) {
log.error("no course session set");
return;
}
const input: SendFeedbackInput = reactive({
materialsRating,
courseNegativeFeedback,

View File

@ -1,13 +1,13 @@
<template>
<div class="container-medium">
<div class="mt-4 lg:mt-12">
<Feedback :page="content" />
<FeedbackForm :page="content" />
</div>
</div>
</template>
<script setup lang="ts">
import Feedback from "@/components/Feedback.vue";
import FeedbackForm from "@/components/FeedbackForm.vue";
import type { LearningContent } from "@/types";
interface Value {

View File

@ -8,7 +8,7 @@
<div class="flex flex-col justify-start align-items-start justify-items-start">
<ItCheckbox
v-for="item in items"
:key="item.id"
:key="item.value"
:label="item.name"
class="mb-4"
/>
@ -20,12 +20,6 @@
import type { RadioItem } from "@/components/learningPath/feedback.types";
import ItCheckbox from "@/components/ui/ItCheckbox.vue";
import {
RadioGroup,
// RadioGroupDescription,
RadioGroupLabel,
RadioGroupOption,
} from "@headlessui/vue";
defineProps<{
modelValue: any;

View File

@ -1,3 +1,5 @@
export const COMPLETION_SUCCESS = "success";
export const COMPLETION_FAILURE = "fail";
export const COMPLETION_UNKNOWN = "unknown";
import type { CourseCompletionStatus } from "@/types";
export const COMPLETION_SUCCESS: CourseCompletionStatus = "success";
export const COMPLETION_FAILURE: CourseCompletionStatus = "fail";
export const COMPLETION_UNKNOWN: CourseCompletionStatus = "unknown";

View File

@ -67,47 +67,3 @@ export const useSetupCourseSessionsStore = defineStore("courseSessionsSetup", ()
hasCockpit,
};
});
export const useOptionsCourseSessionsStore = defineStore({
id: "courseSessions",
state: () => {
return {
courseSessions: [] as CourseSession[],
};
},
getters: {
courseSessionForRoute: (state): CourseSession | undefined => {
const route = useRoute();
const routePath = decodeURI(route.path);
return state.courseSessions?.find((cs) => {
return routePath.startsWith(cs.course_url);
});
},
coursesFromCourseSessions: (state) => {
if (state.courseSessions) {
return _.uniqBy(state.courseSessions, "course.id");
}
},
hasCockpit() {
const userStore = useUserStore();
return (
this.courseSessionForRoute &&
(this.courseSessionForRoute as unknown as CourseSession).experts.filter(
(expert) => expert.user_id === userStore.id
).length > 0
);
},
},
actions: {
async loadCourseSessionsData(reload = false) {
log.debug("loadCourseSessionsData called");
this.courseSessions = await itGetCached(`/api/course/sessions/`, {
reload: reload,
});
if (!this.courseSessions) {
throw `No courseSessionData found for user`;
}
return this.courseSessions;
},
},
});

View File

@ -30,5 +30,5 @@ export function learningContentTypeData(t: LearningContentType): {
return { title: "In Umsetzung", icon: "it-icon-lc-document" };
}
return assertUnreachable(t);
return assertUnreachable();
}