Update resources/scripts/components/NavigationBar.tsx

This commit is contained in:
denis 2024-11-03 02:26:44 -05:00
parent 34a793a4bc
commit 1c420bd7be

View file

@ -4,6 +4,7 @@ import { Link, NavLink } from 'react-router-dom';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCogs, faLayerGroup, faSignOutAlt } from '@fortawesome/free-solid-svg-icons';
import { useStoreState } from 'easy-peasy';
import { useTranslation } from 'react-i18next';
import { ApplicationStore } from '@/state';
import SearchContainer from '@/components/dashboard/search/SearchContainer';
import tw, { theme } from 'twin.macro';
@ -13,10 +14,6 @@ import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
import Tooltip from '@/components/elements/tooltip/Tooltip';
import Avatar from '@/components/Avatar';
import BeforeNavigation from '@/blueprint/components/Navigation/NavigationBar/BeforeNavigation';
import AdditionalItems from '@/blueprint/components/Navigation/NavigationBar/AdditionalItems';
import AfterNavigation from '@/blueprint/components/Navigation/NavigationBar/AfterNavigation';
const RightNavigation = styled.div`
& > a,
& > button,
@ -37,8 +34,10 @@ const RightNavigation = styled.div`
`;
export default () => {
const { t } = useTranslation('strings');
const name = useStoreState((state: ApplicationStore) => state.settings.data!.name);
const rootAdmin = useStoreState((state: ApplicationStore) => state.user.data!.rootAdmin);
const isAdmin = useStoreState((state: ApplicationStore) => state.user.data!.admin);
const [isLoggingOut, setIsLoggingOut] = useState(false);
const onTriggerLogout = () => {
@ -50,7 +49,7 @@ export default () => {
};
return (
<div className={'w-full bg-neutral-900 shadow-md overflow-x-auto'} id={'NavigationBar'}>
<div className={'w-full bg-neutral-900 shadow-md overflow-x-auto'}>
<BeforeNavigation />
<SpinnerOverlay visible={isLoggingOut} />
<div className={'mx-auto w-full flex items-center h-[3.5rem] max-w-[1200px]'}>
@ -66,28 +65,28 @@ export default () => {
</div>
<RightNavigation className={'flex h-full items-center justify-center'}>
<SearchContainer />
<Tooltip placement={'bottom'} content={'Dashboard'}>
<NavLink to={'/'} exact id={'NavigationDashboard'}>
<Tooltip placement={'bottom'} content={t<string>('dashboard')}>
<NavLink to={'/'} exact>
<FontAwesomeIcon icon={faLayerGroup} />
</NavLink>
</Tooltip>
{rootAdmin && (
<Tooltip placement={'bottom'} content={'Admin'}>
<a href={'/admin'} rel={'noreferrer'} id={'NavigationAdmin'}>
{isAdmin && (
<Tooltip placement={'bottom'} content={t<string>('admin')}>
<a href={'/admin'} rel={'noreferrer'}>
<FontAwesomeIcon icon={faCogs} />
</a>
</Tooltip>
)}
<AdditionalItems />
<Tooltip placement={'bottom'} content={'Account Settings'}>
<NavLink to={'/account'} id={'NavigationAccount'}>
<Tooltip placement={'bottom'} content={t<string>('account_settings')}>
<NavLink to={'/account'}>
<span className={'flex items-center w-5 h-5'}>
<Avatar.User />
</span>
</NavLink>
</Tooltip>
<Tooltip placement={'bottom'} content={'Sign Out'}>
<button onClick={onTriggerLogout} id={'NavigationLogout'}>
<Tooltip placement={'bottom'} content={t<string>('sign_out')}>
<button onClick={onTriggerLogout}>
<FontAwesomeIcon icon={faSignOutAlt} />
</button>
</Tooltip>
@ -96,4 +95,4 @@ export default () => {
<AfterNavigation />
</div>
);
};
};