* chore(deps): update dependency eslint to v9 * chore: migrate eslint to v9 * fix: dependency issues * fix: unit tests not working * chore: disable lint check for Image component that does not work in ci * fix: lint issue --------- Co-authored-by: homarr-renovate[bot] <158783068+homarr-renovate[bot]@users.noreply.github.com> Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
25 lines
783 B
TypeScript
25 lines
783 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)
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
return <Avatar {...commonProps} src={currentSession.user.image} alt={currentSession.user.name!} />;
|
|
|
|
return <Avatar {...commonProps}>{currentSession.user.name?.substring(0, 2).toUpperCase()}</Avatar>;
|
|
};
|