import { Avatar as MuiAvatar } from "@mui/material"; import PropTypes from "prop-types"; import { useSelector } from "react-redux"; import { useEffect, useState } from "react"; /** * @component * @param {Object} props * @param {string} props.src - Path to image for avatar * @param {boolean} props.small - Specifies if avatar should be large * @param {Object} [props.sx] - Additional styles to apply to the button. * @returns {JSX.Element} * @example * // Render a red label * */ const Avatar = ({ src, small, sx }) => { const { user } = useSelector((state) => state.auth); const style = small ? { width: 25, height: 25 } : { width: 64, height: 64 }; const border = small ? 1 : 3; const [image, setImage] = useState(); useEffect(() => { if (user.avatarImage) { setImage(`data:image/png;base64,${user.avatarImage}`); } }, [user?.avatarImage]); return ( {user.firstName?.charAt(0)}{user.lastName?.charAt(0)} ); }; Avatar.propTypes = { src: PropTypes.string, small: PropTypes.bool, sx: PropTypes.object, }; export default Avatar;