Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mdshamoon committed Aug 8, 2023
2 parents 72b628f + 2e7f878 commit 2b45c3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/config/apolloclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const cache = new InMemoryCache({
},
});

const gqlClient = (history: any) => {
const gqlClient = (navigate: any) => {
const refreshTokenLink: any = new TokenRefreshLink({
accessTokenField: 'access_token',
isTokenValidOrUndefined: async () => checkAuthStatusService(),
Expand Down Expand Up @@ -105,7 +105,7 @@ const gqlClient = (history: any) => {
switch (networkError.statusCode) {
case 401:
setLogs(`Error 401: logging user out`, 'error');
history.push('/logout/session');
navigate('/logout/session');
break;
default:
// eslint-disable-next-line
Expand Down
13 changes: 9 additions & 4 deletions src/routes/UnauthenticatedRoute/UnauthenticatedRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { lazy, Suspense } from 'react';
import { Navigate, Route, Routes } from 'react-router-dom';
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';

import Loading from 'components/UI/Layout/Loading/Loading';
import { GoogleReCaptchaProvider } from 'react-google-recaptcha-v3';
import { RECAPTCHA_CLIENT_KEY } from 'config';

export const UnauthenticatedRoute = () => {
const location = useLocation();

const Login = lazy(() => import('containers/Auth/Login/Login'));
const Registration = lazy(() => import('containers/Auth/Registration/Registration'));
const ConfirmOTP = lazy(() => import('containers/Auth/ConfirmOTP/ConfirmOTP'));
Expand All @@ -16,17 +18,20 @@ export const UnauthenticatedRoute = () => {
const OrganizationRegistration = lazy(() => import('containers/Organization/RouteSetupSteps'));

return (
<Suspense fallback={<Loading/>}>
<Suspense fallback={<Loading />}>
<GoogleReCaptchaProvider reCaptchaKey={RECAPTCHA_CLIENT_KEY}>
<Routes>
<Route index element={<Navigate to="/logout/user" replace />} />
<Route index element={<Navigate to="/logout/user" replace state={location.pathname} />} />
<Route path="/login" element={<Login />} />
<Route path="/registration" element={<Registration />} />
<Route path="/confirmotp" element={<ConfirmOTP />} />
<Route path="/resetpassword-phone" element={<ResetPasswordPhone />} />
<Route path="/resetpassword-confirmotp" element={<ResetPasswordConfirmOTP />} />
<Route path="/organization-registration" element={<OrganizationRegistration />} />
<Route path="/*" element={<Navigate to="/logout/user" replace />} />
<Route
path="/*"
element={<Navigate to="/logout/user" replace state={location.pathname} />}
/>
</Routes>
</GoogleReCaptchaProvider>
</Suspense>
Expand Down

0 comments on commit 2b45c3b

Please sign in to comment.