Add new org improvements
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
export function genQuizPin() {
|
||||
var minm = 100000;
|
||||
var maxm = 999999;
|
||||
return Math.floor(Math.random() * (maxm - minm + 1)) + minm;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
export function genQuizPin(): number {
|
||||
var minm = 100000;
|
||||
var maxm = 999999;
|
||||
return Math.floor(Math.random() * (maxm - minm + 1)) + minm;
|
||||
}
|
||||
|
||||
export function generateSitename(orgName: string): string {
|
||||
return orgName
|
||||
.toLowerCase()
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/[^a-zA-Z0-9-]/g, '');
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import get from 'lodash/get';
|
||||
import isNumber from 'lodash/isNumber';
|
||||
import z from 'zod';
|
||||
import { validateEmail } from './validateEmail';
|
||||
@@ -161,6 +160,22 @@ export const onboardingValidation = (fields = {}, step) => {
|
||||
return processErrors(error);
|
||||
};
|
||||
|
||||
export const createOrgValidation = (fields = {}) => {
|
||||
const schema = z.object({
|
||||
orgName: z.string().min(5, {
|
||||
message: 'Must be 5 or more characters long',
|
||||
invalid_type_error: 'Must not be empty'
|
||||
}),
|
||||
siteName: z.string().min(5, {
|
||||
message: 'Must be 5 or more characters long',
|
||||
invalid_type_error: 'Must not be empty'
|
||||
})
|
||||
});
|
||||
const { error } = schema.safeParse(fields);
|
||||
|
||||
return processErrors(error);
|
||||
};
|
||||
|
||||
export const createQuizValidation = (fields = {}) => {
|
||||
const { error } = createQuizValidationSchema.safeParse(fields);
|
||||
|
||||
|
||||
@@ -72,21 +72,6 @@ export async function fetchGroup(groupId: Group['id']) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function setProfileIdOfGroupMember(email: string, profileId: string) {
|
||||
const { data, error } = await supabase
|
||||
.from('groupmember')
|
||||
.update({
|
||||
email: null,
|
||||
profile_id: profileId
|
||||
})
|
||||
.match({ email: email });
|
||||
|
||||
return {
|
||||
data,
|
||||
error
|
||||
};
|
||||
}
|
||||
|
||||
export async function uploadAvatar(courseId: string, avatar: string) {
|
||||
const filename = `course/${courseId + Date.now()}.webp`;
|
||||
let logo;
|
||||
|
||||
@@ -57,17 +57,20 @@ export async function getOrganizations(userId) {
|
||||
id,
|
||||
profile_id,
|
||||
role_id,
|
||||
created_at,
|
||||
organization!organizationmember_organization_id_fkey (
|
||||
id,
|
||||
name,
|
||||
siteName,
|
||||
avatar_url,
|
||||
landingpage,
|
||||
theme
|
||||
theme,
|
||||
created_at
|
||||
)
|
||||
`
|
||||
)
|
||||
.eq('profile_id', userId);
|
||||
.eq('profile_id', userId)
|
||||
.order('id', { ascending: false });
|
||||
|
||||
const orgsArray = [];
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { STEPS } from '../constants/quiz';
|
||||
import type { Writable } from 'svelte/store';
|
||||
import type { CurrentOrg, OrgTeamMember } from '../types/org';
|
||||
|
||||
export const orgs = writable([]);
|
||||
export const orgs = writable<CurrentOrg[]>([]);
|
||||
export const currentOrg: Writable<CurrentOrg> = writable({
|
||||
id: '',
|
||||
name: '',
|
||||
|
||||
Reference in New Issue
Block a user