diff --git a/src/components/Course/components/Lesson/Materials/EditMode.svelte b/src/components/Course/components/Lesson/Materials/EditMode.svelte index 6e935001..c7d21955 100644 --- a/src/components/Course/components/Lesson/Materials/EditMode.svelte +++ b/src/components/Course/components/Lesson/Materials/EditMode.svelte @@ -16,11 +16,11 @@ value: 1, }, { - label: 'Slide', + label: 'Video', value: 2, }, { - label: 'Video', + label: 'Slide', value: 3, }, ]; @@ -57,18 +57,18 @@ /> - ($isLessonDirty = true)} - /> - - ($isLessonDirty = true)} /> + + ($isLessonDirty = true)} + /> + diff --git a/src/components/Course/components/Lesson/Materials/ViewMode.svelte b/src/components/Course/components/Lesson/Materials/ViewMode.svelte index c4cb0914..a2910608 100644 --- a/src/components/Course/components/Lesson/Materials/ViewMode.svelte +++ b/src/components/Course/components/Lesson/Materials/ViewMode.svelte @@ -11,21 +11,42 @@ value: 1, }, { - label: 'Slide', + label: 'Video', value: 2, }, { - label: 'Video', + label: 'Slide', value: 3, }, ]; + let currentTab = tabs[0].value; + let errors = {}; function onChange(tabValue) { return () => { currentTab = tabValue; }; } + + function formatYoutubeVideo(url) { + console.log(`url`, url); + if (url.includes('embed')) { + return url; + } + + const splitedUrl = url.split('watch'); + + if (splitedUrl.length !== 2) { + errors.video = 'Wrong url format'; + + return; + } + + const query = new URLSearchParams(splitedUrl[1]); + + return `https://www.youtube.com/embed/${query.get('v')}`; + } @@ -36,11 +57,33 @@ {:else}

No note added

- Video not found + Lesson note not found
{/if} + {#if $lesson.materials.video_url && $lesson.materials.video_url.includes('youtube')} + {#each $lesson.materials.video_url.split(',') as url} +
+