added server auth and protected routes
This commit is contained in:
76
src/App.js
76
src/App.js
@ -1,60 +1,40 @@
|
||||
import React, { Suspense, lazy } from 'react';
|
||||
import { HashRouter as Router, Route, Switch } from 'react-router-dom';
|
||||
import { useSelector } from 'react-redux';
|
||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||
import './fonts/stylesheet.css';
|
||||
import { selectAuth } from './redux/outstaffingSlice';
|
||||
import React, { Suspense, lazy } from 'react'
|
||||
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
|
||||
import 'bootstrap/dist/css/bootstrap.min.css'
|
||||
import './fonts/stylesheet.css'
|
||||
import { ProtectedRoute } from './components/ProtectedRoute/ProtectedRoute';
|
||||
|
||||
const AuthPageForDevelopers = lazy(() => import('./pages/AuthPageForDevelopers'));
|
||||
// const AuthPageForPartners = lazy(() => import('./pages/AuthPageForPartners'));
|
||||
const HomePage = lazy(() => import('./pages/HomePage'));
|
||||
const CandidatePage = lazy(() => import('./pages/CandidatePage'));
|
||||
const CalendarPage = lazy(() => import('./pages/CalendarPage'));
|
||||
const ReportPage = lazy(() => import('./pages/ReportFormPage.js'));
|
||||
const FormPage = lazy(() => import('./pages/FormPage.js'));
|
||||
const AuthPageForDevelopers = lazy(() =>
|
||||
import('./pages/AuthPageForDevelopers')
|
||||
)
|
||||
const AuthPageForPartners = lazy(() => import('./pages/AuthPageForPartners'))
|
||||
const HomePage = lazy(() => import('./pages/HomePage'))
|
||||
const CandidatePage = lazy(() => import('./pages/CandidatePage'))
|
||||
const CalendarPage = lazy(() => import('./pages/CalendarPage'))
|
||||
const ReportPage = lazy(() => import('./pages/ReportFormPage.js'))
|
||||
const FormPage = lazy(() => import('./pages/FormPage.js'))
|
||||
|
||||
const App = () => {
|
||||
const isAuth = useSelector(selectAuth);
|
||||
// const [candidateForCalendar, setCandidateForCalendar] = useState([]);
|
||||
|
||||
// const getCandidateForCalendar = (candidate) => {
|
||||
// console.log('candidate ', candidate);
|
||||
// setCandidateForCalendar(candidate);
|
||||
// };
|
||||
|
||||
return (
|
||||
<Router>
|
||||
<Suspense fallback={<div>Loading...</div>}>
|
||||
{isAuth ? (
|
||||
<Switch>
|
||||
<Route path="/" exact>
|
||||
<HomePage />
|
||||
</Route>
|
||||
<Route path="/candidate/:id">
|
||||
<CandidatePage />
|
||||
</Route>
|
||||
<Route path="/calendar">
|
||||
<CalendarPage />
|
||||
</Route>
|
||||
<Route path="/form">
|
||||
<FormPage />
|
||||
</Route>
|
||||
<Route path="/report">
|
||||
<ReportPage />
|
||||
</Route>
|
||||
<Route>
|
||||
<div>Not found page</div>
|
||||
</Route>
|
||||
</Switch>
|
||||
) : (
|
||||
<Route path="/" exact>
|
||||
<Switch>
|
||||
<Route path='/auth' exact>
|
||||
{/* <AuthPageForPartners /> */}
|
||||
<AuthPageForDevelopers />
|
||||
</Route>
|
||||
)}
|
||||
<ProtectedRoute path='/' exact component={HomePage} />
|
||||
<ProtectedRoute path='/candidate/:id' component={CandidatePage} />
|
||||
<ProtectedRoute path='/calendar' component={CalendarPage} />
|
||||
<ProtectedRoute path='/form' component={FormPage} />
|
||||
<ProtectedRoute path='/report' component={ReportPage} />
|
||||
<Route>
|
||||
<div>Page not found</div>
|
||||
</Route>
|
||||
</Switch>
|
||||
</Suspense>
|
||||
</Router>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default App;
|
||||
export default App
|
||||
|
Reference in New Issue
Block a user