This commit updates the naming convention of icons from Lucide-React, moving some package dependencies to "peerDependencies" in 'team-accounts', 'admin' and 'auth'. Additionally, it includes tweaks to the development server command in apps/web package.json and adds a logger reference to the shared package. Furthermore, cleanup work has been performed within the features and UI packages, and new scripts to interact with Stripe have been added to the root package.json.
51 lines
943 B
TypeScript
51 lines
943 B
TypeScript
import { cache } from 'react';
|
|
|
|
import { getSupabaseServerComponentClient } from '@kit/supabase/server-component-client';
|
|
|
|
export const loadUserWorkspace = cache(async () => {
|
|
const [accounts, session] = await Promise.all([
|
|
loadUserAccounts(),
|
|
loadSession(),
|
|
]);
|
|
|
|
return {
|
|
accounts,
|
|
session,
|
|
};
|
|
});
|
|
|
|
async function loadSession() {
|
|
const client = getSupabaseServerComponentClient();
|
|
|
|
const {
|
|
data: { session },
|
|
error,
|
|
} = await client.auth.getSession();
|
|
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
|
|
return session;
|
|
}
|
|
|
|
async function loadUserAccounts() {
|
|
const client = getSupabaseServerComponentClient();
|
|
|
|
const { data: accounts, error } = await client
|
|
.from('user_accounts')
|
|
.select(`name, slug, picture_url`);
|
|
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
|
|
return accounts.map(({ name, slug, picture_url }) => {
|
|
return {
|
|
label: name,
|
|
value: slug,
|
|
image: picture_url,
|
|
};
|
|
});
|
|
}
|