feat: add user groups (#376)
* feat: add user groups * wip: add unit tests * wip: add more tests and normalized name for creation and update * test: add unit tests for group router * fix: type issues, missing mysql schema, rename column creator_id to owner_id * fix: lint and format issues * fix: deepsource issues * fix: forgot to add log message * fix: build not working * chore: address pull request feedback * feat: add mysql migration and fix merge conflicts * fix: format issue and test issue
This commit is contained in:
28
packages/ui/src/components/user-avatar.tsx
Normal file
28
packages/ui/src/components/user-avatar.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Avatar } from "@mantine/core";
|
||||
import type { AvatarProps, MantineSize } from "@mantine/core";
|
||||
|
||||
export interface UserProps {
|
||||
name: string | null;
|
||||
image: string | null;
|
||||
}
|
||||
|
||||
interface UserAvatarProps {
|
||||
user: UserProps | null;
|
||||
size: MantineSize;
|
||||
}
|
||||
|
||||
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>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user