diff --git a/client/src/components/learningPath/LearningContent.vue b/client/src/components/learningPath/LearningContent.vue index 4386f600..d0e57c41 100644 --- a/client/src/components/learningPath/LearningContent.vue +++ b/client/src/components/learningPath/LearningContent.vue @@ -4,12 +4,16 @@ import { useCircleStore } from "@/stores/circle"; import type { LearningContent } from "@/types"; import * as log from "loglevel"; import { computed } from "vue"; -import { useRoute } from "vue-router"; + +import DescriptionBlock from "@/components/learningPath/blocks/DescriptionBlock.vue"; +import DescriptionTextBlock from "@/components/learningPath/blocks/DescriptionTextBlock.vue"; +import FeedbackBlock from "@/components/learningPath/blocks/FeedbackBlock.vue"; +import IframeBlock from "@/components/learningPath/blocks/IframeBlock.vue"; +import PlaceholderBlock from "@/components/learningPath/blocks/PlaceholderBlock.vue"; +import VideoBlock from "@/components/learningPath/blocks/VideoBlock.vue"; log.debug("LearningContent.vue setup"); -const route = useRoute(); - const circleStore = useCircleStore(); const props = defineProps<{ @@ -23,71 +27,45 @@ const block = computed(() => { return undefined; }); + +// can't use the type as component name, as some are reserved HTML components, e.g. video +const COMPONENTS: Record> = { + placeholder: PlaceholderBlock, + video: VideoBlock, + assignment: DescriptionTextBlock, + resource: DescriptionTextBlock, + exercise: IframeBlock, + test: IframeBlock, + learningmodule: IframeBlock, + feedback: FeedbackBlock, +}; +const DEFAULT_BLOCK = DescriptionBlock; + +const component = computed(() => { + if (block.value) { + return COMPONENTS[block.value.type] || DEFAULT_BLOCK; + } + return DEFAULT_BLOCK; +});