import { Capacitor } from '@capacitor/core'
import {
Archive,
ArrowBack,
History,
Inbox,
ListAlt,
Logout,
MenuRounded,
SettingsOutlined,
Toll,
Widgets,
} from '@mui/icons-material'
import {
Box,
Drawer,
IconButton,
List,
ListItemButton,
ListItemContent,
ListItemDecorator,
Typography,
} from '@mui/joy'
import { useEffect, useState } from 'react'
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'
import { version } from '../../../package.json'
import UserProfileAvatar from '../../components/UserProfileAvatar'
import NavBarLink from './NavBarLink'
const links = [
{
to: '/chores',
label: 'All Tasks',
icon: ,
},
{
to: '/archived',
label: 'Archived',
icon: ,
},
// {
// to: '/chores',
// label: 'Desktop View',
// icon: ,
// },
{
to: '/things',
label: 'Things',
icon: ,
},
{
to: 'labels',
label: 'Labels',
icon: ,
},
{
to: 'activities',
label: 'Activities',
icon: ,
},
{
to: 'points',
label: 'Points',
icon: ,
},
// {
// to: '/settings#sharing',
// label: 'Sharing',
// icon: ,
// },
// {
// to: '/settings#notifications',
// label: 'Notifications',
// icon: ,
// },
// {
// to: '/settings#account',
// label: 'Account',
// icon: ,
// },
{
to: '/settings',
label: 'Settings',
icon: ,
},
]
import { SafeArea } from 'capacitor-plugin-safe-area'
import Z_INDEX from '../../constants/zIndex'
import { useResource } from '../../queries/ResourceQueries'
const publicPages = ['/landing', '/privacy', '/terms']
const NavBar = () => {
const { data: resource } = useResource()
const navigate = useNavigate()
const [drawerOpen, setDrawerOpen] = useState(false)
const [openDrawer, closeDrawer] = [
() => setDrawerOpen(true),
() => setDrawerOpen(false),
]
const location = useLocation()
const [searchParams] = useSearchParams()
useEffect(() => {
SafeArea.getSafeAreaInsets().then(data => {
const { insets } = data
const drawerContent = document.querySelector('.drawer-content')
if (drawerContent) {
drawerContent.style.paddingTop = `${insets.top}px`
drawerContent.style.paddingRight = `${insets.right}px`
drawerContent.style.paddingBottom = `${insets.bottom}px`
drawerContent.style.paddingLeft = `${insets.left}px`
}
})
}, [])
if (
['/signup', '/login', '/forgot-password', '/login/settings'].includes(
location.pathname,
)
) {
return (
// no navbar but show the safe area padding
)
}
// if url has /landing then remove the navbar:
if (publicPages.includes(location.pathname)) {
return null
}
if (
location.pathname === '/' &&
import.meta.env.VITE_IS_LANDING_DEFAULT === 'true'
) {
return null
}
return (
)
}
export default NavBar