2024-06-30 18:55:39 -04:00
|
|
|
import Logo from '@/assets/logo.svg'
|
|
|
|
import {
|
|
|
|
AccountBox,
|
2024-12-28 18:52:06 -05:00
|
|
|
History,
|
2024-06-30 18:55:39 -04:00
|
|
|
HomeOutlined,
|
2024-11-23 20:23:59 -05:00
|
|
|
ListAlt,
|
2024-06-30 18:55:39 -04:00
|
|
|
Logout,
|
|
|
|
MenuRounded,
|
|
|
|
Message,
|
|
|
|
SettingsOutlined,
|
|
|
|
ShareOutlined,
|
2024-12-31 02:20:52 -05:00
|
|
|
Toll,
|
2024-06-30 18:55:39 -04:00
|
|
|
Widgets,
|
|
|
|
} from '@mui/icons-material'
|
|
|
|
import {
|
|
|
|
Box,
|
|
|
|
Drawer,
|
|
|
|
IconButton,
|
|
|
|
List,
|
|
|
|
ListItemButton,
|
|
|
|
ListItemContent,
|
|
|
|
ListItemDecorator,
|
|
|
|
Typography,
|
|
|
|
} from '@mui/joy'
|
|
|
|
import { useState } from 'react'
|
2024-07-13 01:54:23 -04:00
|
|
|
import { useLocation, useNavigate } from 'react-router-dom'
|
2024-06-30 18:55:39 -04:00
|
|
|
import { version } from '../../../package.json'
|
2024-12-28 18:52:06 -05:00
|
|
|
import ThemeToggleButton from '../Settings/ThemeToggleButton'
|
2024-06-30 18:55:39 -04:00
|
|
|
import NavBarLink from './NavBarLink'
|
|
|
|
const links = [
|
|
|
|
{
|
|
|
|
to: '/my/chores',
|
|
|
|
label: 'Home',
|
|
|
|
icon: <HomeOutlined />,
|
|
|
|
},
|
2024-11-23 20:23:59 -05:00
|
|
|
|
2024-08-10 02:08:49 -04:00
|
|
|
// {
|
|
|
|
// to: '/chores',
|
|
|
|
// label: 'Desktop View',
|
|
|
|
// icon: <ListAltRounded />,
|
|
|
|
// },
|
2024-06-30 18:55:39 -04:00
|
|
|
{
|
|
|
|
to: '/things',
|
|
|
|
label: 'Things',
|
|
|
|
icon: <Widgets />,
|
|
|
|
},
|
2024-12-31 02:20:52 -05:00
|
|
|
{
|
|
|
|
to: 'labels',
|
|
|
|
label: 'Labels',
|
|
|
|
icon: <ListAlt />,
|
|
|
|
},
|
2024-12-28 18:52:06 -05:00
|
|
|
{
|
|
|
|
to: 'activities',
|
|
|
|
label: 'Activities',
|
|
|
|
icon: <History />,
|
|
|
|
},
|
2024-11-23 20:23:59 -05:00
|
|
|
{
|
2024-12-31 02:20:52 -05:00
|
|
|
to: 'points',
|
|
|
|
label: 'Points',
|
|
|
|
icon: <Toll />,
|
2024-11-23 20:23:59 -05:00
|
|
|
},
|
2024-06-30 18:55:39 -04:00
|
|
|
{
|
|
|
|
to: '/settings#sharing',
|
|
|
|
label: 'Sharing',
|
|
|
|
icon: <ShareOutlined />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
to: '/settings#notifications',
|
|
|
|
label: 'Notifications',
|
|
|
|
icon: <Message />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
to: '/settings#account',
|
|
|
|
label: 'Account',
|
|
|
|
icon: <AccountBox />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
to: '/settings',
|
|
|
|
label: 'Settings',
|
|
|
|
icon: <SettingsOutlined />,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
const NavBar = () => {
|
2024-07-13 01:54:23 -04:00
|
|
|
const navigate = useNavigate()
|
2024-06-30 18:55:39 -04:00
|
|
|
const [drawerOpen, setDrawerOpen] = useState(false)
|
|
|
|
const [openDrawer, closeDrawer] = [
|
|
|
|
() => setDrawerOpen(true),
|
|
|
|
() => setDrawerOpen(false),
|
|
|
|
]
|
|
|
|
const location = useLocation()
|
|
|
|
// if url has /landing then remove the navbar:
|
|
|
|
if (
|
2024-07-09 21:21:00 -04:00
|
|
|
['/signup', '/login', '/landing', '/forgot-password'].includes(
|
2024-06-30 18:55:39 -04:00
|
|
|
location.pathname,
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
return null
|
|
|
|
}
|
2024-07-09 21:21:00 -04:00
|
|
|
if (
|
|
|
|
location.pathname === '/' &&
|
|
|
|
import.meta.env.VITE_IS_LANDING_DEFAULT === 'true'
|
|
|
|
) {
|
|
|
|
return null
|
|
|
|
}
|
2024-06-30 18:55:39 -04:00
|
|
|
|
|
|
|
return (
|
2025-02-02 01:27:37 -05:00
|
|
|
<nav className='flex gap-2 p-2'>
|
2024-06-30 18:55:39 -04:00
|
|
|
<IconButton size='sm' variant='plain' onClick={() => setDrawerOpen(true)}>
|
|
|
|
<MenuRounded />
|
|
|
|
</IconButton>
|
2024-07-13 01:54:23 -04:00
|
|
|
<Box
|
2025-02-02 01:27:37 -05:00
|
|
|
className='flex items-center gap-1'
|
2024-07-13 01:54:23 -04:00
|
|
|
onClick={() => {
|
|
|
|
navigate('/my/chores')
|
|
|
|
}}
|
|
|
|
>
|
2025-02-02 01:27:37 -05:00
|
|
|
<img component='img' src={Logo} width='25' />
|
2024-06-30 18:55:39 -04:00
|
|
|
<Typography
|
|
|
|
level='title-lg'
|
|
|
|
sx={{
|
|
|
|
fontWeight: 700,
|
2025-02-02 01:27:37 -05:00
|
|
|
fontSize: 20,
|
2025-02-11 20:47:29 -05:00
|
|
|
cursor: 'pointer',
|
2024-06-30 18:55:39 -04:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
Done
|
|
|
|
<span
|
|
|
|
style={{
|
|
|
|
color: '#06b6d4',
|
|
|
|
fontWeight: 600,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
tick✓
|
|
|
|
</span>
|
|
|
|
</Typography>
|
2024-12-28 18:52:06 -05:00
|
|
|
<ThemeToggleButton
|
|
|
|
sx={{
|
|
|
|
position: 'absolute',
|
|
|
|
right: 10,
|
|
|
|
}}
|
|
|
|
/>
|
2024-06-30 18:55:39 -04:00
|
|
|
</Box>
|
|
|
|
<Drawer
|
|
|
|
open={drawerOpen}
|
|
|
|
onClose={closeDrawer}
|
|
|
|
size='sm'
|
|
|
|
onClick={closeDrawer}
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
{/* <div className='align-center flex px-5 pt-4'>
|
|
|
|
<ModalClose size='sm' sx={{ top: 'unset', right: 20 }} />
|
|
|
|
</div> */}
|
|
|
|
<List
|
|
|
|
// sx={{ p: 2, height: 'min-content' }}
|
|
|
|
size='md'
|
|
|
|
onClick={openDrawer}
|
|
|
|
sx={{ borderRadius: 4, width: '100%', padding: 1 }}
|
|
|
|
>
|
|
|
|
{links.map((link, index) => (
|
|
|
|
<NavBarLink key={index} link={link} />
|
|
|
|
))}
|
|
|
|
</List>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<List
|
|
|
|
sx={{
|
|
|
|
p: 2,
|
|
|
|
height: 'min-content',
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: 0,
|
|
|
|
borderRadius: 4,
|
|
|
|
width: '100%',
|
|
|
|
padding: 2,
|
|
|
|
}}
|
|
|
|
size='md'
|
|
|
|
onClick={openDrawer}
|
|
|
|
>
|
|
|
|
<ListItemButton
|
|
|
|
onClick={() => {
|
|
|
|
localStorage.removeItem('ca_token')
|
|
|
|
localStorage.removeItem('ca_expiration')
|
|
|
|
// go to login page:
|
|
|
|
window.location.href = '/login'
|
|
|
|
}}
|
|
|
|
sx={{
|
|
|
|
py: 1.2,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<ListItemDecorator>
|
|
|
|
<Logout />
|
|
|
|
</ListItemDecorator>
|
|
|
|
<ListItemContent>Logout</ListItemContent>
|
|
|
|
</ListItemButton>
|
|
|
|
<Typography
|
2024-07-06 02:34:49 -04:00
|
|
|
onClick={
|
|
|
|
// force service worker to update:
|
|
|
|
() => window.location.reload(true)
|
|
|
|
}
|
2024-06-30 18:55:39 -04:00
|
|
|
level='body-xs'
|
|
|
|
sx={{
|
|
|
|
// p: 2,
|
|
|
|
p: 1,
|
|
|
|
color: 'text.tertiary',
|
|
|
|
textAlign: 'center',
|
|
|
|
bottom: 0,
|
|
|
|
// mb: -2,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
V{version}
|
|
|
|
</Typography>
|
|
|
|
</List>
|
|
|
|
</div>
|
|
|
|
</Drawer>
|
|
|
|
</nav>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default NavBar
|