import { Capacitor } from '@capacitor/core'
import {
Archive,
ArrowBack,
FilterAlt,
FolderOpen,
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: 'projects',
label: 'Projects',
icon: ,
},
{
to: 'filters',
label: 'Filters',
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'
import { apiClient } from '../../utils/ApiClient'
const publicPages = [
'/landing',
'/privacy',
'/terms',
'login',
'/signup',
'/auth/oauth2',
'/forgot-password',
'/login/settings',
'/',
]
const AppNavBar = () => {
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`
}
})
}, [])
const getMenuIcon = () => {
const menuRounded = (
setDrawerOpen(true)}>
)
if (!Capacitor.isNativePlatform()) {
return menuRounded
}
if (
['/chores', '/'].includes(location.pathname) &&
!searchParams.get('filter')
) {
return menuRounded
}
return (
{
if (location.pathname === '/chores') {
// Navigate back to calendar view
navigate('/')
} else {
// Default back navigation
navigate(-1)
}
}}
title={
searchParams.get('from') === 'calendar' ? 'Back to Calendar' : 'Back'
}
>
)
}
if (publicPages.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 (
)
}
const LandingNavBar = () => {
return null
}
const NavBar = () => {
// if capacitor app then show AppNavBar, else show LandingNavBar
if (Capacitor.isNativePlatform()) {
return
}
if (publicPages.includes(window.location.pathname)) {
return
}
return
}
export default NavBar