aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/packages/ui/src/components/user-avatar.tsx
blob: bbdb84ccfe9656f42586de1e8b6e6bb5b48f33c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { useAuthStore } from "@/models/auth";
import { Avatar, AvatarBadge, AvatarFallback, AvatarImage } from "./ui/avatar";

export function UserAvatar({
  className,
  ...props
}: React.ComponentProps<typeof Avatar>) {
  const authStore = useAuthStore();

  if (!authStore.account) {
    return null;
  }

  return (
    <Avatar {...props}>
      <AvatarImage
        src={`https://minotar.net/helm/${authStore.account.username}/100.png`}
      />
      <AvatarFallback>{authStore.account.username.slice(0, 2)}</AvatarFallback>
      <AvatarBadge />
    </Avatar>
  );
}