fix: refresh mentor completions on submission

This commit is contained in:
Livio Bieri 2024-01-15 14:06:28 +01:00 committed by Christian Cueni
parent fa2e96d220
commit a97ac4ec97
2 changed files with 13 additions and 11 deletions

View File

@ -1,8 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Participant, PraxisAssignment } from "@/services/mentorCockpit"; import type { Participant, PraxisAssignment } from "@/services/mentorCockpit";
import { useMentorCockpit } from "@/services/mentorCockpit"; import { useMentorCockpit } from "@/services/mentorCockpit";
import { computed, type Ref } from "vue"; import { computed, onMounted, type Ref } from "vue";
import { useCurrentCourseSession } from "@/composables"; import { useCurrentCourseSession } from "@/composables";
import log from "loglevel";
const props = defineProps<{ const props = defineProps<{
praxisAssignmentId: string; praxisAssignmentId: string;
@ -11,19 +12,19 @@ const props = defineProps<{
const courseSession = useCurrentCourseSession(); const courseSession = useCurrentCourseSession();
const mentorCockpitStore = useMentorCockpit(courseSession.value.id); const mentorCockpitStore = useMentorCockpit(courseSession.value.id);
const participants = computed(() => mentorCockpitStore.summary.value?.participants);
const praxisAssignment: Ref<PraxisAssignment | null> = computed(() => const praxisAssignment: Ref<PraxisAssignment | null> = computed(() =>
mentorCockpitStore.getPraxisAssignmentById(props.praxisAssignmentId) mentorCockpitStore.getPraxisAssignmentById(props.praxisAssignmentId)
); );
const getParticipantById = (id: string): Participant | null => { const getParticipantById = (id: string): Participant | null => {
if (mentorCockpitStore.summary.value?.participants) { return participants.value?.find((participant) => participant.id === id) || null;
const found = mentorCockpitStore.summary.value.participants.find(
(item) => item.id === id
);
return found || null;
}
return null;
}; };
onMounted(() => {
log.debug("MentorPraxisAssignment mounted");
mentorCockpitStore.fetchData();
});
</script> </script>
<template> <template>
@ -109,7 +110,7 @@ const getParticipantById = (id: string): Participant | null => {
class="underline" class="underline"
:to="item.url" :to="item.url"
> >
{{ $t("a.Bewertung anzeigen") }} {{ $t("a.Bewertung ansehen") }}
</router-link> </router-link>
</div> </div>
</div> </div>

View File

@ -1,4 +1,4 @@
import { itGetCached } from "@/fetchHelpers"; import { itGet } from "@/fetchHelpers";
import type { Ref } from "vue"; import type { Ref } from "vue";
import { ref, watchEffect } from "vue"; import { ref, watchEffect } from "vue";
@ -74,7 +74,7 @@ export const useMentorCockpit = (
summary.value = null; summary.value = null;
error.value = null; error.value = null;
itGetCached(`/api/mentor/${courseSessionId}/summary`) itGet(`/api/mentor/${courseSessionId}/summary`)
.then((response) => { .then((response) => {
summary.value = response; summary.value = response;
}) })
@ -94,5 +94,6 @@ export const useMentorCockpit = (
error, error,
getCircleTitleById, getCircleTitleById,
getPraxisAssignmentById, getPraxisAssignmentById,
fetchData,
}; };
}; };