diff --git a/src/common/AppLayout/components/Sidebar/Sidebar.tsx b/src/common/AppLayout/components/Sidebar/Sidebar.tsx index b8ceee6..8a71891 100644 --- a/src/common/AppLayout/components/Sidebar/Sidebar.tsx +++ b/src/common/AppLayout/components/Sidebar/Sidebar.tsx @@ -1,8 +1,8 @@ import React, { useEffect } from 'react'; import { useLocation } from 'react-router-dom'; import clsx from 'clsx'; -import { ROUTE } from 'config/routing'; -import { Route } from './components/Nav/types'; +import { Route } from 'config/routing'; +import { Route as NavRoute } from './components/Nav/types'; import { useTheme } from '@material-ui/core/styles'; import { @@ -15,6 +15,7 @@ import useStyles from './useStyles'; import { Dashboard as DashboardIcon, Group as GroupIcon, + Work as WorkIcon, } from '@material-ui/icons'; import Nav from './components/Nav/Nav'; import CurrentUser from './components/CurrentUser/CurrentUser'; @@ -31,19 +32,25 @@ const Sidebar = ({ className, open, variant, onClose, onOpen }: Props) => { const classes = useStyles(); const theme = useTheme(); const { pathname } = useLocation(); - const routes: Route[] = [ + const routes: NavRoute[] = [ { name: 'Dashboard', - to: ROUTE.DASHBOARD_PAGE, + to: Route.DashboardPage, Icon: , exact: true, }, { name: 'Użytkownicy', - to: ROUTE.USERS_PAGE, + to: Route.UsersPage, exact: true, Icon: , }, + { + name: 'Zawody', + to: Route.ProfessionsPage, + exact: true, + Icon: , + }, ]; useEffect(() => { diff --git a/src/common/AppLayout/components/TopBar/TopBar.tsx b/src/common/AppLayout/components/TopBar/TopBar.tsx index a523e3f..cd36431 100644 --- a/src/common/AppLayout/components/TopBar/TopBar.tsx +++ b/src/common/AppLayout/components/TopBar/TopBar.tsx @@ -1,7 +1,7 @@ import React from 'react'; import clsx from 'clsx'; import { useAuth } from 'libs/auth'; -import { ROUTE } from 'config/routing'; +import { Route } from 'config/routing'; import { makeStyles } from '@material-ui/core/styles'; import { @@ -37,7 +37,7 @@ const TopBar = ({ className, openSidebar }: Props) => { - + Zdam Egzamin Zawodowy diff --git a/src/common/Table/Table.tsx b/src/common/Table/Table.tsx index a9f42ba..62e090d 100644 --- a/src/common/Table/Table.tsx +++ b/src/common/Table/Table.tsx @@ -94,7 +94,7 @@ function Table({ ); } }} - allSelected={selected?.length === data.length} + allSelected={selected?.length === data.length && data.length > 0} /> {loading ? ( diff --git a/src/config/routing.ts b/src/config/routing.ts index 5710bf1..28482d7 100644 --- a/src/config/routing.ts +++ b/src/config/routing.ts @@ -1,11 +1,11 @@ -export const ROUTE = { - SIGN_IN_PAGE: '/', - DASHBOARD_PAGE: '/dashboard', - USERS_PAGE: '/users', - PROFESSIONS_PAGE: '/professions', -}; +export enum Route { + SignInPage = '/', + DashboardPage = '/dashboard', + UsersPage = '/users', + ProfessionsPage = '/professions', +} -export const PUBLIC_ROUTES = [ROUTE.SIGN_IN_PAGE]; -export const ADMIN_ROUTES = Object.values(ROUTE).filter( - route => !PUBLIC_ROUTES.includes(route) +export const PUBLIC_ROUTES = [Route.SignInPage]; +export const ADMIN_ROUTES = Object.values(Route).filter( + route => !PUBLIC_ROUTES.includes(route as Route) ); diff --git a/src/features/AdminRoutes.tsx b/src/features/AdminRoutes.tsx index d50be3b..774a93c 100644 --- a/src/features/AdminRoutes.tsx +++ b/src/features/AdminRoutes.tsx @@ -1,5 +1,5 @@ -import { Switch, Route } from 'react-router-dom'; -import { ROUTE } from '../config/routing'; +import { Switch, Route as RRDRoute } from 'react-router-dom'; +import { Route } from '../config/routing'; import AppLayout from 'common/AppLayout/AppLayout'; import DashboardPage from './DashboardPage/DashboardPage'; import UsersPage from './UsersPage/UsersPage'; @@ -9,15 +9,15 @@ function AdminRoutes() { return ( - + - - + + - {' '} - + + - + ); diff --git a/src/features/App.tsx b/src/features/App.tsx index a750a97..320ba07 100644 --- a/src/features/App.tsx +++ b/src/features/App.tsx @@ -1,25 +1,25 @@ -import { Route, Switch } from 'react-router-dom'; +import { Route as RRDRoute, Switch } from 'react-router-dom'; import PublicRoute from '../libs/router/PublicRoute'; import AdminRoute from '../libs/router/AdminRoute'; import AppLoading from './AppLoading'; import SignInPage from './SignInPage/SignInPage'; import NotFoundPage from './NotFoundPage/NotFoundPage'; import AdminRoutes from './AdminRoutes'; -import { ROUTE, ADMIN_ROUTES } from '../config/routing'; +import { Route, ADMIN_ROUTES } from '../config/routing'; function App() { return ( - + - + - + ); diff --git a/src/features/NotFoundPage/NotFoundPage.tsx b/src/features/NotFoundPage/NotFoundPage.tsx index 399519b..e7f2398 100644 --- a/src/features/NotFoundPage/NotFoundPage.tsx +++ b/src/features/NotFoundPage/NotFoundPage.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { ROUTE } from 'config/routing'; +import { Route } from 'config/routing'; import { makeStyles } from '@material-ui/core/styles'; import { Container, Typography } from '@material-ui/core'; @@ -19,7 +19,7 @@ const NotFoundPage = () => { który nie istnieje. - Wróć na stronę główną + Wróć na stronę główną diff --git a/src/features/ProfessionsPage/ProfessionsPage.tsx b/src/features/ProfessionsPage/ProfessionsPage.tsx index 42acb36..abb64fb 100644 --- a/src/features/ProfessionsPage/ProfessionsPage.tsx +++ b/src/features/ProfessionsPage/ProfessionsPage.tsx @@ -108,7 +108,7 @@ const ProfessionsPage = () => { }; const handleDeleteProfessions = async () => { - if (!window.confirm('Czy na pewno chcesz usunąć wybranych zawody?')) { + if (!window.confirm('Czy na pewno chcesz usunąć wybrane zawody?')) { return; } try { diff --git a/src/libs/router/AdminRoute.tsx b/src/libs/router/AdminRoute.tsx index 0ef307d..b0b906b 100644 --- a/src/libs/router/AdminRoute.tsx +++ b/src/libs/router/AdminRoute.tsx @@ -1,19 +1,19 @@ -import { Route, Redirect, RouteProps } from 'react-router-dom'; +import { Route as RRDRoute, Redirect, RouteProps } from 'react-router-dom'; import { isNil } from 'lodash'; import { useAuth } from '../auth'; import { Role } from '../graphql/types'; -import { ROUTE } from 'config/routing'; +import { Route } from 'config/routing'; const AdminRoute = ({ children, ...rest }: RouteProps) => { const { user } = useAuth(); return ( - + {!isNil(user) && user.role === Role.Admin ? ( children ) : ( - + )} - + ); }; diff --git a/src/libs/router/PublicRoute.tsx b/src/libs/router/PublicRoute.tsx index 94fd8b8..f63c533 100644 --- a/src/libs/router/PublicRoute.tsx +++ b/src/libs/router/PublicRoute.tsx @@ -1,19 +1,19 @@ -import { Redirect, Route, RouteProps } from 'react-router-dom'; +import { Redirect, Route as RRDRoute, RouteProps } from 'react-router-dom'; import { isNil } from 'lodash'; import { useAuth } from '../auth'; -import { ROUTE } from '../../config/routing'; +import { Route } from '../../config/routing'; import { Role } from '../graphql/types'; const PublicRoute = ({ children, ...rest }: RouteProps) => { const { user } = useAuth(); return ( - + {isNil(user) || user.role !== Role.Admin ? ( children ) : ( - + )} - + ); };