| @@ -1,24 +1,12 @@ | |||
| import React, { useEffect } from "react"; | |||
| import React from "react"; | |||
| import { Router } from "react-router-dom"; | |||
| import { Helmet } from "react-helmet-async"; | |||
| import i18next from "i18next"; | |||
| import history from "./store/utils/history"; | |||
| import MainContainer from "./components/Section/MainContainer"; | |||
| import AppRoutes from "./AppRoutes"; | |||
| import { useDispatch } from "react-redux"; | |||
| import { refreshUserToken } from "./store/actions/login/loginActions"; | |||
| import { BASE_PAGE } from "./constants/pages"; | |||
| function App() { | |||
| const dispatch = useDispatch(); | |||
| useEffect(() => { | |||
| if (history.location.pathname === BASE_PAGE) { | |||
| return; | |||
| } | |||
| dispatch(refreshUserToken()); | |||
| }, []); | |||
| return ( | |||
| <> | |||
| <Router history={history}> | |||
| @@ -1,5 +1,8 @@ | |||
| import React from "react"; | |||
| import React, { useEffect } from "react"; | |||
| import { Redirect, Route, Switch } from "react-router-dom"; | |||
| import { useDispatch } from "react-redux"; | |||
| import { refreshUserToken } from "./store/actions/login/loginActions"; | |||
| import { useLocation } from "react-router-dom"; | |||
| import { | |||
| HOME_PAGE, | |||
| @@ -22,7 +25,7 @@ import { | |||
| SCHEDULE_PAGE, | |||
| STATS_PAGE, | |||
| REGISTER_PAGE, | |||
| CREATE_AD_PAGE | |||
| CREATE_AD_PAGE, | |||
| } from "./constants/pages"; | |||
| // import LoginPage from './pages/LoginPage/LoginPage'; | |||
| @@ -51,51 +54,62 @@ import StatsPage from "./pages/StatsPage/StatsPage"; | |||
| import RegisterPage from "./pages/RegisterPage/RegisterPage"; | |||
| import CreateAdPage from "./pages/AdsPage/CreateAdPage"; | |||
| const AppRoutes = () => ( | |||
| <Switch> | |||
| <Route exact path={BASE_PAGE} component={LoginPage} /> | |||
| <Route path={NOT_FOUND_PAGE} component={NotFoundPage} /> | |||
| {/* <Route path={USERS_PAGE} component={UsersPage} /> */} | |||
| <Route path={ERROR_PAGE} component={ErrorPage} /> | |||
| <Route path={FORGOT_PASSWORD_PAGE} component={ForgotPasswordPage} /> | |||
| <Route | |||
| path={FORGOT_PASSWORD_CONFIRMATION_PAGE} | |||
| component={ForgotPasswordConfirmationPage} | |||
| /> | |||
| <Route exact path={REGISTER_PAGE} component={RegisterPage} /> | |||
| <Route path={RESET_PASSWORD_PAGE} component={ResetPasswordPage} /> | |||
| <PrivateRoute exact path={HOME_PAGE} component={HomePage} /> | |||
| <PrivateRoute exact path={ADS_PAGE} component={AdsPage} /> | |||
| <PrivateRoute exact path={AD_DETAILS_PAGE} component={AdDetailsPage} /> | |||
| <PrivateRoute exact path={USER_DETAILS_PAGE} component={UserDetails} /> | |||
| <PrivateRoute exact path={USERS_PAGE} component={UsersPage} /> | |||
| <PrivateRoute exact path={CANDIDATES_PAGE} component={CandidatesPage} /> | |||
| <PrivateRoute exact path={CREATE_AD_PAGE} component={CreateAdPage} /> | |||
| <PrivateRoute | |||
| exact | |||
| path={CANDIDATES_DETAILS_PAGE} | |||
| component={CandidateDetailsPage} | |||
| /> | |||
| <PrivateRoute | |||
| exact | |||
| path={SELECTION_PROCESS_PAGE} | |||
| component={SelectionProcessPage} | |||
| /> | |||
| <PrivateRoute | |||
| exact | |||
| path={SELECTION_PROCESS_OF_APPLICANT_PAGE} | |||
| component={SelectionProcessOfApplicantPage} | |||
| /> | |||
| <PrivateRoute | |||
| exact | |||
| path={PATTERN_DETAILS_PAGE} | |||
| component={PatternDetailsPage} | |||
| /> | |||
| <PrivateRoute exact path={PATTERNS_PAGE} component={PatternsPage} /> | |||
| <PrivateRoute exact path={SCHEDULE_PAGE} component={SchedulePage} /> | |||
| <PrivateRoute exact path={STATS_PAGE} component={StatsPage} /> | |||
| <Redirect from="*" to={NOT_FOUND_PAGE} /> | |||
| </Switch> | |||
| ); | |||
| const AppRoutes = () => { | |||
| const dispatch = useDispatch(); | |||
| const location = useLocation(); | |||
| useEffect(() => { | |||
| if (location.pathname === BASE_PAGE) { | |||
| return; | |||
| } | |||
| dispatch(refreshUserToken()); | |||
| }, [location]); | |||
| return ( | |||
| <Switch> | |||
| <Route exact path={BASE_PAGE} component={LoginPage} /> | |||
| <Route path={NOT_FOUND_PAGE} component={NotFoundPage} /> | |||
| {/* <Route path={USERS_PAGE} component={UsersPage} /> */} | |||
| <Route path={ERROR_PAGE} component={ErrorPage} /> | |||
| <Route path={FORGOT_PASSWORD_PAGE} component={ForgotPasswordPage} /> | |||
| <Route | |||
| path={FORGOT_PASSWORD_CONFIRMATION_PAGE} | |||
| component={ForgotPasswordConfirmationPage} | |||
| /> | |||
| <Route exact path={REGISTER_PAGE} component={RegisterPage} /> | |||
| <Route path={RESET_PASSWORD_PAGE} component={ResetPasswordPage} /> | |||
| <PrivateRoute exact path={HOME_PAGE} component={HomePage} /> | |||
| <PrivateRoute exact path={ADS_PAGE} component={AdsPage} /> | |||
| <PrivateRoute exact path={AD_DETAILS_PAGE} component={AdDetailsPage} /> | |||
| <PrivateRoute exact path={USER_DETAILS_PAGE} component={UserDetails} /> | |||
| <PrivateRoute exact path={USERS_PAGE} component={UsersPage} /> | |||
| <PrivateRoute exact path={CANDIDATES_PAGE} component={CandidatesPage} /> | |||
| <PrivateRoute exact path={CREATE_AD_PAGE} component={CreateAdPage} /> | |||
| <PrivateRoute | |||
| exact | |||
| path={CANDIDATES_DETAILS_PAGE} | |||
| component={CandidateDetailsPage} | |||
| /> | |||
| <PrivateRoute | |||
| exact | |||
| path={SELECTION_PROCESS_PAGE} | |||
| component={SelectionProcessPage} | |||
| /> | |||
| <PrivateRoute | |||
| exact | |||
| path={SELECTION_PROCESS_OF_APPLICANT_PAGE} | |||
| component={SelectionProcessOfApplicantPage} | |||
| /> | |||
| <PrivateRoute | |||
| exact | |||
| path={PATTERN_DETAILS_PAGE} | |||
| component={PatternDetailsPage} | |||
| /> | |||
| <PrivateRoute exact path={PATTERNS_PAGE} component={PatternsPage} /> | |||
| <PrivateRoute exact path={SCHEDULE_PAGE} component={SchedulePage} /> | |||
| <PrivateRoute exact path={STATS_PAGE} component={StatsPage} /> | |||
| <Redirect from="*" to={NOT_FOUND_PAGE} /> | |||
| </Switch> | |||
| ); | |||
| }; | |||
| export default AppRoutes; | |||
| @@ -195,9 +195,13 @@ const CandidatesPage = ({ history }) => { | |||
| ) : ( | |||
| <AdsCandidatesPage history={history} search={search} /> | |||
| )} | |||
| <Fade in={isCVDisplayed} timeout={400} className="candidates-cv"> | |||
| <embed src={`data:application/pdf;base64,${linkToCV}`} /> | |||
| </Fade> | |||
| {isTableView ? ( | |||
| <Fade in={isCVDisplayed} timeout={400} className="candidates-cv"> | |||
| <embed src={`data:application/pdf;base64,${linkToCV}`} /> | |||
| </Fade> | |||
| ) : ( | |||
| "" | |||
| )} | |||
| </div> | |||
| </div> | |||
| ); | |||
| @@ -1,6 +1,6 @@ | |||
| import { all, call, put, takeLatest } from '@redux-saga/core/effects'; | |||
| import jwt from 'jsonwebtoken'; | |||
| import history from '../utils/history'; | |||
| import { all, call, put, takeLatest } from "@redux-saga/core/effects"; | |||
| import jwt from "jsonwebtoken"; | |||
| import history from "../utils/history"; | |||
| import { | |||
| AUTHENTICATE_USER, | |||
| LOGIN_GOOGLE_USER_FETCH, | |||
| @@ -9,8 +9,8 @@ import { | |||
| REFRESH_TOKEN, | |||
| GENERATE_TOKEN, | |||
| FORGOT_PASSWORD, | |||
| RESET_PASSWORD | |||
| } from '../actions/login/loginActionConstants'; | |||
| RESET_PASSWORD, | |||
| } from "../actions/login/loginActionConstants"; | |||
| import { | |||
| attemptGoogleLogin, | |||
| attemptLogin, | |||
| @@ -18,8 +18,8 @@ import { | |||
| refreshTokenRequest, | |||
| generateTokenRequest, | |||
| forgetPasswordEmailSend, | |||
| sendResetPassword | |||
| } from '../../request/loginRequest'; | |||
| sendResetPassword, | |||
| } from "../../request/loginRequest"; | |||
| import { | |||
| fetchGoogleUserSuccess, | |||
| fetchUserError, | |||
| @@ -27,29 +27,26 @@ import { | |||
| forgetPasswordSuccess, | |||
| resetLoginState, | |||
| updateUserToken, | |||
| } from '../actions/login/loginActions'; | |||
| import { BASE_PAGE } from '../../constants/pages'; | |||
| import { setUser } from '../actions/user/userActions'; | |||
| import { | |||
| addHeaderToken, | |||
| removeHeaderToken, | |||
| } from '../../request'; | |||
| } from "../actions/login/loginActions"; | |||
| import { BASE_PAGE } from "../../constants/pages"; | |||
| import { setUser } from "../actions/user/userActions"; | |||
| import { addHeaderToken, removeHeaderToken } from "../../request"; | |||
| import { | |||
| IMPERSONATE_USER_UID, | |||
| REGISTRATION_USER_UID, | |||
| } from '../../constants/sessionStorage'; | |||
| } from "../../constants/sessionStorage"; | |||
| import { | |||
| JWT_REFRESH_TOKEN, | |||
| JWT_TOKEN, | |||
| REFRESH_TOKEN_CONST, | |||
| } from '../../constants/localStorage'; | |||
| } from "../../constants/localStorage"; | |||
| import { | |||
| authScopeClearHelper, | |||
| authScopeStringGetHelper, | |||
| authScopeRemoveHelper, | |||
| authScopeSetHelper, | |||
| } from '../../util/helpers/authScopeHelpers'; | |||
| import { rejectErrorCodeHelper } from '../../util/helpers/rejectErrorCodeHelper'; | |||
| } from "../../util/helpers/authScopeHelpers"; | |||
| import { rejectErrorCodeHelper } from "../../util/helpers/rejectErrorCodeHelper"; | |||
| function* fetchUser({ payload }) { | |||
| try { | |||
| @@ -90,8 +87,7 @@ function* forgetPassword({ payload }) { | |||
| const errorMessage = yield call(rejectErrorCodeHelper, e); | |||
| yield put(fetchUserError(errorMessage)); | |||
| } | |||
| } | |||
| finally{ | |||
| } finally { | |||
| // console.log('Done') | |||
| } | |||
| } | |||
| @@ -120,8 +116,9 @@ function* fetchGoogleUser({ payload }) { | |||
| if (data.token) { | |||
| // const user = jwt.decode(data.token); | |||
| yield call(authScopeSetHelper, JWT_TOKEN, data.token); | |||
| yield call(authScopeSetHelper, JWT_REFRESH_TOKEN, data.JwtRefreshToken); | |||
| yield call(authScopeSetHelper, REFRESH_TOKEN_CONST, data.RefreshToken); | |||
| yield call(authScopeSetHelper, JWT_REFRESH_TOKEN, data.refreshToken); | |||
| yield call(authScopeSetHelper, REFRESH_TOKEN_CONST, data.refreshToken); | |||
| yield call(addHeaderToken, data.token); | |||
| yield put(setUser(data)); | |||
| } | |||
| @@ -150,7 +147,7 @@ function* authenticateUser() { | |||
| return yield put( | |||
| fetchUserSuccess({ | |||
| JwtToken, | |||
| }), | |||
| }) | |||
| ); | |||
| } catch (error) { | |||
| const errorMessage = yield call(rejectErrorCodeHelper, error); | |||
| @@ -181,7 +178,10 @@ function* logoutUser() { | |||
| export function* refreshToken() { | |||
| try { | |||
| const token = yield call(authScopeStringGetHelper, JWT_TOKEN); | |||
| const refreshToken = yield call(authScopeStringGetHelper,REFRESH_TOKEN_CONST); | |||
| const refreshToken = yield call( | |||
| authScopeStringGetHelper, | |||
| REFRESH_TOKEN_CONST | |||
| ); | |||
| if (token && refreshToken) { | |||
| const { data } = yield call(refreshTokenRequest, { | |||
| @@ -194,8 +194,8 @@ export function* refreshToken() { | |||
| yield put(setUser(data.data)); | |||
| } | |||
| } catch (error) { | |||
| localStorage.removeItem(JWT_TOKEN) | |||
| localStorage.removeItem(REFRESH_TOKEN_CONST) | |||
| localStorage.removeItem(JWT_TOKEN); | |||
| localStorage.removeItem(REFRESH_TOKEN_CONST); | |||
| yield call(history.replace, BASE_PAGE); | |||
| } | |||
| } | |||