From d6472a54ca5807a5673f04ddc9c8bcbbed676626 Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Mon, 30 Oct 2023 04:52:00 +0000 Subject: [PATCH] course landing page improvements --- .../AI/AIButton/CustomPromptBtn.svelte | 1 + src/lib/components/Backdrop/index.svelte | 20 ++++-- .../components/Buttons/VisitOrgSite.svelte | 8 +-- .../Course/components/Settings/index.svelte | 64 ++++++++++-------- .../components/PricingSection.svelte | 66 +++++++++++-------- .../components/CourseLandingPage/index.svelte | 5 +- src/lib/components/Form/TextArea.svelte | 2 +- .../Snackbar/{constants.js => constants.ts} | 0 src/lib/components/Snackbar/index.svelte | 12 ++-- src/lib/utils/services/courses/index.ts | 2 +- .../utils/services/org/{index.js => index.ts} | 52 +++++++++++---- src/lib/utils/store/org.ts | 13 +++- src/lib/utils/store/user.ts | 2 +- src/lib/utils/types/index.ts | 11 ++-- src/lib/utils/types/org.ts | 8 +++ src/routes/+layout.svelte | 24 +++---- .../courses/[id]/landingpage/+page.svelte | 7 +- .../courses/[id]/submissions/+page.svelte | 4 +- 18 files changed, 189 insertions(+), 112 deletions(-) rename src/lib/components/Snackbar/{constants.js => constants.ts} (100%) rename src/lib/utils/services/org/{index.js => index.ts} (78%) diff --git a/src/lib/components/AI/AIButton/CustomPromptBtn.svelte b/src/lib/components/AI/AIButton/CustomPromptBtn.svelte index 3939896c..8793420c 100644 --- a/src/lib/components/AI/AIButton/CustomPromptBtn.svelte +++ b/src/lib/components/AI/AIButton/CustomPromptBtn.svelte @@ -47,6 +47,7 @@ } $: onCompletion($completion); + $: prompt = defaultPrompt;
diff --git a/src/lib/components/Backdrop/index.svelte b/src/lib/components/Backdrop/index.svelte index b5efb34e..d8e50c29 100644 --- a/src/lib/components/Backdrop/index.svelte +++ b/src/lib/components/Backdrop/index.svelte @@ -1,4 +1,12 @@ -
+ + +
@@ -8,15 +16,17 @@ left: 0; right: 0; bottom: 0; - display: flex; position: fixed; - align-items: center; - justify-content: center; background-color: rgba(0, 0, 0, 0.3); -webkit-tap-highlight-color: transparent; color: #fff; z-index: 1201; - opacity: 1; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; } + + .center { + display: flex; + align-items: center; + justify-content: center; + } diff --git a/src/lib/components/Buttons/VisitOrgSite.svelte b/src/lib/components/Buttons/VisitOrgSite.svelte index 48f82008..abb32bf4 100644 --- a/src/lib/components/Buttons/VisitOrgSite.svelte +++ b/src/lib/components/Buttons/VisitOrgSite.svelte @@ -1,17 +1,13 @@ - + {#if !$isMobile} View site diff --git a/src/lib/components/Course/components/Settings/index.svelte b/src/lib/components/Course/components/Settings/index.svelte index dadd26c1..5ddf147c 100644 --- a/src/lib/components/Course/components/Settings/index.svelte +++ b/src/lib/components/Course/components/Settings/index.svelte @@ -16,7 +16,7 @@ import { currentOrgPath } from '$lib/utils/store/org'; import { isObject } from '$lib/utils/functions/isObject'; import { lessons } from '../Lesson/store/lessons'; - import { currentOrg } from '$lib/utils/store/org'; + import { currentOrg, currentOrgDomain } from '$lib/utils/store/org'; import { snackbar } from '$lib/components/Snackbar/store'; import UploadWidget from '$lib/components/UploadWidget/index.svelte'; import { handleOpenWidget } from '$lib/components/CourseLandingPage/store'; @@ -24,14 +24,17 @@ let isSaving = false; let isLoading = false; let isDeleting = false; - let errors = {}; - let avatar; + let errors: { + title: string | undefined; + description: string | undefined; + } = { title: undefined, description: undefined }; + let avatar: string | undefined; function widgetControl() { $handleOpenWidget.open = true; } - function getLessonOrder(id) { + function getLessonOrder(id: string) { const index = $lessons.findIndex((lesson) => lesson.id === id); if (index < 9) { return '0' + (index + 1); @@ -172,7 +175,6 @@ $: $settings.course_description = $course.description; $: $settings.course_title = $course.title; - $: $settings.allow_new_students = $settings.is_published; $: setDefault($course); @@ -238,11 +240,7 @@

Course Link

