* Update Next.js and React versions in all packages * Replace onRedirect function with next/link in BillingSessionStatus, since it's no longer cached by default * Remove unused revalidatePath import in billing return page, since it's no longer cached by default * Add Turbopack module aliases to improve development server speed * Converted new Dynamic APIs to be Promise-based * Adjust mobile layout * Use ENABLE_REACT_COMPILER to enable the React Compiler in Next.js 15 * Report Errors using the new onRequestError hook
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import { cn } from '../lib/utils';
|
|
import { Avatar, AvatarFallback, AvatarImage } from '../shadcn/avatar';
|
|
|
|
type SessionProps = {
|
|
displayName: string | null;
|
|
pictureUrl?: string | null;
|
|
};
|
|
|
|
type TextProps = {
|
|
text: string;
|
|
};
|
|
|
|
type ProfileAvatarProps = (SessionProps | TextProps) & {
|
|
className?: string;
|
|
};
|
|
|
|
export function ProfileAvatar(props: ProfileAvatarProps) {
|
|
const avatarClassName = cn(
|
|
props.className,
|
|
'mx-auto h-9 w-9 group-focus:ring-2',
|
|
);
|
|
|
|
if ('text' in props) {
|
|
return (
|
|
<Avatar className={avatarClassName}>
|
|
<AvatarFallback>
|
|
<span className={'uppercase'}>{props.text.slice(0, 1)}</span>
|
|
</AvatarFallback>
|
|
</Avatar>
|
|
);
|
|
}
|
|
|
|
const initials = props.displayName?.slice(0, 1);
|
|
|
|
return (
|
|
<Avatar className={avatarClassName}>
|
|
<AvatarImage src={props.pictureUrl ?? undefined} />
|
|
|
|
<AvatarFallback className={'animate-in fade-in'}>
|
|
<span suppressHydrationWarning className={'uppercase'}>
|
|
{initials}
|
|
</span>
|
|
</AvatarFallback>
|
|
</Avatar>
|
|
);
|
|
}
|