2021-06-16 17:51:25 +03:00
|
|
|
import React, { useState, Suspense, lazy } from 'react';
|
2021-06-02 18:25:25 +03:00
|
|
|
import { HashRouter as Router, Route, Switch } from 'react-router-dom';
|
2021-05-27 17:44:11 +03:00
|
|
|
import 'bootstrap/dist/css/bootstrap.min.css';
|
|
|
|
import './fonts/stylesheet.css';
|
2021-05-25 14:50:01 +03:00
|
|
|
|
2021-06-18 17:16:08 +03:00
|
|
|
const AuthPageForDevelopers = lazy(() => import('./pages/AuthPageForDevelopers'));
|
2021-06-16 17:51:25 +03:00
|
|
|
// const AuthPageForPartners = lazy(() => import('./pages/AuthPageForPartners'));
|
2021-05-27 17:44:11 +03:00
|
|
|
const HomePage = lazy(() => import('./pages/HomePage'));
|
|
|
|
const CandidatePage = lazy(() => import('./pages/CandidatePage'));
|
2021-06-16 17:51:25 +03:00
|
|
|
const CalendarPage = lazy(() => import('./pages/CalendarPage'));
|
2021-06-21 17:41:26 +03:00
|
|
|
const ReportPage = lazy(() => import('./pages/ReportFormPage.js'));
|
2021-05-26 13:35:57 +03:00
|
|
|
|
|
|
|
const App = () => {
|
2021-06-21 12:08:12 +03:00
|
|
|
const [isAuth, setIsAuth] = useState(true);
|
2021-06-29 17:58:15 +03:00
|
|
|
const [candidates, setCandidates] = useState([]);
|
2021-06-30 17:21:55 +03:00
|
|
|
const [candidateForCalendar, setCandidateForCalendar] = useState([]);
|
2021-06-29 17:58:15 +03:00
|
|
|
|
|
|
|
const getCandidate = (candidateArr) => {
|
2021-06-30 17:21:55 +03:00
|
|
|
console.log('candidateArr ', candidateArr);
|
2021-06-29 17:58:15 +03:00
|
|
|
setCandidates(candidateArr);
|
|
|
|
};
|
2021-05-31 13:40:49 +03:00
|
|
|
|
2021-06-30 17:21:55 +03:00
|
|
|
const getCandidateForCalendar = (candidate) => {
|
|
|
|
setCandidateForCalendar(candidate);
|
|
|
|
};
|
|
|
|
|
2021-05-25 14:50:01 +03:00
|
|
|
return (
|
2021-05-26 13:35:57 +03:00
|
|
|
<Router>
|
|
|
|
<Suspense fallback={<div>Loading...</div>}>
|
|
|
|
{isAuth ? (
|
|
|
|
<Switch>
|
2021-05-31 18:23:25 +03:00
|
|
|
<Route path="/" exact>
|
2021-06-29 17:58:15 +03:00
|
|
|
<HomePage getCandidate={getCandidate} />
|
2021-05-31 18:23:25 +03:00
|
|
|
</Route>
|
|
|
|
<Route path="/candidate/:id">
|
2021-06-30 17:21:55 +03:00
|
|
|
<CandidatePage candidatesArr={candidates} getCandidateForCalendar={getCandidateForCalendar} />
|
2021-05-31 18:23:25 +03:00
|
|
|
</Route>
|
2021-06-18 17:16:08 +03:00
|
|
|
<Route path="/calendar">
|
2021-06-30 17:21:55 +03:00
|
|
|
<CalendarPage candidateForCalendar={candidateForCalendar} />
|
2021-06-18 17:16:08 +03:00
|
|
|
</Route>
|
2021-06-21 17:41:26 +03:00
|
|
|
<Route path="/report">
|
|
|
|
<ReportPage />
|
|
|
|
</Route>
|
2021-05-31 18:23:25 +03:00
|
|
|
<Route>
|
|
|
|
<div>Not found page</div>
|
|
|
|
</Route>
|
2021-05-26 13:35:57 +03:00
|
|
|
</Switch>
|
|
|
|
) : (
|
2021-05-31 18:23:25 +03:00
|
|
|
<Route path="/" exact>
|
2021-06-18 17:16:08 +03:00
|
|
|
<AuthPageForDevelopers setAuth={setIsAuth} />
|
2021-06-16 17:51:25 +03:00
|
|
|
{/* <AuthPageForPartners setAuth={setIsAuth} /> */}
|
2021-05-31 18:23:25 +03:00
|
|
|
</Route>
|
2021-05-26 13:35:57 +03:00
|
|
|
)}
|
|
|
|
</Suspense>
|
|
|
|
</Router>
|
2021-05-27 17:44:11 +03:00
|
|
|
);
|
|
|
|
};
|
2021-05-25 14:50:01 +03:00
|
|
|
|
2021-05-27 17:44:11 +03:00
|
|
|
export default App;
|