Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global nav #536

Merged
merged 3 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions app/src/components/common/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ import {useAuth} from '../../app/hooks/useAuth';
import {useSignOutMutation} from '../../services/auth';
import {useAppDispatch} from '../../app/hooks/store';
import {setCredentials} from '../../app/authSlice';
import {useNavigate} from 'react-router-dom';
import {Link, useNavigate} from 'react-router-dom';

const userName = 'Hank Hill';

function getInitials(name: string) {
const splitName = name.split(' ');

if (splitName.length === 1) return splitName[0][0];

return splitName[0][0] + splitName[splitName.length - 1][0];
}

interface Props {
/**
Expand Down Expand Up @@ -104,23 +114,12 @@ export const Header = (props: Props) => {
</IconButton>
<Stack direction="row" gap={1} sx={{alignItems: 'center'}}>
<img
style={{width: '42px', height: '42px'}}
style={{width: '40px', height: '40px'}}
src={logo}
alt="Home Unite Us logo"
/>
<Typography
variant="h6"
color="primary"
component="div"
sx={{flexGrow: 1, display: {xs: 'none', sm: 'block'}}}
>
Home Unite Us
</Typography>
</Stack>
<Stack direction="row" gap={1} sx={{alignItems: 'center'}}>
<Button href="/" color="primary">
Home
</Button>
{!user ? (
<Box sx={{display: {xs: 'none', sm: 'flex'}}}>
{navItems.map(({title, href}) => {
Expand All @@ -142,7 +141,8 @@ export const Header = (props: Props) => {
<Box sx={{flexGrow: 0}}>
<Tooltip title="Open settings">
<IconButton onClick={handleOpenUserMenu} sx={{p: 0}}>
<Avatar alt={user.email} src="" />
{/* Replace with real user name */}
<Avatar alt={userName}>{getInitials(userName)}</Avatar>
</IconButton>
</Tooltip>
<Menu
Expand All @@ -161,11 +161,15 @@ export const Header = (props: Props) => {
open={Boolean(anchorElUser)}
onClose={handleCloseUserMenu}
>
<MenuItem onClick={handleCloseUserMenu}>
<Typography textAlign="center">{user.email}</Typography>
<MenuItem component={Link} to="/settings">
<Typography textAlign="center">Settings</Typography>
</MenuItem>
<MenuItem onClick={handleCloseUserMenu}>
<Typography textAlign="center">Account</Typography>
<MenuItem
component="a"
target="_blank"
href="https://github.com/hackforla/HomeUniteUs/wiki/Home-Unite-Us-User-Guide"
>
<Typography textAlign="center">Help</Typography>
</MenuItem>
<MenuItem onClick={handleSignOut}>
<Typography textAlign="center">Logout</Typography>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
EmailVerificationError,
ForgotPasswordCode,
ForgotPasswordSuccess,
Settings,
} from './views';
import {AccountVerification} from './views/AccountVerification';
import {AppLayout, Header} from './components/common';
Expand All @@ -59,6 +60,7 @@ function HuuApp() {
<Route path="/" element={<Home />} />
<Route path="/coord" element={<CoordinatorDashboard />} />
<Route path="/hosts" element={<HostsList />} />
<Route path="/settings" element={<Settings />} />
<Route
path="/profile"
element={
Expand Down
9 changes: 9 additions & 0 deletions app/src/views/Settings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {Container, Typography} from '@mui/material';

export const Settings = () => {
return (
<Container>
<Typography variant="h3">Settings</Typography>
</Container>
);
};
1 change: 1 addition & 0 deletions app/src/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export {EmailVerificationSuccess} from './EmailVerificationSuccess';
export {EmailVerificationError} from './EmailVerificationError';
export {ForgotPasswordCode} from './ForgotPasswordCode';
export {ForgotPasswordSuccess} from './ForgotPasswordSuccess';
export {Settings} from './Settings';