INSIGHT-MVP/packages/frontend/src/components/UserAvatar.tsx
Thomas Reitz 6fa86714db feat: add profile picture upload, sidebar hint, and fix 2FA bugs
- Bug fix: include twoFactorEnabled in login response so ProfilePage
  shows correct 2FA status after login (not always "Aktivieren")
- Bug fix: restructure 2FA enable/disable handlers to separate API call
  from state updates, preventing false error messages on success
- New: avatar field in User model (Base64 data-URL in PostgreSQL TEXT)
- New: UserAvatar component with initials fallback
- New: client-side image resize to 200x200px before upload
- New: avatar upload/remove on ProfilePage with preview
- New: avatar display + "Zum Profil" hint in sidebar
- Increase JSON body size limit to 1mb for avatar uploads

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 06:51:27 +01:00

40 lines
852 B
TypeScript

import styles from './UserAvatar.module.css';
interface UserAvatarProps {
firstName: string;
lastName: string;
avatar?: string | null;
size?: number;
className?: string;
}
export function UserAvatar({
firstName,
lastName,
avatar,
size = 36,
className,
}: UserAvatarProps) {
const initials = `${firstName.charAt(0)}${lastName.charAt(0)}`.toUpperCase();
if (avatar) {
return (
<img
src={avatar}
alt={`${firstName} ${lastName}`}
className={`${styles.avatar} ${className ?? ''}`}
style={{ width: size, height: size }}
/>
);
}
return (
<div
className={`${styles.avatar} ${styles.initials} ${className ?? ''}`}
style={{ width: size, height: size, fontSize: size * 0.4 }}
aria-label={`${firstName} ${lastName}`}
>
{initials}
</div>
);
}