-
Notifications
You must be signed in to change notification settings - Fork 3
/
Nav.tsx
19 lines (16 loc) · 849 Bytes
/
Nav.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import Button from '@mui/material/Button';
import { Fragment } from "react";
import { useTranslation } from "react-i18next";
import { useHistory, useLocation } from "react-router-dom";
import { useAppSelector } from "../../app/hooks";
import { selectAuth } from "../auth/authSlice";
export const Nav = () => {
const history = useHistory();
const location = useLocation();
const { t } = useTranslation();
const authState = useAppSelector(selectAuth);
return <Fragment>
{authState.isAuthenticated && location.pathname !== '/dashboard' && <Button data-testid="dashboard-link" color="inherit" onClick={() => history.push('/dashboard')}>{t('dashboard')}</Button>}
{location.pathname !== '/' && <Button data-testid="home-link" color="inherit" onClick={() => history.push('/')}>{t('home')}</Button>}
</Fragment>
}