wip: Update copy, fix typecheck
This commit is contained in:
parent
0d982f937c
commit
5d7898d415
|
|
@ -23,7 +23,7 @@ onMounted(async () => {
|
||||||
:details-link="`/dashboard/persons`"
|
:details-link="`/dashboard/persons`"
|
||||||
data-cy="dashboard.mentor.competenceSummary"
|
data-cy="dashboard.mentor.competenceSummary"
|
||||||
>
|
>
|
||||||
<template #title>{{ $t("Personen") }}</template>
|
<template #title>{{ $t("a.Personen") }}</template>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="flex flex-row space-x-3 bg-white pb-6">
|
<div class="flex flex-row space-x-3 bg-white pb-6">
|
||||||
<div
|
<div
|
||||||
|
|
@ -32,7 +32,7 @@ onMounted(async () => {
|
||||||
<span>{{ menteeCount }}</span>
|
<span>{{ menteeCount }}</span>
|
||||||
</div>
|
</div>
|
||||||
<p class="ml-3 mt-0 leading-[74px]">
|
<p class="ml-3 mt-0 leading-[74px]">
|
||||||
{{ $t("Personen, die du begleitest") }}
|
{{ $t("a.Personen, die du begleitest") }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ export function useCourseData(courseSlug: string) {
|
||||||
log.error(result.error);
|
log.error(result.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
course.value = result.data?.course as Course;
|
course.value = result.data?.course as unknown as Course;
|
||||||
actionCompetences.value = result.data?.course
|
actionCompetences.value = result.data?.course
|
||||||
?.action_competences as ActionCompetence[];
|
?.action_competences as ActionCompetence[];
|
||||||
learningPath.value = result.data?.course?.learning_path as LearningPathType;
|
learningPath.value = result.data?.course?.learning_path as LearningPathType;
|
||||||
|
|
|
||||||
|
|
@ -348,6 +348,7 @@ export type CourseConfigurationObjectType = {
|
||||||
enable_learning_mentor: Scalars['Boolean']['output'];
|
enable_learning_mentor: Scalars['Boolean']['output'];
|
||||||
id: Scalars['ID']['output'];
|
id: Scalars['ID']['output'];
|
||||||
is_uk: Scalars['Boolean']['output'];
|
is_uk: Scalars['Boolean']['output'];
|
||||||
|
is_vv: Scalars['Boolean']['output'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CourseObjectType = {
|
export type CourseObjectType = {
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,7 @@ type CourseConfigurationObjectType {
|
||||||
enable_circle_documents: Boolean!
|
enable_circle_documents: Boolean!
|
||||||
enable_learning_mentor: Boolean!
|
enable_learning_mentor: Boolean!
|
||||||
enable_competence_certificates: Boolean!
|
enable_competence_certificates: Boolean!
|
||||||
|
is_vv: Boolean!
|
||||||
is_uk: Boolean!
|
is_uk: Boolean!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ import { computed, onMounted } from "vue";
|
||||||
import type { CompetenceCertificate } from "@/types";
|
import type { CompetenceCertificate } from "@/types";
|
||||||
import { useCurrentCourseSession } from "@/composables";
|
import { useCurrentCourseSession } from "@/composables";
|
||||||
import CompetenceCertificateComponent from "@/pages/competence/CompetenceCertificateComponent.vue";
|
import CompetenceCertificateComponent from "@/pages/competence/CompetenceCertificateComponent.vue";
|
||||||
|
import {
|
||||||
|
isCompetenceCertificateForUserQueryQuery,
|
||||||
|
isCompetenceCertificateQueryQuery,
|
||||||
|
} from "@/services/competence";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseSlug: string;
|
courseSlug: string;
|
||||||
|
|
@ -42,15 +46,30 @@ const certificatesQuery = (() => {
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const certificate = computed(() => {
|
const certificate = computed(() => {
|
||||||
const certificate = props.userId
|
const data = certificatesQuery.data.value;
|
||||||
? certificatesQuery.data?.value?.competence_certificate_list_for_user
|
if (!data) {
|
||||||
: certificatesQuery.data?.value?.competence_certificate_list;
|
return null;
|
||||||
if (certificate) {
|
|
||||||
return (
|
|
||||||
(certificate.competence_certificates as unknown as CompetenceCertificate[]) ?? []
|
|
||||||
).find((cc) => cc.slug.endsWith(props.certificateSlug));
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
let certificate;
|
||||||
|
|
||||||
|
if (props.userId && isCompetenceCertificateForUserQueryQuery(data)) {
|
||||||
|
certificate = data.competence_certificate_list_for_user;
|
||||||
|
} else if (isCompetenceCertificateQueryQuery(data)) {
|
||||||
|
certificate = data.competence_certificate_list;
|
||||||
|
} else {
|
||||||
|
// Handle case where data does not match expected types
|
||||||
|
console.error("Data structure is not recognized!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!certificate) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
(certificate.competence_certificates as unknown as CompetenceCertificate[]) ?? []
|
||||||
|
).find((cc) => cc.slug.endsWith(props.certificateSlug));
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ import {
|
||||||
assignmentsUserPoints,
|
assignmentsUserPoints,
|
||||||
} from "@/pages/competence/utils";
|
} from "@/pages/competence/utils";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
|
import {
|
||||||
|
isCompetenceCertificateForUserQueryQuery,
|
||||||
|
isCompetenceCertificateQueryQuery,
|
||||||
|
} from "@/services/competence";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseSlug: string;
|
courseSlug: string;
|
||||||
|
|
@ -47,16 +51,30 @@ const certificatesQuery = (() => {
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const competenceCertificates = computed(() => {
|
const competenceCertificates = computed(() => {
|
||||||
const certificates = props.userId
|
const data = certificatesQuery.data.value;
|
||||||
? certificatesQuery.data?.value?.competence_certificate_list_for_user
|
if (!data) {
|
||||||
: certificatesQuery.data?.value?.competence_certificate_list;
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
let certificate;
|
||||||
|
|
||||||
|
if (props.userId && isCompetenceCertificateForUserQueryQuery(data)) {
|
||||||
|
certificate = data.competence_certificate_list_for_user;
|
||||||
|
} else if (isCompetenceCertificateQueryQuery(data)) {
|
||||||
|
certificate = data.competence_certificate_list;
|
||||||
|
} else {
|
||||||
|
// Handle case where data does not match expected types
|
||||||
|
console.error("Data structure is not recognized!");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
(certificates?.competence_certificates as unknown as CompetenceCertificate[]) ?? []
|
(certificate?.competence_certificates as unknown as CompetenceCertificate[]) ?? []
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const assignments = computed(() => {
|
const assignments = computed(() => {
|
||||||
return competenceCertificates.value.flatMap((cc) => cc.assignments);
|
return competenceCertificates?.value?.flatMap((cc) => cc.assignments);
|
||||||
});
|
});
|
||||||
|
|
||||||
const totalPointsEvaluatedAssignments = computed(() => {
|
const totalPointsEvaluatedAssignments = computed(() => {
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,21 @@ if (useCurrentCourseSession().value.course.configuration.is_uk) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function convertRouteRecordNameToString(
|
||||||
|
routeRecordName: string | symbol | undefined
|
||||||
|
): string {
|
||||||
|
if (!routeRecordName) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (typeof routeRecordName === "symbol") {
|
||||||
|
// Convert symbol to string explicitly
|
||||||
|
return routeRecordName.toString();
|
||||||
|
} else {
|
||||||
|
// It's already a string, return as is
|
||||||
|
return routeRecordName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -66,7 +81,7 @@ const route = useRoute();
|
||||||
class="flex w-full items-center space-x-2 p-2 pr-4 text-blue-900 hover:bg-gray-200 lg:pr-8"
|
class="flex w-full items-center space-x-2 p-2 pr-4 text-blue-900 hover:bg-gray-200 lg:pr-8"
|
||||||
:class="{
|
:class="{
|
||||||
'text-bold bg-gray-200': route.matched.some((record) =>
|
'text-bold bg-gray-200': route.matched.some((record) =>
|
||||||
entry.routeMatch.includes(record.name)
|
entry.routeMatch.includes(convertRouteRecordNameToString(record?.name))
|
||||||
),
|
),
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
import type {
|
||||||
|
CompetenceCertificateForUserQueryQuery,
|
||||||
|
CompetenceCertificateQueryQuery,
|
||||||
|
} from "@/gql/graphql";
|
||||||
import type { PerformanceCriteria } from "@/types";
|
import type { PerformanceCriteria } from "@/types";
|
||||||
import groupBy from "lodash/groupBy";
|
import groupBy from "lodash/groupBy";
|
||||||
|
|
||||||
|
|
@ -17,3 +21,21 @@ export function calcPerformanceCriteriaStatusCount(criteria: PerformanceCriteria
|
||||||
FAIL: 0,
|
FAIL: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Type guards
|
||||||
|
export function isCompetenceCertificateForUserQueryQuery(
|
||||||
|
data: any
|
||||||
|
): data is CompetenceCertificateForUserQueryQuery {
|
||||||
|
return (
|
||||||
|
(data as CompetenceCertificateForUserQueryQuery)
|
||||||
|
.competence_certificate_list_for_user !== undefined
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isCompetenceCertificateQueryQuery(
|
||||||
|
data: any
|
||||||
|
): data is CompetenceCertificateQueryQuery {
|
||||||
|
return (
|
||||||
|
(data as CompetenceCertificateQueryQuery).competence_certificate_list !== undefined
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ export const fetchDashboardConfig = async (): Promise<DashboardConfigType[] | nu
|
||||||
console.error("Error fetching dashboard config:", res.error);
|
console.error("Error fetching dashboard config:", res.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.data?.dashboard_config || null;
|
return (res.data?.dashboard_config as unknown as DashboardConfigType[]) || null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching dashboard config:", error);
|
console.error("Error fetching dashboard config:", error);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,8 @@ export interface CourseCategory {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
general: boolean;
|
general: boolean;
|
||||||
|
is_uk: boolean;
|
||||||
|
is_vv: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MediaLibraryContentBlockValue = {
|
export type MediaLibraryContentBlockValue = {
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@ class CourseConfigurationObjectType(DjangoObjectType):
|
||||||
"enable_learning_mentor",
|
"enable_learning_mentor",
|
||||||
"enable_competence_certificates",
|
"enable_competence_certificates",
|
||||||
"is_uk",
|
"is_uk",
|
||||||
|
"is_vv",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue