* wip: improve user preferences * wip: fix translations and add user danger zone * feat: add user delete button to danger zone * fix: test not working * refactor: add access checks for user edit page, improve not found behaviour, change user preference link in avatar menu to correct link * fix: remove invalid bg for container * chore: address pull request feedback
29 lines
671 B
TypeScript
29 lines
671 B
TypeScript
import type { AvatarProps } from "@mantine/core";
|
|
import { Avatar } from "@mantine/core";
|
|
|
|
export interface UserProps {
|
|
name: string | null;
|
|
image: string | null;
|
|
}
|
|
|
|
interface UserAvatarProps {
|
|
user: UserProps | null;
|
|
size: AvatarProps["size"];
|
|
}
|
|
|
|
export const UserAvatar = ({ user, size }: UserAvatarProps) => {
|
|
const commonProps = {
|
|
size,
|
|
color: "primaryColor",
|
|
} satisfies Partial<AvatarProps>;
|
|
|
|
if (!user?.name) return <Avatar {...commonProps} />;
|
|
if (user.image) {
|
|
return <Avatar {...commonProps} src={user.image} alt={user.name} />;
|
|
}
|
|
|
|
return (
|
|
<Avatar {...commonProps}>{user.name.substring(0, 2).toUpperCase()}</Avatar>
|
|
);
|
|
};
|