B2B-30: adds personal code to account, company admins invites members
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
ChevronsUpDown,
|
||||
Home,
|
||||
LogOut,
|
||||
MessageCircleQuestion,
|
||||
UserCircle,
|
||||
Shield,
|
||||
} from 'lucide-react';
|
||||
|
||||
@@ -170,12 +170,12 @@ export function PersonalAccountDropdown({
|
||||
<DropdownMenuItem asChild>
|
||||
<Link
|
||||
className={'s-full flex cursor-pointer items-center space-x-2'}
|
||||
href={'/docs'}
|
||||
href={'/home/settings'}
|
||||
>
|
||||
<MessageCircleQuestion className={'h-5'} />
|
||||
<UserCircle className={'h-5'} />
|
||||
|
||||
<span>
|
||||
<Trans i18nKey={'common:documentation'} />
|
||||
<Trans i18nKey={'common:routes.profile'} />
|
||||
</span>
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
|
||||
@@ -47,23 +47,61 @@ class AccountsApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name loadUserAccounts
|
||||
* Load the user accounts.
|
||||
*/
|
||||
* @name loadUserAccounts
|
||||
* Load only user-owned accounts (not just memberships).
|
||||
*/
|
||||
async loadUserAccounts() {
|
||||
const authUser = await this.client.auth.getUser();
|
||||
|
||||
const {
|
||||
data,
|
||||
error: userError,
|
||||
} = authUser
|
||||
|
||||
if (userError) {
|
||||
throw userError;
|
||||
}
|
||||
|
||||
const { user } = data;
|
||||
|
||||
const { data: accounts, error } = await this.client
|
||||
.from('user_accounts')
|
||||
.select(`name, slug, picture_url`);
|
||||
.from('accounts_memberships')
|
||||
.select(`
|
||||
account_id,
|
||||
user_accounts (
|
||||
name,
|
||||
slug,
|
||||
picture_url
|
||||
)
|
||||
`)
|
||||
.eq('user_id', user.id)
|
||||
.eq('account_role', 'owner');
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return accounts.map(({ name, slug, picture_url }) => {
|
||||
return accounts.map(({ user_accounts }) => ({
|
||||
label: user_accounts.name,
|
||||
value: user_accounts.slug,
|
||||
image: user_accounts.picture_url,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
async loadTempUserAccounts() {
|
||||
const { data: accounts, error } = await this.client
|
||||
.from('user_accounts')
|
||||
.select(`name, slug`);
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return accounts.map(({ name, slug }) => {
|
||||
return {
|
||||
label: name,
|
||||
value: slug,
|
||||
image: picture_url,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user