Skip to content

Commit

Permalink
fixed profile picture! put in placeholder for initials
Browse files Browse the repository at this point in the history
  • Loading branch information
ieliu committed Aug 27, 2022
1 parent 5a59e69 commit 52d3b87
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 10 deletions.
46 changes: 37 additions & 9 deletions client/src/components/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,41 @@ import '../stylesheets/NavBar.css';
import { getAnovaToken, removeAnovaToken, removeGoogleToken } from '../utils/utils';
import { NavLink } from 'react-router-dom';
import { GoogleLogout } from 'react-google-login';
import { handleErrors } from '../utils/helpers';
import { Modal, Input, Row, Col, Avatar } from 'antd';
import * as decode from 'jwt-decode';

const logo = require('../stylesheets/logo.png');

const NavBar = props => {

const { match } = props;

const [drawerVisible, setDrawerVisible] = useState(false);
const [selectedKeys, setSelectedKeys] = useState([]);

const [username, setUsername] = useState('');

const clientId =
'128601698558-80ae6kq3v7p8iuknfpkqu6bsfg05vgra.apps.googleusercontent.com';

useEffect(() => {
const tok = localStorage.getItem('anovaToken');
const d_tok = decode(tok);
var { id } = decode(getAnovaToken());
var get_url = '/api/v1/profile/';
var id_str = id.toString();
fetch(get_url + id_str + '?uid=' + d_tok.id)
.then(handleErrors)
.then(profile => {
setUsername(profile[0].name);
})
.catch(() =>
Modal.error({
title: 'Unable to get profile.',
centered: true,
}),
);
if (match.path === '/SiteLessons' || match.path === '/') {
setSelectedKeys('lessons');
} else if (match.path === '/Roster') {
Expand All @@ -38,7 +60,10 @@ const NavBar = props => {
removeAnovaToken();
removeGoogleToken();
};

const getInitials = () => {
const nameArray = username.split(" ");
return (username)? nameArray[0][0] + nameArray[1][0] : "Student"
}
if (getAnovaToken() === null) {
return <div></div>;
} else {
Expand Down Expand Up @@ -69,14 +94,17 @@ const NavBar = props => {
<Menu mode="horizontal" selectedKeys={selectedKeys}>
<Menu.SubMenu
className="menuItem"
title={
<img
src={'https://image.flaticon.com/icons/png/128/1141/1141771.png'}
className="profile-logo"
alt={'Profile'}
/>
}
>
title={
// <img
// src={'https://image.flaticon.com/icons/png/128/1141/1141771.png'}
// className="profile-logo"
// alt={'Profile'}
// />
<div className = "circleNav">
<p className = "circletextNav"> {getInitials()} </p>
</div>
}
>
<Menu.Item className="menuItem" key="profile">
<NavLink to="/Profile">Profile</NavLink>
</Menu.Item>
Expand Down
12 changes: 11 additions & 1 deletion client/src/components/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,23 @@ const Profile = () => {
const showModal = bool => {
setShowEdit(bool);
};

const getInitials = () => {
const nameArray = username.split(" ");
return (username)? nameArray[0][0] + nameArray[1][0] : "Student"
}

return (
<div className="profileContainer">
<div className="profileBox">
<div className="profileBody">
<div className="profileLeft">
<Avatar id="profileImage" src={profileimage} />
{/* <Avatar id="profileImage" src={} /> */}
<div className="circle">
<p className="circletext">
{getInitials()}
</p>
</div>
<p id="username" className="profileName">
{username}
</p>
Expand Down
15 changes: 15 additions & 0 deletions client/src/stylesheets/NavBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,18 @@
padding: 10px 20px;
}
}

.circleNav {
display: flex;
width: 30px;
height: 30px;
background-color: rgb(144, 211, 200);
border-radius: 50%;
}

.circletextNav {
margin: auto;
font-style: normal;
font-size: 15px;
color: white;
}
15 changes: 15 additions & 0 deletions client/src/stylesheets/Profile.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,20 @@
color: #000000;
}

.circle {
display: flex;
width: 100px;
height: 100px;
background-color: rgb(144, 211, 200);
border-radius: 50%;
}

.circletext {
margin: auto;
font-style: normal;
font-size: 30px;
color: white;
}



0 comments on commit 52d3b87

Please sign in to comment.