diff --git a/src/lib/components/Org/Settings/LandingpageSettings.svelte b/src/lib/components/Org/Settings/LandingpageSettings.svelte new file mode 100644 index 00000000..84d28dae --- /dev/null +++ b/src/lib/components/Org/Settings/LandingpageSettings.svelte @@ -0,0 +1,434 @@ + + + + + + Landing Page + + Hide section + Show section + + + + + + + + + Actions + + + + + No redirect + Redirect + + + Video + + + + Hide Video + Show Video + + + + + + + About + + Hide section + Show section + + + + + + + + onFileSelected(file?.detail?.[0])} + /> + {#if $landingPageSettings.aboutUs.imageUrl} + + {/if} + + + + + + Courses + + Hide section + Show section + + + + + + + + + + + Frequently Asked Questions + + Hide section + Show section + + + + + {#each $landingPageSettings.faq.questions as item (item.id)} + + + + deleteFaq(item.id)}> + + + + {/each} + {#if creatingNewQuestion} + + + + + + + {:else} + + {/if} + + + + + Contact us + + Hide section + Show section + + + + + + + + + + + + + Mailing List + + Hide section + Show section + + + + + + + + + + + + Footer + + Hide section + Show section + + + + + + + + + + + + + diff --git a/src/lib/components/Org/Settings/OrgSettings.svelte b/src/lib/components/Org/Settings/OrgSettings.svelte index 22baa558..df0c4e99 100644 --- a/src/lib/components/Org/Settings/OrgSettings.svelte +++ b/src/lib/components/Org/Settings/OrgSettings.svelte @@ -58,8 +58,8 @@ if (data && data.Key) { const { publicURL } = supabase.storage.from('avatars').getPublicUrl(filename); - updates.avatar_url = publicURL; - $currentOrg.avatar_url = publicURL; + updates.avatar_url = data.publicUrl; + $currentOrg.avatar_url = data.publicUrl; } avatar = undefined; } diff --git a/src/lib/components/Org/Settings/Profile.svelte b/src/lib/components/Org/Settings/Profile.svelte index 15064470..7b3e11c8 100644 --- a/src/lib/components/Org/Settings/Profile.svelte +++ b/src/lib/components/Org/Settings/Profile.svelte @@ -36,12 +36,11 @@ cacheControl: '3600', upsert: false }); + if (data) { + const { data: response } = await supabase.storage.from('avatars').getPublicUrl(filename); - if (data && data.Key) { - const { publicURL } = supabase.storage.from('avatars').getPublicUrl(filename); - - updates.avatar_url = publicURL; - $profile.avatar_url = publicURL; + updates.avatar_url = response.publicUrl; + $profile.avatar_url = response.publicUrl; } avatar = undefined; } diff --git a/src/lib/components/Org/Settings/index.svelte b/src/lib/components/Org/Settings/index.svelte index 379f41f5..190aa8a1 100644 --- a/src/lib/components/Org/Settings/index.svelte +++ b/src/lib/components/Org/Settings/index.svelte @@ -2,6 +2,7 @@ import { page } from '$app/stores'; import { Tabs, Tab, TabContent } from 'carbon-components-svelte'; import Profile from './Profile.svelte'; + import LandingpageSettings from './LandingpageSettings.svelte'; // import Account from './Account.svelte'; import OrgSettings from './OrgSettings.svelte'; import { onMount } from 'svelte'; @@ -21,20 +22,22 @@ }, { key: 1, - label: 'Organization Settings', + label: 'Organization', tabKey: 'org', href: `${$page.url.pathname}?tab=org` + }, + { + key: 2, + label: 'LandingPage', + tabKey: 'landingpage', + href: `${$page.url.pathname}?tab=landingpage` } ]; function getSelectedByTab(tabKey = '') { const tab = tabs.find((t) => t.tabKey === tabKey); - console.log('tab', tab); - if (tab) { - return tab.key; - } - return 0; + return tab ? tab.key : 0; } function changeRouteOnTabChange(key = 0) { const tab = tabs.find((t) => t.key === key); @@ -69,5 +72,8 @@ + + + diff --git a/src/lib/components/Org/Settings/store.ts b/src/lib/components/Org/Settings/store.ts new file mode 100644 index 00000000..0911fbe1 --- /dev/null +++ b/src/lib/components/Org/Settings/store.ts @@ -0,0 +1,139 @@ +import { writable } from 'svelte/store'; +import type { Writable } from 'svelte/store'; + +export interface OrgLandingPageJson { + header: { + title: string; + titleHighlight: string; + subtitle: string; + action: { + label: string; + link: string; + redirect: boolean; + }; + video: { + link: string; + show: boolean; + }; + show: boolean; + }; + aboutUs: { + title: string; + content: string; + imageUrl: string; + show: boolean; + }; + courses: { + title: string; + titleHighlight: string; + subtitle: string; + show: boolean; + }; + faq: { + title: string; + questions: Array<{ + id: number; + title: string; + content: string; + }>; + show: boolean; + }; + contact: { + title: string; + titleHighlight: string; + subtitle: string; + address: string; + phone: string; + email: string; + show: boolean; + }; + mailinglist: { + title: string; + subtitle: string; + buttonLabel: string; + show: boolean; + }; + footer: { + facebook: string; + instagram: string; + linkedin: string; + show: boolean; + }; +} +export let landingPageSettings: Writable = writable({ + header: { + title: 'Web Development Courses for', + titleHighlight: 'Everyone', + subtitle: + 'Practical project-based courses that are easy to understand and straight to the point', + action: { + label: 'Start learning Today', + link: '#contact', + redirect: false + }, + video: { + show: false, + link: 'https://youtube.com/sosf24lsfgs' + }, + show: false + }, + aboutUs: { + title: 'Our Story', + content: + 'Lorem ipsum dolor sit, amet consectetur adipisicing elit. Repudiandae, quaerat cum. Ullam similique quae dicta ipsum atque quam fugit iusto eligendi magni voluptatum aut, exercitationem deserunt vitae iste rem sunt!\nLorem ipsum, dolor sit amet consectetur adipisicing elit. Maiores obcaecati veritatis tenetur in, nihil repellat quasi cumque sed molestias id reiciendis harum doloremque minus fugit quia cum dolores quas pariatur.', + imageUrl: '', + show: true + }, + courses: { + title: 'Explore our', + titleHighlight: 'Courses', + subtitle: 'Find courses you will love from best teachers all over the world🌎.', + show: true + }, + faq: { + title: 'Frequently Asked Questions.', + questions: [ + { + id: 1, + title: 'Lorem ipsum dolor sit, amet con', + content: + 'Lorem ipsum dolor sit, amet consectetur adipisicing elit. Repudiandae, quaerat cum. Ullam similique quae dicta ipsum atque quam fugit iusto eligendi magni voluptatum aut, exercitationem deserunt vitae iste rem sunt!\nLorem ipsum, dolor sit amet consectetur adipisicing elit. Maiores obcaecati veritatis tenetur in, nihil repellat quasi cumque sed molestias id reiciendis harum doloremque minus fugit quia cum dolores quas pariatur.' + }, + { + id: 2, + title: 'Lorem ipsum dolor sit, amet con', + content: + 'Lorem ipsum dolor sit, amet consectetur adipisicing elit. Repudiandae, quaerat cum. Ullam similique quae dicta ipsum atque quam fugit iusto eligendi magni voluptatum aut, exercitationem deserunt vitae iste rem sunt!\nLorem ipsum, dolor sit amet consectetur adipisicing elit. Maiores obcaecati veritatis tenetur in, nihil repellat quasi cumque sed molestias id reiciendis harum doloremque minus fugit quia cum dolores quas pariatur.' + }, + { + id: 3, + title: 'Lorem ipsum dolor sit, amet con', + content: + 'Lorem ipsum dolor sit, amet consectetur adipisicing elit. Repudiandae, quaerat cum. Ullam similique quae dicta ipsum atque quam fugit iusto eligendi magni voluptatum aut, exercitationem deserunt vitae iste rem sunt!\nLorem ipsum, dolor sit amet consectetur adipisicing elit. Maiores obcaecati veritatis tenetur in, nihil repellat quasi cumque sed molestias id reiciendis harum doloremque minus fugit quia cum dolores quas pariatur.' + } + ], + show: true + }, + contact: { + title: 'Have you got any', + titleHighlight: 'Question?', + subtitle: 'Reach out to us with any question you might have.', + address: 'Ashwoodfield House Farm, Kidderminster Rd, Stourbridge, Kingswinford DY6 0AA', + phone: '+4407339904995', + email: 'help@digdippa.com', + show: true + }, + mailinglist: { + title: 'Join our mailing list', + subtitle: + 'We are constantly releasing new courses and sharing them with our email list. Subscribe to get notified once we release a new course', + buttonLabel: 'Subscribe', + show: true + }, + footer: { + facebook: '#', + instagram: '#', + linkedin: '#', + show: true + } +}); diff --git a/src/lib/utils/services/courses/index.ts b/src/lib/utils/services/courses/index.ts index 9277358a..e1de44b3 100644 --- a/src/lib/utils/services/courses/index.ts +++ b/src/lib/utils/services/courses/index.ts @@ -93,12 +93,12 @@ export async function uploadAvatar(courseId: string, avatar: string) { upsert: false }); - if (data && data.Key) { - const { publicURL } = supabase.storage.from('avatars').getPublicUrl(filename); + if (data) { + const { data } = supabase.storage.from('avatars').getPublicUrl(filename); - if (!publicURL) return; + if (!data.publicUrl) return; - logo = publicURL; + logo = data.publicUrl; } return logo; @@ -117,12 +117,12 @@ export async function updateCourse( upsert: false }); - if (data && data.Key) { - const { publicURL } = supabase.storage.from('avatars').getPublicUrl(filename); + if (data) { + const { data: response } = supabase.storage.from('avatars').getPublicUrl(filename); - if (!publicURL) return; + if (!response.publicUrl) return; - course.logo = publicURL; + course.logo = response.publicUrl; } } diff --git a/src/lib/utils/services/org/index.js b/src/lib/utils/services/org/index.js index d31c694d..78f60025 100644 --- a/src/lib/utils/services/org/index.js +++ b/src/lib/utils/services/org/index.js @@ -58,8 +58,9 @@ export async function getOrganizations(userId) { id, name, siteName, - theme, - avatar_url + avatar_url, + landingpage, + theme ) ` ) @@ -75,7 +76,8 @@ export async function getOrganizations(userId) { siteName: orgMember?.organization?.siteName, theme: orgMember?.organization?.theme, avatar_url: orgMember?.organization?.avatar_url, - memberId: orgMember?.id + memberId: orgMember?.id, + landingpage: orgMember?.organization?.landingpage }); }); @@ -150,8 +152,9 @@ export async function getCourseBySiteName(siteName) { name: 'ClassroomIO', shortName: '', siteName: '', - theme: '', - avatar_url: '/logo-192.png' + avatar_url: '/logo-192.png', + landingpage: {}, + theme: '' }); currentOrg.set(org); @@ -166,8 +169,9 @@ export async function getCurrentOrg(siteName, justGet = false) { id, name, siteName, - theme, - avatar_url + avatar_url, + landingpage, + theme ` ) .eq('siteName', siteName); diff --git a/src/lib/utils/store/org.js b/src/lib/utils/store/org.js index 2c20390e..a5d87a21 100644 --- a/src/lib/utils/store/org.js +++ b/src/lib/utils/store/org.js @@ -1,6 +1,5 @@ -import cloneDeep from 'lodash/cloneDeep'; import { writable, derived } from 'svelte/store'; -import { allOptions, STEPS, booleanOptions } from '../constants/quiz'; +import { STEPS } from '../constants/quiz'; export const orgs = writable([]); export const currentOrg = writable({ @@ -9,8 +8,9 @@ export const currentOrg = writable({ shortName: '', siteName: '', avatar_url: '', - theme: '', - memberId: '' + memberId: '', + landingpage: {}, + theme: '' }); export const orgAudience = writable([]); export const orgTeam = writable([]); diff --git a/src/routes/profile/[id]/+page.svelte b/src/routes/profile/[id]/+page.svelte index 3973eb03..0898433e 100644 --- a/src/routes/profile/[id]/+page.svelte +++ b/src/routes/profile/[id]/+page.svelte @@ -58,11 +58,11 @@ upsert: false }); - if (data && data.Key) { - const { publicURL } = supabase.storage.from('avatars').getPublicUrl(filename); + if (data) { + const { data: response } = supabase.storage.from('avatars').getPublicUrl(filename); - updates.avatar_url = publicURL; - currentProfile.avatar_url = publicURL; + updates.avatar_url = response.publicUrl; + currentProfile.avatar_url = response.publicUrl; } avatar = undefined; }