feat: add avatar and nickname display in user info scope

This commit is contained in:
moonrailgun 2024-08-03 03:41:41 +08:00
parent 20e95ef973
commit 03bc9b5125
2 changed files with 11 additions and 7 deletions

View File

@ -1,4 +1,4 @@
import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { Button } from '@/components/ui/button';
import {
DropdownMenu,
@ -53,17 +53,18 @@ export const UserConfig: React.FC<UserConfigProps> = React.memo((props) => {
});
});
const nickname = userInfo?.nickname ?? userInfo?.username ?? '';
const avatar = (
<Avatar size={props.isCollapsed ? 'sm' : 'default'}>
<AvatarFallback>
{(userInfo?.username ?? '').substring(0, 2).toUpperCase()}
</AvatarFallback>
<AvatarImage src={userInfo?.avatar ?? undefined} />
<AvatarFallback>{nickname.substring(0, 2).toUpperCase()}</AvatarFallback>
</Avatar>
);
const name = (
<div className="flex-1 overflow-hidden text-ellipsis">
{userInfo?.username ?? ''}
<div className="flex-1 overflow-hidden text-ellipsis" title={nickname}>
{nickname}
</div>
);

View File

@ -22,9 +22,12 @@ export const workspaceSchema = z.object({
});
export const userInfoSchema = z.object({
username: z.string(),
id: z.string(),
role: z.string(),
username: z.string(),
nickname: z.string().nullable(),
avatar: z.string().nullable(),
email: z.string().nullable(),
createdAt: z.date(),
updatedAt: z.date(),
deletedAt: z.date().nullable(),