From 35afbf8b8283e7d0713b2ec5f8d4d22c40f40b33 Mon Sep 17 00:00:00 2001 From: emmanuel Date: Thu, 26 Oct 2023 21:17:58 +0000 Subject: [PATCH] CLASSROOMIO-T-248: add allow new user to course setting CLASSROOMIO-T-248:Updated code based on reviews Merge branch 'main' into CLASSROOMIO-T-248 CLASSROOMIO-T-248:Add allow new user to course setting Co-authored-by: Ifeanyi Nwosu Merge-request: CLASSROOMIO-MR-114 Merged-by: Best Admin --- .../Course/components/Settings/index.svelte | 26 +++++++++++++++---- .../Course/components/Settings/store.js | 1 + src/lib/components/Course/store.ts | 3 ++- .../components/PricingSection.svelte | 2 ++ .../components/CourseLandingPage/index.svelte | 5 ++-- src/lib/utils/types/index.ts | 1 + 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/lib/components/Course/components/Settings/index.svelte b/src/lib/components/Course/components/Settings/index.svelte index cd8b5db3..f389cd3b 100644 --- a/src/lib/components/Course/components/Settings/index.svelte +++ b/src/lib/components/Course/components/Settings/index.svelte @@ -26,7 +26,6 @@ let errors = {}; let avatar; - // controls widget open and close function widgetControl() { $handleOpenWidget.open = true; } @@ -118,6 +117,7 @@ logo, tabs, grading, + allow_new_students, lesson_download, is_published } = $settings; @@ -130,7 +130,8 @@ ...(isObject($course.metadata) ? $course.metadata : {}), lessonTabsOrder: tabs, grading: grading, - lessonDownload: lesson_download + lessonDownload: lesson_download, + allowNewStudent: allow_new_students } }); @@ -142,7 +143,8 @@ ...(isObject($course.metadata) ? $course.metadata : {}), lessonTabsOrder: tabs, grading: grading, - lessonDownload: lesson_download + lessonDownload: lesson_download, + allowNewStudent: allow_new_students }; snackbar.success('Saved successfully'); } catch (error) { @@ -153,7 +155,6 @@ }; function setDefault(course) { - console.log('course.is_published', course.is_published); if (course && Object.keys(course).length) { $settings = { course_title: course.title, @@ -162,13 +163,16 @@ tabs: course.metadata.lessonTabsOrder || $settings.tabs, grading: course.metadata.grading, lesson_download: course.metadata.lessonDownload, - is_published: course.is_published + is_published: course.is_published, + allow_new_students: course.metadata.allowNewStudent }; } } $: $settings.course_description = $course.description; $: $settings.course_title = $course.title; + $: $settings.allow_new_students = $settings.is_published; + $: setDefault($course); @@ -256,6 +260,18 @@ + + + Allow New Students +

Allow new students to access this course

+
+ + + Disable + Enable + + +
Order Lessons Tab diff --git a/src/lib/components/Course/components/Settings/store.js b/src/lib/components/Course/components/Settings/store.js index 437f5b2e..ba7b9bdc 100644 --- a/src/lib/components/Course/components/Settings/store.js +++ b/src/lib/components/Course/components/Settings/store.js @@ -5,6 +5,7 @@ export const settings = writable({ course_title: '', course_description: '', grading: false, + allow_new_students: false, tabs: [ { id: 1, name: 'Note' }, { id: 2, name: 'Slide' }, diff --git a/src/lib/components/Course/store.ts b/src/lib/components/Course/store.ts index 7b600036..daa83446 100644 --- a/src/lib/components/Course/store.ts +++ b/src/lib/components/Course/store.ts @@ -42,7 +42,8 @@ export const defaultCourse: Course = { { id: 3, name: 'Video' } ], grading: false, - lessonDownload: true + lessonDownload: true, + allowNewStudent: false } }; diff --git a/src/lib/components/CourseLandingPage/components/PricingSection.svelte b/src/lib/components/CourseLandingPage/components/PricingSection.svelte index a0f6c62e..63e935f3 100644 --- a/src/lib/components/CourseLandingPage/components/PricingSection.svelte +++ b/src/lib/components/CourseLandingPage/components/PricingSection.svelte @@ -99,6 +99,7 @@ label={isFree ? 'Join Course' : 'Buy Now'} className="w-full sm:w-full h-[40px]" onClick={handleJoinCourse} + isDisabled={!editMode && !courseData.metadata.allowNewStudent} /> @@ -135,6 +136,7 @@ label={isFree ? 'Join Course' : 'Buy Now'} className="w-full sm:w-full py-3 mb-3" onClick={handleJoinCourse} + isDisabled={!editMode && !courseData.metadata.allowNewStudent} />

Early bird offer. Buy ASAP

diff --git a/src/lib/components/CourseLandingPage/index.svelte b/src/lib/components/CourseLandingPage/index.svelte index caf3ff43..0df31447 100644 --- a/src/lib/components/CourseLandingPage/index.svelte +++ b/src/lib/components/CourseLandingPage/index.svelte @@ -40,7 +40,7 @@ let totalRatings = 0; let startCoursePayment = false; let isVisible = false; - let observer; + let observer: { destroy: () => void }; // initialize the expandDescription array with 'false' values for each review. let expandDescription = Array(reviews.length).fill(false); @@ -75,7 +75,7 @@ onMount(() => { window.onhashchange = locationHashChanged; const targetNode = document.querySelector('.target-component'); - observer = observeIntersection(targetNode, (inView) => { + observer = observeIntersection(targetNode, (inView: boolean) => { isVisible = inView; }); }); @@ -132,6 +132,7 @@ onClick={() => { startCoursePayment = true; }} + isDisabled={!editMode && !courseData.metadata.allowNewStudent} /> diff --git a/src/lib/utils/types/index.ts b/src/lib/utils/types/index.ts index 6f1e45dd..e6d583c4 100644 --- a/src/lib/utils/types/index.ts +++ b/src/lib/utils/types/index.ts @@ -81,6 +81,7 @@ interface CourseMetadata { lessonTabsOrder?: Array; grading?: boolean; lessonDownload?: boolean; + allowNewStudent: boolean; } export interface LessonCommentInsertPayload {