diff --git a/src/components/UserAvatar/UserAvatar.js b/src/components/UserAvatar/UserAvatar.js index 92407aa..7dd0648 100644 --- a/src/components/UserAvatar/UserAvatar.js +++ b/src/components/UserAvatar/UserAvatar.js @@ -3,8 +3,19 @@ import PropTypes from "prop-types"; import { Avatar } from "@material-ui/core"; export default function UserAvatar({ name, alias, ...avatarProps }) { + const [userImage, setUserImage] = useState([]); + + useEffect(() => { + const getImage = async () => { + const response = await fetch(`https://engineering.purdue.edu/ECN/PersonPhotos/getPhoto?json=1&alias=${alias}`); + const jsonResponse = await response.json(); + setUserImage(jsonResponse); + }; + getImage(); + }, [alias]) + return ( - + {name === "" ? null : name.charAt(0)} ); @@ -12,9 +23,12 @@ export default function UserAvatar({ name, alias, ...avatarProps }) { UserAvatar.propTypes = { /** The name of the user. */ - "name": PropTypes.string + "name": PropTypes.string, + /** The user's career account alias. */ + "alias": PropTypes.string }; UserAvatar.defaultProps = { - "name": "" + "name": "", + "alias": "", }; \ No newline at end of file