diff --git a/frontend/src/components/GroupProgressRow.vue b/frontend/src/components/GroupProgressRow.vue index 022e07c5..f012b8cc 100644 --- a/frontend/src/components/GroupProgressRow.vue +++ b/frontend/src/components/GroupProgressRow.vue @@ -2,7 +2,7 @@ import { useGetLearningPathQuery } from "@/queries/learning-paths.ts"; import { computed } from "vue"; import type { Language } from "@/data-objects/language.ts"; -import type { LearningPath } from "@/data-objects/learning-paths/learning-path.ts"; +import {calculateProgress} from "@/utils/assignment-utils.ts"; const props = defineProps<{ groupNumber: number; @@ -12,10 +12,6 @@ const props = defineProps<{ classId: string; }>(); -function calculateProgress(lp: LearningPath): number { - return ((lp.amountOfNodes - lp.amountOfNodesLeft) / lp.amountOfNodes) * 100; -} - const query = useGetLearningPathQuery( () => props.learningPath, () => props.language, @@ -30,12 +26,18 @@ const progress = computed(() => { if (!query.data.value) return 0; return calculateProgress(query.data.value); }); + +const progressColor = computed(() => { + if (progress.value < 50) return "error"; + if (progress.value < 80) return "warning"; + return "success"; +});