import React from 'react';
import { Box, Center, Flex } from '@chakra-ui/react';
import { Link, useLocation, useNavigate } from '@remix-run/react';
import { Commander } from '../Commander/Commander';
import { CommanderV1 } from '../Commander/CommanderV2';
import { Icon } from '../Icon/Icon';
import { RainbowSkeleton } from '../Skeleton/RainbowSkeleton';
import { ProfileDrawer } from './ProfileDrawer';
export const Nav = (props) => {
const [profileDrawerOpen, setProfileDrawerOpen] = React.useState(false);
const { pathname } = useLocation();
const navigate = useNavigate();
const toggleProfileDrawer = React.useCallback(() => {
setProfileDrawerOpen(!profileDrawerOpen);
}, [profileDrawerOpen]);
const inEditorMode = React.useMemo(() => {
if (pathname.slice(0, 7) === '/editor') {
return true;
}
return false;
}, [pathname]);
const inEditMode = React.useMemo(() => {
if (pathname.slice(0, 5) === '/edit') {
return true;
}
return false;
}, [pathname]);
const editorToggleable = React.useMemo(() => {
if (pathname.slice(0, 7) === '/things') {
return true;
} else if (pathname.slice(0, 5) === '/edit') {
return true;
}
return false;
}, [pathname]);
const toggleEdit = React.useCallback(
(e) => {
// if first characters of pathname are /things replace with /edit
// or if first characters of pathname are /edit replace with /things
if (pathname.slice(0, 7) === '/things') {
const newPathname = pathname.replace('/things', '/edit');
navigate(newPathname);
} else if (pathname.slice(0, 7) === '/editor') {
const newPathname = pathname.replace('/editor', '/things');
navigate(newPathname);
} else if (pathname.slice(0, 5) === '/edit') {
const newPathname = pathname.replace('/edit', '/things');
navigate(newPathname);
}
},
[pathname, navigate]
);
const toggleEditor = React.useCallback(
(e) => {
// if first characters of pathname are /things replace with /edit
// or if first characters of pathname are /edit replace with /things
if (pathname.slice(0, 7) === '/editor') {
const newPathname = pathname.replace('/editor', '/edit');
navigate(newPathname);
} else if (pathname.slice(0, 5) === '/edit') {
const newPathname = pathname.replace('/edit', '/editor');
navigate(newPathname);
}
},
[pathname, navigate]
);
return (
<>
{inEditMode && (
{/* */}
)}
{editorToggleable && (
{/* */}
)}
{/* TODO - Add conditional only show if loggedIn */}
{/* */}
{/*
*/}
{/* */}
>
);
};