Skip to content

Commit a4bbee0

Browse files
committed
fix: redirection handler
1 parent c13aa3d commit a4bbee0

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

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: 16 additions & 7 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,39 @@ 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 ?? '/');
31+
console.log(fallback);
2832

2933
if (path != null) {
3034
if (destnation === 'web') {
3135
return window.location.replace(path + queryParams);
3236
}
3337

3438
if (destnation === 'app') {
35-
setTimeout(
36-
() => window.location.replace(`${APP_ID}://${path}${queryParams}`),
37-
500,
38-
);
39-
window.location.replace(fallback ? fallback + queryParams : '/');
39+
setTimeout(() => {
40+
window.location.replace(`${APP_ID}://${path}${queryParams}`);
41+
}, 500);
42+
window.location.replace(redirectUrl);
4043
}
4144

42-
window.location.replace(fallback ? fallback + queryParams : '/');
45+
window.location.replace(redirectUrl);
4346
} else {
4447
// eslint-disable-next-line no-console
4548
console.error('Invalid redirect data');
4649
}
4750

4851
return () => {};
49-
}, []);
52+
}, [redirectUrl]);
5053

5154
return (
5255
<div className=" dark:bg-dark-frame-bg flex flex-col py-8 px-5 items-center justify-center grow h-full w-full">
5356
<p>Redirecting...</p>
57+
<p>
58+
If you are not redirected in a few seconds, please click{' '}
59+
<a className="underline" href={redirectUrl}>
60+
here
61+
</a>
62+
</p>
5463
</div>
5564
);
5665
}

0 commit comments

Comments
 (0)