@@ -105,7 +194,7 @@
class="rounded h-10 w-10 inline-block mx-auto"
data-atf="1"
/>
-
{$currentOrg.name}
+ {$currentOrg.name}
@@ -113,35 +202,17 @@
-
+
-
+
-
+
diff --git a/src/lib/components/PrimaryButton/constants.js b/src/lib/components/PrimaryButton/constants.js
index a814b995..dfe4751d 100644
--- a/src/lib/components/PrimaryButton/constants.js
+++ b/src/lib/components/PrimaryButton/constants.js
@@ -1,5 +1,6 @@
export const VARIANTS = {
CONTAINED: 'CONTAINED',
+ CONTAINED_LIGHT: 'CONTAINED_LIGHT',
CONTAINED_INFO: 'CONTAINED_INFO',
CONTAINED_WHITE: 'CONTAINED_WHITE',
CONTAINED_DANGER: 'CONTAINED_DANGER',
@@ -12,6 +13,7 @@ export const VARIANTS = {
export const VARIANTS_CLASS = {
[VARIANTS.CONTAINED]: 'border-none bg-blue-700 hover:bg-blue-900 text-white font-bold',
+ [VARIANTS.CONTAINED_LIGHT]: 'border-none bg-blue-600 hover:bg-blue-900 text-white font-bold',
[VARIANTS.CONTAINED_WHITE]:
'border-none hover:border-black-300 hover:bg-blue-700 dark:hover:bg-blue-900 text-black hover:text-white bg-white',
[VARIANTS.CONTAINED_INFO]: 'border-none bg-gray-400 hover:bg-gray-600 text-white',
diff --git a/src/lib/utils/constants/routes.ts b/src/lib/utils/constants/routes.ts
index 7f5bcb84..b24155af 100644
--- a/src/lib/utils/constants/routes.ts
+++ b/src/lib/utils/constants/routes.ts
@@ -3,6 +3,7 @@ export const ROUTE = {
DASHBOARD: '/dashboard',
ONBOARDING: '/onboarding',
COURSES: '/courses',
+ PAGES: '/pages',
COURSE: '/course',
LOGIN: '/login',
SIGN_UP: '/signup',
@@ -11,7 +12,7 @@ export const ROUTE = {
DISCUSSIONS: '/discussions',
ASK: '/ask',
FORGOT: '/forgot',
- RESET: '/reset',
+ RESET: '/reset'
};
export const PUBLIC_ROUTES = [
@@ -20,7 +21,8 @@ export const PUBLIC_ROUTES = [
ROUTE.SIGN_UP,
ROUTE.FORGOT,
ROUTE.RESET,
- `^${ROUTE.COURSE}/.*`,
+ `^${ROUTE.PAGES}/.*`,
+ `^${ROUTE.COURSE}/.*`
];
export const ROUTES_TO_HIDE_NAV = [
@@ -28,5 +30,5 @@ export const ROUTES_TO_HIDE_NAV = [
ROUTE.SIGN_UP,
ROUTE.FORGOT,
ROUTE.RESET,
- ROUTE.ONBOARDING,
+ ROUTE.ONBOARDING
];
diff --git a/src/lib/utils/services/org/index.js b/src/lib/utils/services/org/index.js
index d4fd6e48..4498cb3d 100644
--- a/src/lib/utils/services/org/index.js
+++ b/src/lib/utils/services/org/index.js
@@ -34,7 +34,7 @@ export async function getOrgTeam(orgId) {
verified: teamMember?.verified,
profileId: teamMember?.profile?.id,
role: ROLE_LABEL[teamMember?.role_id] || '',
- isAdmin: teamMember?.role_id === ROLE.ADMIN,
+ isAdmin: teamMember?.role_id === ROLE.ADMIN
});
});
@@ -43,7 +43,7 @@ export async function getOrgTeam(orgId) {
return {
team,
- error,
+ error
};
}
@@ -70,11 +70,10 @@ export async function getOrganizations(userId) {
orgsArray.push({
id: orgMember?.organization?.id,
name: orgMember?.organization?.name,
- shortName:
- orgMember?.organization?.name?.substring(0, 2)?.toUpperCase() || '',
+ shortName: orgMember?.organization?.name?.substring(0, 2)?.toUpperCase() || '',
siteName: orgMember?.organization?.siteName,
avatar_url: orgMember?.organization?.avatar_url,
- memberId: orgMember?.id,
+ memberId: orgMember?.id
});
});
@@ -85,7 +84,7 @@ export async function getOrganizations(userId) {
return {
orgs: orgsArray,
currentOrg: orgsArray[0],
- error,
+ error
};
}
@@ -116,13 +115,13 @@ export async function getOrgAudience(orgId) {
name: profile.fullname,
email: profile.email,
avatar_url: profile.avatar_url,
- date_joined: new Date(profile.created_at).toDateString(),
+ date_joined: new Date(profile.created_at).toDateString()
}));
orgAudience.set(audience);
return {
audience: audience,
- error,
+ error
};
}
@@ -132,6 +131,7 @@ export async function getCourseBySiteName(siteName) {
.select(
`
*,
+ lessons:lesson(count),
group!inner(
organization!inner(id, name, siteName, avatar_url)
)
@@ -148,7 +148,7 @@ export async function getCourseBySiteName(siteName) {
name: 'ClassroomIO',
shortName: '',
siteName: '',
- avatar_url: '/logo-192.png',
+ avatar_url: '/logo-192.png'
});
currentOrg.set(org);
diff --git a/src/lib/utils/store/app.js b/src/lib/utils/store/app.js
index 6636126b..e2dec2c0 100644
--- a/src/lib/utils/store/app.js
+++ b/src/lib/utils/store/app.js
@@ -2,6 +2,6 @@ import { writable } from 'svelte/store';
export const appStore = writable({
isDark: false,
- isStudentDomain: false,
- siteNameFromDomain: '',
+ isOrgSite: false,
+ orgSiteName: ''
});
diff --git a/src/routes/+layout.js b/src/routes/+layout.js
deleted file mode 100644
index 9c2bb2b0..00000000
--- a/src/routes/+layout.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { redirect } from '@sveltejs/kit';
-
-export const load = ({ url }) => {
- // if (url.hostname === 'classroomio.com') {
- // throw redirect(301, 'https://about.classroomio.com');
- // }
- return {}
-};
diff --git a/src/routes/+layout.server.js b/src/routes/+layout.server.js
new file mode 100644
index 00000000..1580840f
--- /dev/null
+++ b/src/routes/+layout.server.js
@@ -0,0 +1,34 @@
+// import { redirect } from '@sveltejs/kit';
+import { blockedSubdomain } from '$lib/utils/constants/app';
+
+/** @type {import('./$types').LayoutServerLoad} */
+export const load = ({ url, cookies }) => {
+ // if (url.hostname === 'classroomio.com') {
+ // throw redirect(301, 'https://about.classroomio.com');
+ // }
+
+ let response = {
+ orgSiteName: '',
+ isOrgSite: false,
+ skipAuth: false
+ };
+
+ const debugOrgLandingPage = cookies.get('debugOrgLandingPage');
+ const debugPlay = cookies.get('debugPlay');
+ const debugMode = debugOrgLandingPage === 'true';
+ console.log('debugOrgLandingPage', debugOrgLandingPage);
+
+ const matches = url.host.match(/([a-z0-9]+).*classroomio[.]com/);
+ const subdomain = matches?.[1] ?? '';
+
+ if (!blockedSubdomain.includes(subdomain)) {
+ const answer = Array.isArray(matches) ? !!subdomain && subdomain !== 'www' : false;
+
+ response.isOrgSite = debugMode || answer;
+ response.orgSiteName = debugMode ? 'codingdojo' : subdomain;
+ } else if (subdomain === 'play' || debugPlay === 'true') {
+ response.skipAuth = true;
+ }
+
+ return response;
+};
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 61dcc96a..d52ebdfc 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -38,10 +38,11 @@
import '../app.postcss';
+ export let data;
+
let supabase = getSupabase();
let path = $page.url?.pathname?.replace('/', '');
let theme = 'white';
- let skipAuth = false;
const delayedPreloading = derived(navigating, (currentPreloading, set) => {
setTimeout(() => set(currentPreloading), 250);
@@ -114,7 +115,7 @@
// Set user in sentry
Sentry.setUser($profile);
- if ($appStore.isStudentDomain) {
+ if (data.isOrgSite) {
const { data, error } = await supabase
.from('organizationmember')
.insert({
@@ -156,7 +157,7 @@
const orgRes = await getOrganizations($profile.id);
// student redirect
- if ($appStore.isStudentDomain) {
+ if (data.isOrgSite) {
if (params.has('redirect')) {
goto(params.get('redirect') || '');
} else {
@@ -176,23 +177,6 @@
}
}
- function setOrgBasedOnUrl(host) {
- if (browser) {
- const debug = localStorage.getItem('role') === 'student';
- const matches = host.match(/([a-z0-9]+).*classroomio[.]com/);
- const subdomain = matches?.[1] ?? '';
-
- if (!blockedSubdomain.includes(subdomain)) {
- const answer = Array.isArray(matches) ? !!subdomain && subdomain !== 'www' : false;
-
- $appStore.isStudentDomain = debug || answer;
- $appStore.siteNameFromDomain = debug ? 'codingdojo' : subdomain;
- } else if (subdomain === 'play' || debug) {
- skipAuth = true;
- }
- }
- }
-
function handleResize() {
isMobile.update(() => window.innerWidth <= 760);
}
@@ -201,7 +185,7 @@
console.log(
'Welcome to ClassroomIO, we are grateful you chose us.',
$page.url.host,
- `\nIs student domain: ${$appStore.isStudentDomain}`
+ `\nIs student domain: ${data.isOrgSite}`
);
// Disable GA on localhost
if (dev) {
@@ -234,7 +218,7 @@
}
// Skip Authentication
- if (skipAuth) return;
+ if (data.skipAuth) return;
// Authentication Steps
if (event === 'SIGNED_IN') {
@@ -252,8 +236,10 @@
toggleBodyByTheme($appStore.isDark);
}
- if ($appStore.isStudentDomain) {
- getCurrentOrg($appStore.siteNameFromDomain);
+ if (data.isOrgSite) {
+ $appStore.orgSiteName = data.orgSiteName;
+ $appStore.isOrgSite = data.isOrgSite;
+ getCurrentOrg(data.orgSiteName);
}
return () => {
@@ -264,7 +250,6 @@
$: path = $page.url?.pathname?.replace('/', '');
$: theme = $appStore.isDark ? 'g100' : 'white';
- $: setOrgBasedOnUrl($page.url.host);
@@ -277,10 +262,10 @@
-{#if skipAuth}
+{#if data.skipAuth}
-{:else if $appStore.isStudentDomain && !path}
-
+{:else if data.isOrgSite && !path}
+
{:else}
{#if $navigating && $delayedPreloading}
@@ -295,8 +280,9 @@
{:else}
{/if}
diff --git a/static/images/org-header-banner.jpg b/static/images/org-header-banner.jpg
new file mode 100644
index 00000000..4f953b37
Binary files /dev/null and b/static/images/org-header-banner.jpg differ