B2B-31: refactor profile menu, header
This commit is contained in:
@@ -112,10 +112,10 @@ export function AccountSelector({
|
||||
role="combobox"
|
||||
aria-expanded={open}
|
||||
className={cn(
|
||||
'dark:shadow-primary/10 group w-full min-w-0 px-2 lg:w-auto lg:max-w-fit',
|
||||
'dark:shadow-primary/10 group w-full min-w-0 px-4 py-2 h-10 border-1 lg:w-auto lg:max-w-fit',
|
||||
{
|
||||
'justify-start': !collapsed,
|
||||
'm-auto justify-center px-2 lg:w-full': collapsed,
|
||||
'm-auto justify-center px-4 lg:w-full': collapsed,
|
||||
},
|
||||
className,
|
||||
)}
|
||||
@@ -124,7 +124,7 @@ export function AccountSelector({
|
||||
condition={selected}
|
||||
fallback={
|
||||
<span
|
||||
className={cn('flex max-w-full items-center', {
|
||||
className={cn('flex max-w-full items-center w-4 h-4', {
|
||||
'justify-center gap-x-0': collapsed,
|
||||
'gap-x-4': !collapsed,
|
||||
})}
|
||||
@@ -148,7 +148,7 @@ export function AccountSelector({
|
||||
'gap-x-4': !collapsed,
|
||||
})}
|
||||
>
|
||||
<Avatar className={'rounded-xs h-6 w-6'}>
|
||||
<Avatar className={'rounded-md h-6 w-6'}>
|
||||
<AvatarImage src={account.image ?? undefined} />
|
||||
|
||||
<AvatarFallback
|
||||
@@ -297,7 +297,7 @@ export function AccountSelector({
|
||||
|
||||
function UserAvatar(props: { pictureUrl?: string }) {
|
||||
return (
|
||||
<Avatar className={'rounded-xs h-6 w-6'}>
|
||||
<Avatar className={'rounded-md h-6 w-6'}>
|
||||
<AvatarImage src={props.pictureUrl} />
|
||||
</Avatar>
|
||||
);
|
||||
|
||||
@@ -28,6 +28,9 @@ import { Trans } from '@kit/ui/trans';
|
||||
import { cn } from '@kit/ui/utils';
|
||||
|
||||
import { usePersonalAccountData } from '../hooks/use-personal-account-data';
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@kit/ui/avatar';
|
||||
|
||||
const PERSONAL_ACCOUNT_SLUG = 'personal';
|
||||
|
||||
export function PersonalAccountDropdown({
|
||||
className,
|
||||
@@ -37,6 +40,7 @@ export function PersonalAccountDropdown({
|
||||
paths,
|
||||
features,
|
||||
account,
|
||||
accounts
|
||||
}: {
|
||||
user: User;
|
||||
|
||||
@@ -45,7 +49,11 @@ export function PersonalAccountDropdown({
|
||||
name: string | null;
|
||||
picture_url: string | null;
|
||||
};
|
||||
|
||||
accounts: {
|
||||
label: string | null;
|
||||
value: string | null;
|
||||
image?: string | null;
|
||||
}[];
|
||||
signOutRequested: () => unknown;
|
||||
|
||||
paths: {
|
||||
@@ -95,7 +103,7 @@ export function PersonalAccountDropdown({
|
||||
className ?? '',
|
||||
{
|
||||
['active:bg-secondary/50 items-center gap-4 rounded-md' +
|
||||
' hover:bg-secondary p-2 transition-colors']: showProfileName,
|
||||
' hover:bg-secondary p-0 m-0 transition-colors border-1 rounded-md px-4 py-1 h-10']: showProfileName,
|
||||
},
|
||||
)}
|
||||
>
|
||||
@@ -119,12 +127,6 @@ export function PersonalAccountDropdown({
|
||||
{displayName}
|
||||
</span>
|
||||
|
||||
<span
|
||||
data-test={'account-dropdown-email'}
|
||||
className={'text-muted-foreground truncate text-xs'}
|
||||
>
|
||||
{signedInAsLabel}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<ChevronsUpDown
|
||||
@@ -167,6 +169,46 @@ export function PersonalAccountDropdown({
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<If condition={(accounts ?? []).length > 0}>
|
||||
<span className='px-2 text-muted-foreground text-xs'>
|
||||
<Trans
|
||||
i18nKey={'teams:yourTeams'}
|
||||
values={{ teamsCount: (accounts ?? []).length }}
|
||||
/>
|
||||
</span>
|
||||
|
||||
{(accounts ?? []).map((account) => (
|
||||
<DropdownMenuItem key={account.value} asChild>
|
||||
<Link
|
||||
className={'s-full flex cursor-pointer items-center space-x-2'}
|
||||
href={`/home/${account.value}`}
|
||||
>
|
||||
<div className={'flex items-center'}>
|
||||
<Avatar className={'rounded-xs h-5 w-5'}>
|
||||
<AvatarImage src={account.image ?? undefined} />
|
||||
|
||||
<AvatarFallback
|
||||
className={cn('rounded-md', {
|
||||
['bg-background']: PERSONAL_ACCOUNT_SLUG === account.value,
|
||||
['group-hover:bg-background']:
|
||||
PERSONAL_ACCOUNT_SLUG !== account.value,
|
||||
})}
|
||||
>
|
||||
{account.label ? account.label[0] : ''}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
|
||||
<span className={'pl-3'}>
|
||||
{account.label}
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</If>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem asChild>
|
||||
<Link
|
||||
className={'s-full flex cursor-pointer items-center space-x-2'}
|
||||
|
||||
@@ -121,8 +121,8 @@ export function NotificationsPopover(params: {
|
||||
return (
|
||||
<Popover modal open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button className={'relative h-9 w-9'} variant={'ghost'}>
|
||||
<Bell className={'min-h-4 min-w-4'} />
|
||||
<Button className={'relative px-4 py-2 h-10 border-1 mr-0'} variant={'ghost'}>
|
||||
<Bell className={'h-4 w-4'} />
|
||||
|
||||
<span
|
||||
className={cn(
|
||||
|
||||
@@ -90,18 +90,31 @@ export class TeamAccountsApi {
|
||||
* @description Get the account workspace data.
|
||||
* @param slug
|
||||
*/
|
||||
async getAccountWorkspace(slug: string) {
|
||||
async getAccountWorkspace(slug: string, userId: string) {
|
||||
const accountPromise = this.client.rpc('team_account_workspace', {
|
||||
account_slug: slug,
|
||||
});
|
||||
|
||||
const accountsPromise = this.client.from('user_accounts').select('*');
|
||||
const accountsPromise = this.client
|
||||
.from('accounts_memberships')
|
||||
.select(`
|
||||
account_id,
|
||||
user_accounts (
|
||||
id,
|
||||
role,
|
||||
name,
|
||||
slug,
|
||||
picture_url
|
||||
)
|
||||
`)
|
||||
.eq('user_id', userId)
|
||||
.eq('account_role', 'owner');
|
||||
|
||||
const [accountResult, accountsResult] = await Promise.all([
|
||||
accountPromise,
|
||||
accountsPromise,
|
||||
]);
|
||||
|
||||
|
||||
if (accountResult.error) {
|
||||
return {
|
||||
error: accountResult.error,
|
||||
|
||||
@@ -87,7 +87,7 @@ function PageWithHeader(props: PageProps) {
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
'bg-muted/40 dark:border-border dark:shadow-primary/10 flex h-14 items-center justify-between px-4 lg:justify-start lg:shadow-xs',
|
||||
'bg-bg-background border-1 light:border-border dark:border-border dark:shadow-primary/10 flex h-15 items-center justify-between px-4 py-1 lg:justify-start lg:shadow-xs',
|
||||
{
|
||||
'sticky top-0 z-10 backdrop-blur-md': props.sticky ?? true,
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@ type ProfileAvatarProps = (SessionProps | TextProps) & {
|
||||
export function ProfileAvatar(props: ProfileAvatarProps) {
|
||||
const avatarClassName = cn(
|
||||
props.className,
|
||||
'mx-auto h-9 w-9 group-focus:ring-2',
|
||||
'mx-auto h-6 w-6 group-focus:ring-2',
|
||||
);
|
||||
|
||||
if ('text' in props) {
|
||||
|
||||
Reference in New Issue
Block a user