From fcd0bcc656ef1b1df3b1a305a5e539bb6cac3026 Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Sun, 7 Apr 2024 06:08:34 +0100 Subject: [PATCH] feat: dashboard billing (#193) * feat: move plans into sharable json * remove unused code * update pnpm lock * update plans.json * implement early adopter pricing * docs: update meta title and description * Finished the UI for upgrading plans * Updated the pricing plans * Updated the cards ui * use relative import * improve styling of upgrade plan card * styling improvements, lemonsqueezy setup * trigger lemonsqueezy payment and add webhook * update pnpm lock * add logout route * feat: complete billing functionality * generate lock file * make crypto false on browser * feat: adding upgrade prompts to org * chore: add upgrade icon to upload video * feat: add upgrade prompt to certificate and settings * feat: implement onboarding setup page (#229) * working on the onboarding setup * working on the onboarding page * Almost done with the onboarding UI * finished the UI of the onBoarding setup * finished the UI of the onBoarding setup * Implementing the functions to carryout the logic of updating the UI onmount if a user has carried out a certain step or not * Implementing the functions to carryout the logic of updating the UI onmount if a user has carried out a certain step or not * making some chnages * finished the onBoarding task * updated some logic * Removed the uneeded svg from the static folder * fixed isCoursePublished not returning a boolean * improved the setup link protection * chore: make menuItems reactive * improve formatting * format supabase queries --------- Co-authored-by: Rotimi Best * revamp setup * improve the upgrade experience * migration * feat: add lemonsqueezy customer portal --------- Co-authored-by: emmanuel --- README.md | 4 +- apps/classroomio-com/README.md | 4 +- apps/classroomio-com/package.json | 1 + apps/classroomio-com/src/app.html | 6 +- apps/classroomio-com/src/lib/Faq/Faq.svelte | 24 +- .../src/lib/Footer/Footer.svelte | 60 ++--- apps/classroomio-com/src/lib/Hero/Hero.svelte | 7 +- .../src/lib/Pricing/Pricing.svelte | 171 ++++++-------- apps/classroomio-com/vite.config.js | 2 +- apps/dashboard/.env.example | 4 +- apps/dashboard/.gitignore | 1 + apps/dashboard/README.md | 4 +- apps/dashboard/package.json | 7 + apps/dashboard/src/app.html | 11 +- .../components/Poll/components/Poll.svelte | 2 +- .../components/Poll/components/Tabs.svelte | 2 +- .../src/lib/components/Apps/index.svelte | 2 +- .../src/lib/components/Box/index.svelte | 2 +- .../components/Buttons/Logout/index.svelte | 24 +- .../components/Buttons/VisitOrgSite.svelte | 3 +- .../src/lib/components/Chip/Plan.svelte | 9 + .../components/Ceritficate/Design.svelte | 31 ++- .../components/Ceritficate/Reports.svelte | 4 +- .../components/Lesson/AddLessonModal.svelte | 2 +- .../Lesson/Exercises/NewExerciseModal.svelte | 4 +- .../Lesson/Materials/Video/Index.svelte | 18 +- .../Lesson/Materials/Video/LocalVideo.svelte | 16 +- .../Navigation/NavExpandable.svelte | 6 + .../Course/components/Navigation/index.svelte | 33 ++- .../components/NewsFeed/NewsFeedCard.svelte | 6 +- .../Course/components/Settings/index.svelte | 35 +-- .../Courses/components/Card/index.svelte | 23 +- .../components/Form/AutoGrowTextField.svelte | 2 +- .../src/lib/components/Form/TextArea.svelte | 2 +- .../src/lib/components/Form/TextField.svelte | 2 +- .../lib/components/Icons/AudienceIcon.svelte | 4 +- .../lib/components/Icons/CourseIcon.svelte | 4 +- .../src/lib/components/Icons/HomeIcon.svelte | 4 +- .../src/lib/components/Icons/QuizIcon.svelte | 4 +- .../components/Icons/SiteSettingsIcon.svelte | 4 +- .../lib/components/Icons/StepDoneIcon.svelte | 6 + .../src/lib/components/LMS/SideBar.svelte | 2 +- .../components/LMS/components/Profile.svelte | 4 +- .../src/lib/components/Modal/index.svelte | 12 +- .../components/Org/Community/Loader.svelte | 2 +- .../src/lib/components/Org/Quiz/Loader.svelte | 2 +- .../components/Org/Settings/Billing.svelte | 46 ++++ .../components/Org/Settings/Domains.svelte | 2 +- .../Org/Settings/Integrations.svelte | 2 +- .../Org/Settings/LandingpageSettings.svelte | 2 +- .../Org/Settings/OrgSettings.svelte | 16 +- .../components/Org/Settings/Profile.svelte | 4 +- .../Org/Settings/TeamMembers.svelte | 8 +- .../lib/components/Org/Settings/index.svelte | 11 + .../src/lib/components/Org/SideBar.svelte | 199 +++++++++------- .../components/OrgSelector/OrgSelector.svelte | 56 ++++- .../OrgSelector/OrgSelectorItem.svelte | 13 +- .../lib/components/PrimaryButton/constants.js | 5 +- .../lib/components/PrimaryButton/index.svelte | 15 +- .../src/lib/components/Upgrade/Banner.svelte | 23 ++ .../src/lib/components/Upgrade/Modal.svelte | 220 ++++++++++++++++++ .../lib/components/UploadImage/index.svelte | 2 +- .../WelcomeModal/WelcomeModal.svelte | 19 +- apps/dashboard/src/lib/utils/constants/app.js | 3 +- .../src/lib/utils/functions/logout.ts | 23 ++ apps/dashboard/src/lib/utils/functions/org.ts | 12 + .../lib/utils/services/lemonsqueezy/index.ts | 11 + .../utils/services/lemonsqueezy/subscribe.ts | 24 ++ .../src/lib/utils/services/org/index.ts | 51 +++- apps/dashboard/src/lib/utils/store/org.ts | 22 +- apps/dashboard/src/lib/utils/types/index.ts | 11 + apps/dashboard/src/lib/utils/types/org.ts | 7 +- apps/dashboard/src/routes/+layout.svelte | 2 + .../api/completion/customprompt/+server.js | 4 +- .../src/routes/api/lmz/subscribe/+server.js | 38 +++ .../routes/api/lmz/subscriptions/+server.js | 23 ++ .../src/routes/api/lmz/webhook/+server.js | 77 ++++++ .../src/routes/api/stripe/webhook/+server.js | 57 +++++ .../courses/[id]/certificates/+page.svelte | 3 +- .../routes/courses/[id]/lessons/+page.svelte | 2 +- apps/dashboard/src/routes/logout/+page.svelte | 12 + .../src/routes/org/[slug]/+layout.server.ts | 5 + .../src/routes/org/[slug]/+layout.svelte | 15 +- .../src/routes/org/[slug]/+page.svelte | 10 +- .../routes/org/[slug]/audience/+page.svelte | 18 +- .../routes/org/[slug]/courses/+page.svelte | 2 + .../routes/org/[slug]/settings/+page.svelte | 2 +- .../org/[slug]/settings/domains/+page.svelte | 2 +- .../org/[slug]/settings/teams/+page.svelte | 4 +- .../src/routes/org/[slug]/setup/+page.svelte | 128 ++++++++++ .../src/routes/org/[slug]/setup/+page.ts | 146 ++++++++++++ apps/dashboard/static/upgrade.png | Bin 0 -> 4223 bytes apps/dashboard/vite.config.ts | 17 +- apps/docs/pages/index.mdx | 2 +- apps/docs/theme.config.tsx | 9 +- packages/shared-constants/package.json | 7 + .../shared-constants/src/plans/constants.ts | 43 ++++ packages/shared-constants/src/plans/data.json | 75 ++++++ packages/shared-constants/src/plans/types.ts | 0 packages/shared-constants/src/plans/utils.ts | 7 + packages/shared-constants/tsconfig.json | 3 + packages/tsconfig/base.json | 3 +- pnpm-lock.yaml | 39 ++++ .../migrations/20240406215136_org_billing.sql | 26 +++ supabase/seed.sql | 36 --- 105 files changed, 1743 insertions(+), 463 deletions(-) create mode 100644 apps/dashboard/src/lib/components/Chip/Plan.svelte create mode 100644 apps/dashboard/src/lib/components/Icons/StepDoneIcon.svelte create mode 100644 apps/dashboard/src/lib/components/Org/Settings/Billing.svelte create mode 100644 apps/dashboard/src/lib/components/Upgrade/Banner.svelte create mode 100644 apps/dashboard/src/lib/components/Upgrade/Modal.svelte create mode 100644 apps/dashboard/src/lib/utils/functions/logout.ts create mode 100644 apps/dashboard/src/lib/utils/services/lemonsqueezy/index.ts create mode 100644 apps/dashboard/src/lib/utils/services/lemonsqueezy/subscribe.ts create mode 100644 apps/dashboard/src/routes/api/lmz/subscribe/+server.js create mode 100644 apps/dashboard/src/routes/api/lmz/subscriptions/+server.js create mode 100644 apps/dashboard/src/routes/api/lmz/webhook/+server.js create mode 100644 apps/dashboard/src/routes/api/stripe/webhook/+server.js create mode 100644 apps/dashboard/src/routes/logout/+page.svelte create mode 100644 apps/dashboard/src/routes/org/[slug]/+layout.server.ts create mode 100644 apps/dashboard/src/routes/org/[slug]/setup/+page.svelte create mode 100644 apps/dashboard/src/routes/org/[slug]/setup/+page.ts create mode 100644 apps/dashboard/static/upgrade.png create mode 100644 packages/shared-constants/package.json create mode 100644 packages/shared-constants/src/plans/constants.ts create mode 100644 packages/shared-constants/src/plans/data.json create mode 100644 packages/shared-constants/src/plans/types.ts create mode 100644 packages/shared-constants/src/plans/utils.ts create mode 100644 packages/shared-constants/tsconfig.json create mode 100644 supabase/migrations/20240406215136_org_billing.sql diff --git a/README.md b/README.md index a1aad74d..50d771bb 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ - ClassroomIO is a no-code tool that allows you build and scale your own teaching platform with ease. + ClassroomIO is a no-code tool that allows you build and scale your online bootcamp with ease.

ClassroomIO.com

- The Open Source Teaching Platform + The Open Source Teaching Platform for Bootcamps
Website | Join Discord community

diff --git a/apps/classroomio-com/README.md b/apps/classroomio-com/README.md index e0a67256..5fa8703f 100644 --- a/apps/classroomio-com/README.md +++ b/apps/classroomio-com/README.md @@ -1,9 +1,9 @@ - ClassroomIO is a no-code tool that allows you build and scale your own teaching platform with ease. + ClassroomIO is the easiest place to launch and scale your online bootcamp.

ClassroomIO

-The Open Source Teaching Platform +The Open Source Teaching Platform for Bootcamps ## Tools diff --git a/apps/classroomio-com/package.json b/apps/classroomio-com/package.json index d02daa66..3bd6840c 100644 --- a/apps/classroomio-com/package.json +++ b/apps/classroomio-com/package.json @@ -30,6 +30,7 @@ "rehype-slug": "^6.0.0", "remark-toc": "^9.0.0", "remark-unwrap-images": "^4.0.0", + "shared-constants": "workspace:*", "shiki": "^0.14.7" } } diff --git a/apps/classroomio-com/src/app.html b/apps/classroomio-com/src/app.html index d5d4cb20..0439de2e 100644 --- a/apps/classroomio-com/src/app.html +++ b/apps/classroomio-com/src/app.html @@ -22,7 +22,7 @@ @@ -44,7 +44,7 @@ /> @@ -60,7 +60,7 @@ /> diff --git a/apps/classroomio-com/src/lib/Faq/Faq.svelte b/apps/classroomio-com/src/lib/Faq/Faq.svelte index 9b994840..fb0b8f9d 100644 --- a/apps/classroomio-com/src/lib/Faq/Faq.svelte +++ b/apps/classroomio-com/src/lib/Faq/Faq.svelte @@ -2,29 +2,29 @@ import { faqs } from './faqs'; -
-
-

+
+
+

Questions & Answers

Can’t find the answer you’re looking for? - Shoot us an email and we’ll get back to you ASAP.

-
+
{#each faqs as faq}

{faq.question}

{faq.answer}

@@ -33,16 +33,16 @@
-

- Supercharge your Classroom Today +

+ Launch Your Bootcamp Today

-

+

Try before you buy. No credit card required.

Monthly Annually
Save 2 months
-
- -
-

Hobby

-

- For personal use. Hobby plan is free for up to 5 courses forever, no credit card required. +

+ + - -
-

Pro

-

- Advanced features for small teaching businesses. Built for scale. + +

+

+ {PLANS.EARLY_ADOPTER.NAME}

-

- ${prices ? '12' : '15'} /member +

+ {PLANS.EARLY_ADOPTER.DESCRIPTION}

- -
- -
-

Team

-

- Best suited for teams and larger businesses that need more control. + +

+

+ {PLANS.ENTERPRISE.NAME}

-

- ${prices ? '42' : '50'} /member +

+ {PLANS.ENTERPRISE.DESCRIPTION} +

+

+ Request Pricing

-
    - {#each teamFeatures as teamFeature} +
      + {#each PLANS.ENTERPRISE.FEATURES as features}
    • - {teamFeature} + {features}
    • {/each}
    @@ -172,7 +155,7 @@ class="m-0 lg:mt-1 text-md leading-7 lg:leading-6 text-gray-600" > For personal use. Hobby plan is free for up to 5 courses forever, no - credit card required. + credit Card required.

{/each} diff --git a/apps/dashboard/src/lib/components/Course/components/Lesson/Materials/Video/LocalVideo.svelte b/apps/dashboard/src/lib/components/Course/components/Lesson/Materials/Video/LocalVideo.svelte index 1d2c191b..8d70f44c 100644 --- a/apps/dashboard/src/lib/components/Course/components/Lesson/Materials/Video/LocalVideo.svelte +++ b/apps/dashboard/src/lib/components/Course/components/Lesson/Materials/Video/LocalVideo.svelte @@ -1,4 +1,4 @@ - + ($uploadCourseVideoStore.isModalOpen = false)}> + Upgrade your plan to upload vidoes + + {#if !isLoaded}
diff --git a/apps/dashboard/src/lib/components/Course/components/Settings/index.svelte b/apps/dashboard/src/lib/components/Course/components/Settings/index.svelte index 656a319e..2b4c378d 100644 --- a/apps/dashboard/src/lib/components/Course/components/Settings/index.svelte +++ b/apps/dashboard/src/lib/components/Course/components/Settings/index.svelte @@ -14,13 +14,14 @@ import { course } from '$lib/components/Course/store'; import type { Course } from '$lib/utils/types'; import { updateCourse, deleteCourse } from '$lib/utils/services/courses'; - import { currentOrgPath } from '$lib/utils/store/org'; + import { currentOrgPath, isFreePlan } from '$lib/utils/store/org'; import { isObject } from '$lib/utils/functions/isObject'; import { lessons } from '../Lesson/store/lessons'; 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'; + import UpgradeBanner from '$lib/components/Upgrade/Banner.svelte'; import { Restart } from 'carbon-icons-svelte'; import IconButton from '$lib/components/IconButton/index.svelte'; @@ -186,7 +187,7 @@ $: setDefault($course); - + Cover Image @@ -287,10 +288,14 @@

Make the Lesson available for Download in pdf for registered students

- - Disabled - Enabled - + {#if $isFreePlan} + Upgrade to download lessons + {:else} + + Disabled + Enabled + + {/if}
@@ -299,13 +304,17 @@

Make the Course available for Download for registered students

- + {#if $isFreePlan} + Upgrade to download course + {:else} + + {/if}
diff --git a/apps/dashboard/src/lib/components/Courses/components/Card/index.svelte b/apps/dashboard/src/lib/components/Courses/components/Card/index.svelte index 6fba2e7c..59459029 100644 --- a/apps/dashboard/src/lib/components/Courses/components/Card/index.svelte +++ b/apps/dashboard/src/lib/components/Courses/components/Card/index.svelte @@ -1,11 +1,18 @@ + + diff --git a/apps/dashboard/src/lib/components/LMS/SideBar.svelte b/apps/dashboard/src/lib/components/LMS/SideBar.svelte index 20322873..29b5a461 100644 --- a/apps/dashboard/src/lib/components/LMS/SideBar.svelte +++ b/apps/dashboard/src/lib/components/LMS/SideBar.svelte @@ -56,7 +56,7 @@ } overflow-y-auto transition w-[250px] min-w-[250px] bg-gray-100 dark:bg-neutral-900 h-[calc(100vh-48px)]`} >
-
+
- +

Profile Picture

@@ -83,6 +84,7 @@ @@ -32,12 +32,14 @@
e.stopPropagation()} role="presentation" > -
-

+

+

{modalHeading}

{#if isCloseable} @@ -47,7 +49,7 @@ {/if}
-
+
diff --git a/apps/dashboard/src/lib/components/Org/Community/Loader.svelte b/apps/dashboard/src/lib/components/Org/Community/Loader.svelte index 1c4092b3..6adfc253 100644 --- a/apps/dashboard/src/lib/components/Org/Community/Loader.svelte +++ b/apps/dashboard/src/lib/components/Org/Community/Loader.svelte @@ -3,7 +3,7 @@
diff --git a/apps/dashboard/src/lib/components/Org/Quiz/Loader.svelte b/apps/dashboard/src/lib/components/Org/Quiz/Loader.svelte index b945156f..c822d42c 100644 --- a/apps/dashboard/src/lib/components/Org/Quiz/Loader.svelte +++ b/apps/dashboard/src/lib/components/Org/Quiz/Loader.svelte @@ -3,7 +3,7 @@
diff --git a/apps/dashboard/src/lib/components/Org/Settings/Billing.svelte b/apps/dashboard/src/lib/components/Org/Settings/Billing.svelte new file mode 100644 index 00000000..ae6929b0 --- /dev/null +++ b/apps/dashboard/src/lib/components/Org/Settings/Billing.svelte @@ -0,0 +1,46 @@ + + + + + Billing details + +

Manage your billing

+ {#if $isFreePlan} + You don't have any active billing + {:else} +

We use Lemonsqueezy to help manage your billing

+ + + {/if} +
+
+
diff --git a/apps/dashboard/src/lib/components/Org/Settings/Domains.svelte b/apps/dashboard/src/lib/components/Org/Settings/Domains.svelte index beab4f98..bcd3dff0 100644 --- a/apps/dashboard/src/lib/components/Org/Settings/Domains.svelte +++ b/apps/dashboard/src/lib/components/Org/Settings/Domains.svelte @@ -72,7 +72,7 @@ $: setSiteName($currentOrg.siteName); - + Add diff --git a/apps/dashboard/src/lib/components/Org/Settings/Integrations.svelte b/apps/dashboard/src/lib/components/Org/Settings/Integrations.svelte index c96dbd18..bd71cf18 100644 --- a/apps/dashboard/src/lib/components/Org/Settings/Integrations.svelte +++ b/apps/dashboard/src/lib/components/Org/Settings/Integrations.svelte @@ -48,7 +48,7 @@ } - + diff --git a/apps/dashboard/src/lib/components/Org/Settings/LandingpageSettings.svelte b/apps/dashboard/src/lib/components/Org/Settings/LandingpageSettings.svelte index 1442f3b5..fa3fc96c 100644 --- a/apps/dashboard/src/lib/components/Org/Settings/LandingpageSettings.svelte +++ b/apps/dashboard/src/lib/components/Org/Settings/LandingpageSettings.svelte @@ -117,7 +117,7 @@ $: setDefault($currentOrg?.landingpage as OrgLandingPageJson); - + Landing Page diff --git a/apps/dashboard/src/lib/components/Org/Settings/OrgSettings.svelte b/apps/dashboard/src/lib/components/Org/Settings/OrgSettings.svelte index fe77c09e..af5a4eff 100644 --- a/apps/dashboard/src/lib/components/Org/Settings/OrgSettings.svelte +++ b/apps/dashboard/src/lib/components/Org/Settings/OrgSettings.svelte @@ -1,6 +1,7 @@ - + Organization Profile @@ -175,7 +177,7 @@

gotoSetting('/domains')} /> @@ -189,11 +191,15 @@ Add team mates to your organization so you can both collaborate on projects.

gotoSetting('/teams')} - /> + > + {#if $isFreePlan} + + {/if} + Manage Team +
diff --git a/apps/dashboard/src/lib/components/Org/Settings/Profile.svelte b/apps/dashboard/src/lib/components/Org/Settings/Profile.svelte index 2f70ecbc..e75c3cff 100644 --- a/apps/dashboard/src/lib/components/Org/Settings/Profile.svelte +++ b/apps/dashboard/src/lib/components/Org/Settings/Profile.svelte @@ -3,6 +3,7 @@ import TextField from '$lib/components/Form/TextField.svelte'; import SectionTitle from '../SectionTitle.svelte'; import PrimaryButton from '$lib/components/PrimaryButton/index.svelte'; + import { VARIANTS } from '$lib/components/PrimaryButton/constants'; import UploadImage from '$lib/components/UploadImage/index.svelte'; import { supabase } from '$lib/utils/functions/supabase'; import { profile } from '$lib/utils/store/user'; @@ -61,7 +62,7 @@ } - + Profile Picture @@ -83,6 +84,7 @@ - + Add @@ -146,10 +147,11 @@ placeholder="email comma separated" bind:value={emailsStr} className="mb-3" + isDisabled={$isFreePlan} {errorMessage} /> - @@ -158,7 +160,7 @@ label="Send Invite" onClick={onSendInvite} {isLoading} - isDisabled={isLoading} + isDisabled={isLoading || $isFreePlan} />
diff --git a/apps/dashboard/src/lib/components/Org/Settings/index.svelte b/apps/dashboard/src/lib/components/Org/Settings/index.svelte index d10620fd..7c9001c3 100644 --- a/apps/dashboard/src/lib/components/Org/Settings/index.svelte +++ b/apps/dashboard/src/lib/components/Org/Settings/index.svelte @@ -5,6 +5,7 @@ import LandingpageSettings from './LandingpageSettings.svelte'; // import Account from './Account.svelte'; import OrgSettings from './OrgSettings.svelte'; + import Billing from './Billing.svelte'; import { onMount } from 'svelte'; import { browser } from '$app/environment'; import { goto } from '$app/navigation'; @@ -64,6 +65,13 @@ }, { key: 3, + label: 'Billing', + tabKey: 'billing', + href: `${$page.url.pathname}?tab=billing`, + disabled: !$isOrgAdmin + }, + { + key: 4, label: 'Integrations', tabKey: 'integrations', href: `${$page.url.pathname}?tab=integrations`, @@ -91,6 +99,9 @@ + + + diff --git a/apps/dashboard/src/lib/components/Org/SideBar.svelte b/apps/dashboard/src/lib/components/Org/SideBar.svelte index 9c487e33..bcfa6b62 100644 --- a/apps/dashboard/src/lib/components/Org/SideBar.svelte +++ b/apps/dashboard/src/lib/components/Org/SideBar.svelte @@ -2,8 +2,8 @@ import { page } from '$app/stores'; import HelpIcon from 'carbon-icons-svelte/lib/Help.svelte'; import ForumIcon from 'carbon-icons-svelte/lib/Forum.svelte'; - - import TextChip from '$lib/components/Chip/Text.svelte'; + import { SettingsAdjust } from 'carbon-icons-svelte'; + import PrimaryButton from '$lib/components/PrimaryButton/index.svelte'; import OrgSelector from '$lib/components/OrgSelector/OrgSelector.svelte'; import HomeIcon from '$lib/components/Icons/HomeIcon.svelte'; import CourseIcon from '$lib/components/Icons/CourseIcon.svelte'; @@ -11,37 +11,18 @@ import SiteSettingsIcon from '$lib/components/Icons/SiteSettingsIcon.svelte'; import AudienceIcon from '$lib/components/Icons/AudienceIcon.svelte'; import Avatar from '$lib/components/Avatar/index.svelte'; - import { currentOrg, currentOrgPath } from '$lib/utils/store/org'; + import { currentOrgPath, currentOrgPlan, isFreePlan } from '$lib/utils/store/org'; + import { isOrgAdmin } from '$lib/utils/store/org'; import { profile } from '$lib/utils/store/user'; import { NavClasses } from '$lib/utils/constants/reusableClass'; import { sideBar } from './store'; + import { goto } from '$app/navigation'; - const menuItems = [ - { - path: '', - label: 'Dashboard' - }, - // { - // path: '/quiz', - // label: 'Quizzes' - // }, - { - path: '/courses', - label: 'Courses' - }, - { - path: '/community', - label: 'Community' - }, - // { - // path: '/site', - // label: 'Site settings', - // }, - { - path: '/audience', - label: 'Audience' - } - ]; + let menuItems: { + path: string; + label: string; + show: boolean; + }[] = []; function isActive(pagePath: string, itemPath: string) { const pageLinkItems = pagePath.split('/'); @@ -56,87 +37,137 @@ const toggleSidebar = () => { $sideBar.hidden = !$sideBar.hidden; }; + + const openModal = () => { + goto(window.location.pathname + '?upgrade=true'); + }; + + $: { + menuItems = [ + { + path: '', + label: 'Dashboard', + show: true + }, + // { + // path: '/quiz', + // label: 'Quizzes' + // }, + { + path: '/courses', + label: 'Courses', + show: true + }, + { + path: '/community', + label: 'Community', + show: true + }, + // { + // path: '/site', + // label: 'Site settings', + // }, + { + path: '/audience', + label: 'Audience', + show: true + }, + { + path: '/setup', + label: 'Setup', + show: $isOrgAdmin + } + ]; + }