import Avatar, { AvatarProps } from 'antd/es/avatar';
import { UserOutlined } from '@ant-design/icons';
import React from 'react';

interface AppAvatarProps extends AvatarProps {
  src?: string;
  alt?: string;
  icon?: React.ReactNode;
  text?: string;
}

const AppAvatar: React.FC<AppAvatarProps> = ({
  src,
  alt,
  icon = <UserOutlined />,
  text,
  size = 'default',
  shape = 'circle',
  ...props
}) => {
  if (src) {
    return <Avatar src={src} alt={alt} size={size} shape={shape} {...props} />;
  }

  if (text) {
    return <Avatar size={size} shape={shape} {...props}>{text}</Avatar>;
  }

  return <Avatar icon={icon} size={size} shape={shape} {...props} />;
};

export default AppAvatar;