Skip to content

Commit ec2cc2b

Browse files
committed
fix: redirection handler
fix: add removed redirect path
1 parent 266d7ed commit ec2cc2b

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

src/containers/Routes.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ function MainRoutes() {
160160
}
161161
/>
162162
<Route path="/noredirect" element={<Noredirect />} />
163+
<Route path="/redirect" element={<RedirectHandler />} />
163164
</Route>
164165
<Route path="*" element={<Error />} />
165166
</Routes>
@@ -168,4 +169,4 @@ function MainRoutes() {
168169
);
169170
}
170171

171-
export default MainRoutes;
172+
export default MainRoutes;

src/pages/Organization/UserRegister.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/* eslint-disable */
2-
import { useApolloClient, useLazyQuery, useMutation } from '@apollo/client';
3-
import React, { useContext, useState, useEffect } from 'react';
2+
import { useLazyQuery, useMutation } from '@apollo/client';
3+
import React, { useContext, useEffect, useState } from 'react';
44
import { useForm } from 'react-hook-form';
55

6+
import jwt_decode from 'jwt-decode';
67
import { useTranslation } from 'react-i18next';
7-
import { FaGoogle, FaRegEnvelope, FaRegEye } from 'react-icons/fa';
8+
import { FaRegEnvelope, FaRegEye } from 'react-icons/fa';
89
import { FiEyeOff } from 'react-icons/fi';
910
import { MdLockOutline } from 'react-icons/md';
1011
import { Link, useLocation, useNavigate } from 'react-router-dom';
1112
import { toast } from 'react-toastify';
1213
import ButtonLoading from '../../components/ButtonLoading';
1314
import Button from '../../components/Buttons';
15+
import ControlledSelect from '../../components/ControlledSelect';
1416
import { UserContext } from '../../hook/useAuth';
1517
import useDocumentTitle from '../../hook/useDocumentTitle';
16-
import { SIGN_UP_MUTATION, GET_SIGNUP_ORGANIZATION } from './Mutations';
17-
import ControlledSelect from '../../components/ControlledSelect';
18-
import jwt_decode from 'jwt-decode';
18+
import { GET_SIGNUP_ORGANIZATION, SIGN_UP_MUTATION } from './Mutations';
1919

2020
const Signup = () => {
2121
const token: any = window.location.href.substring(

src/pages/RedirectHandler.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import React, { useEffect } from 'react';
33
const APP_ID = 'com.atlp.pulseapp';
44

55
export default function RedirectHandler() {
6+
const [redirectUrl, setRedirectUrl] = React.useState('');
7+
68
const buildQueryString = (params: URLSearchParams) => {
79
let queryParams = '?';
810
const ignoredKeys = ['path', 'dest', 'fallback'];
@@ -25,32 +27,33 @@ export default function RedirectHandler() {
2527
const path = params.get('path');
2628
const destnation = params.get('dest');
2729
const fallback = params.get('fallback');
30+
setRedirectUrl(fallback ?? '/');
2831

2932
if (path != null) {
3033
if (destnation === 'web') {
3134
return window.location.replace(path + queryParams);
3235
}
3336

3437
if (destnation === 'app') {
35-
setTimeout(
36-
() => window.location.replace(`${APP_ID}://${path}${queryParams}`),
37-
500,
38-
);
39-
window.location.replace(fallback ? fallback + queryParams : '/');
38+
window.location.replace(`${APP_ID}://${path}${queryParams}`);
4039
}
41-
42-
window.location.replace(fallback ? fallback + queryParams : '/');
4340
} else {
4441
// eslint-disable-next-line no-console
4542
console.error('Invalid redirect data');
4643
}
4744

4845
return () => {};
49-
}, []);
46+
}, [redirectUrl]);
5047

5148
return (
5249
<div className=" dark:bg-dark-frame-bg flex flex-col py-8 px-5 items-center justify-center grow h-full w-full">
5350
<p>Redirecting...</p>
51+
<p>
52+
If you are not redirected in a few seconds, please click{' '}
53+
<a className="underline" href={redirectUrl}>
54+
here
55+
</a>
56+
</p>
5457
</div>
5558
);
5659
}

0 commit comments

Comments
 (0)