{#if $course.slug} - + {:else} {/if} @@ -256,23 +254,12 @@ - Disable - Enable - - - - - - Allow New Students -

Allow new students to access this course

-
- - - Disable - Enable + Disabled + Enabled
+ Order Lessons Tab @@ -289,8 +276,8 @@ - Disable - Enable + Disabled + Enabled @@ -301,8 +288,8 @@ + + + Allow New Students +

Allow new students to access this course

+
+ + + Disabled + Enabled + + +
+ @@ -317,7 +317,13 @@

This determines if your course displays on your landing page

- + { + $settings.allow_new_students = e.detail.toggled; + }} + > Unpublished Published diff --git a/src/lib/components/CourseLandingPage/components/PricingSection.svelte b/src/lib/components/CourseLandingPage/components/PricingSection.svelte index 63e935f3..c179a265 100644 --- a/src/lib/components/CourseLandingPage/components/PricingSection.svelte +++ b/src/lib/components/CourseLandingPage/components/PricingSection.svelte @@ -53,7 +53,7 @@ $: setFormatter(courseData.currency); $: discount = get(courseData, 'metadata.discount', 0); - $: calculatedCost = calcDisc(discount, courseData.cost || 0, courseData.metadata.showDiscount); + $: calculatedCost = calcDisc(discount, courseData.cost || 0, !!courseData.metadata.showDiscount); $: isFree = isCourseFree(calculatedCost); @@ -77,18 +77,24 @@
-

- {formatter?.format(calculatedCost) || calculatedCost} - {#if isFree} - (Free) + {#if courseData?.metadata?.allowNewStudent} +

+ {formatter?.format(calculatedCost) || calculatedCost} + {#if isFree} + (Free) + {/if} +

+ {#if courseData?.metadata?.showDiscount} +

+ {discount}% Discount. + {formatter?.format(courseData?.cost || 0) || courseData.cost} +

{/if} -

- {#if courseData?.metadata?.showDiscount} -

- {discount}% Discount. - {formatter?.format(courseData?.cost || 0) || courseData.cost} + {:else} +

+ This course is currently not accepting new students.

{/if}
@@ -99,7 +105,7 @@ label={isFree ? 'Join Course' : 'Buy Now'} className="w-full sm:w-full h-[40px]" onClick={handleJoinCourse} - isDisabled={!editMode && !courseData.metadata.allowNewStudent} + isDisabled={!courseData.metadata.allowNewStudent} />
@@ -114,18 +120,24 @@
-

- {formatter?.format(calculatedCost) || calculatedCost} - {#if isFree} - (Free) + {#if courseData?.metadata?.allowNewStudent} +

+ {formatter?.format(calculatedCost) || calculatedCost} + {#if isFree} + (Free) + {/if} +

+ {#if courseData?.metadata?.showDiscount} +

+ {discount}% Discount. + {formatter?.format(courseData?.cost || 0) || courseData.cost} +

{/if} -

- {#if courseData?.metadata?.showDiscount} -

- {discount}% Discount. - {formatter?.format(courseData?.cost || 0) || courseData.cost} + {:else} +

+ This course is currently not accepting new students.

{/if}
@@ -136,9 +148,11 @@ label={isFree ? 'Join Course' : 'Buy Now'} className="w-full sm:w-full py-3 mb-3" onClick={handleJoinCourse} - isDisabled={!editMode && !courseData.metadata.allowNewStudent} + isDisabled={!courseData.metadata.allowNewStudent} /> -

Early bird offer. Buy ASAP

+ {#if courseData?.metadata?.showDiscount && courseData.metadata.allowNewStudent} +

Early bird offer. Buy ASAP

+ {/if}
diff --git a/src/lib/components/CourseLandingPage/index.svelte b/src/lib/components/CourseLandingPage/index.svelte index e3889821..61f002af 100644 --- a/src/lib/components/CourseLandingPage/index.svelte +++ b/src/lib/components/CourseLandingPage/index.svelte @@ -128,9 +128,10 @@ label="Start Course" className="px-6 py-5 mt-6 sm:w-fit hidden md:block" onClick={() => { + if (editMode) return; startCoursePayment = true; }} - isDisabled={!editMode && !courseData.metadata.allowNewStudent} + isDisabled={!courseData.metadata.allowNewStudent} />
@@ -202,7 +203,7 @@ {navItem.label} diff --git a/src/lib/components/Form/TextArea.svelte b/src/lib/components/Form/TextArea.svelte index 780474e8..bb62c5c3 100644 --- a/src/lib/components/Form/TextArea.svelte +++ b/src/lib/components/Form/TextArea.svelte @@ -36,7 +36,7 @@ {#if isAIEnabled} { value = v; diff --git a/src/lib/components/Snackbar/constants.js b/src/lib/components/Snackbar/constants.ts similarity index 100% rename from src/lib/components/Snackbar/constants.js rename to src/lib/components/Snackbar/constants.ts diff --git a/src/lib/components/Snackbar/index.svelte b/src/lib/components/Snackbar/index.svelte index f367de44..19ebd297 100644 --- a/src/lib/components/Snackbar/index.svelte +++ b/src/lib/components/Snackbar/index.svelte @@ -1,4 +1,4 @@ -