Files
homarr/apps/nextjs/src/components/user-avatar.tsx
Thomas Camlong f1b1ec59ec chore: update prettier configuration for print width (#519)
* feat: update prettier configuration for print width

* chore: apply code formatting to entire repository

* fix: remove build files

* fix: format issue

---------

Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
2024-05-19 22:38:39 +02:00

24 lines
710 B
TypeScript

import type { AvatarProps, MantineSize } from "@mantine/core";
import { Avatar } from "@mantine/core";
import { auth } from "@homarr/auth/next";
interface UserAvatarProps {
size: MantineSize;
}
export const UserAvatar = async ({ size }: UserAvatarProps) => {
const currentSession = await auth();
const commonProps = {
size,
color: "primaryColor",
} satisfies Partial<AvatarProps>;
if (!currentSession?.user) return <Avatar {...commonProps} />;
if (currentSession.user.image)
return <Avatar {...commonProps} src={currentSession.user.image} alt={currentSession.user.name!} />;
return <Avatar {...commonProps}>{currentSession.user.name!.substring(0, 2).toUpperCase()}</Avatar>;
};