Get org errors
This commit is contained in:
@@ -151,10 +151,13 @@
|
||||
if (typeof window !== 'undefined') {
|
||||
const debug = localStorage.getItem('role') === 'student';
|
||||
const matches = host.match(/([a-z0-9]+).*classroomio[.]com/);
|
||||
const answer = Array.isArray(matches) ? !!matches[1] : false;
|
||||
const subdomain = matches?.[1] ?? '';
|
||||
const answer = Array.isArray(matches)
|
||||
? !!subdomain && subdomain !== 'www'
|
||||
: false;
|
||||
|
||||
$appStore.isStudentDomain = debug || answer;
|
||||
$appStore.siteNameFromDomain = debug ? 'codingdojo' : matches?.[1] ?? '';
|
||||
$appStore.siteNameFromDomain = debug ? 'codingdojo' : subdomain;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import get from 'lodash/get';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import { goto } from '@sapper/app';
|
||||
import { supabase } from '../../functions/supabase';
|
||||
import { orgs, currentOrg, orgAudience, orgTeam } from '../../store/org';
|
||||
@@ -157,11 +158,17 @@ export async function getCourseBySiteName(siteName) {
|
||||
export async function getCurrentOrg(siteName) {
|
||||
const { data, error } = await supabase
|
||||
.from('organization')
|
||||
.select(`*`)
|
||||
.eq('siteName', siteName)
|
||||
.single();
|
||||
.select(
|
||||
`
|
||||
id,
|
||||
name,
|
||||
siteName,
|
||||
avatar_url
|
||||
`
|
||||
)
|
||||
.eq('siteName', siteName);
|
||||
|
||||
if (error || !data) {
|
||||
if (error || isEmpty(data)) {
|
||||
console.error('Error getOrganization', error);
|
||||
return goto('/404');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user