|
1 | | -// import { RouteVisibilityAuthentication } from '../RouteVisibility'; |
2 | | -// import { loggedOutRoute, loggedInRoute } from '../../constants'; |
3 | | - |
4 | | -// const isUnauthenticatedOrMissingRoute = ( |
5 | | -// currentLocation: any | undefined, |
6 | | -// ): boolean => |
7 | | -// currentLocation |
8 | | -// ? currentLocation.visibility && |
9 | | -// currentLocation.visibility.authentication === |
10 | | -// RouteVisibilityAuthentication.unauthenticatedOnly |
11 | | -// : false; |
12 | | - |
13 | | -// const isAuthenticatedOrMissingRoute = ( |
14 | | -// currentLocation: any | undefined, |
15 | | -// ): boolean => |
16 | | -// currentLocation |
17 | | -// ? currentLocation.visibility && |
18 | | -// currentLocation.visibility.authentication === |
19 | | -// RouteVisibilityAuthentication.authenticatedOnly |
20 | | -// : false; |
21 | | - |
22 | | -// let timeout = null as any; |
23 | | - |
24 | | -// export const replaceRouteIfNeeded = ({ |
25 | | -// user, |
26 | | -// isAuthenticated, |
27 | | -// currentLocation, |
28 | | -// replaceRoute, |
29 | | -// routeFromSearchParam, |
30 | | -// }: { |
31 | | -// user: any; |
32 | | -// isAuthenticated: any; |
33 | | -// currentLocation: any | undefined; |
34 | | -// replaceRoute: (arg1: string) => void; |
35 | | -// routeFromSearchParam: null | string; |
36 | | -// }): void => { |
37 | | -// clearTimeout(timeout); |
38 | | - |
39 | | -// const routeToReplace = () => { |
40 | | -// return isAuthenticated ? loggedInRoute : loggedOutRoute; |
41 | | -// }; |
42 | | -// const replaceToLoggedInRoute = |
43 | | -// isAuthenticated && isUnauthenticatedOrMissingRoute(currentLocation); |
44 | | - |
45 | | -// const replaceToLoggedOutRoute = |
46 | | -// !isAuthenticated && isAuthenticatedOrMissingRoute(currentLocation); |
47 | | - |
48 | | -// const replaceToLoggedInRouteForEmailOptedIn = |
49 | | -// isAuthenticated && |
50 | | -// user?.emailOptedIn === null && |
51 | | -// currentLocation?.path !== `/user-email`; |
52 | | -// const shouldReplaceRoute = |
53 | | -// replaceToLoggedInRoute || |
54 | | -// replaceToLoggedOutRoute || |
55 | | -// replaceToLoggedInRouteForEmailOptedIn; |
56 | | - |
57 | | -// if (shouldReplaceRoute) { |
58 | | -// timeout = setTimeout(() => { |
59 | | -// let route = routeToReplace(); |
60 | | -// if (user?.emailOptedIn === null) { |
61 | | -// route = `/user-email`; |
62 | | -// } |
63 | | -// console.log(currentLocation, 'currentLocation', routeFromSearchParam); |
64 | | - |
65 | | -// if (replaceToLoggedOutRoute && currentLocation) { |
66 | | -// route = `${route}?route=${currentLocation.path}`; |
67 | | -// } else if (replaceToLoggedInRoute && routeFromSearchParam) { |
68 | | -// route = routeFromSearchParam; |
69 | | -// } |
70 | | - |
71 | | -// replaceRoute(route); |
72 | | -// }, 0); |
73 | | -// } |
74 | | -// }; |
75 | | - |
76 | 1 | import { |
77 | 2 | RouteInterface, |
78 | 3 | RouteVisibilityAuthentication, |
79 | 4 | } from '../RouteVisibility'; |
80 | | -import { loggedOutRoute } from '../../constants'; |
| 5 | +import { loggedOutRoute, DEFAULT_PROJECT_NAME } from '../../constants'; |
| 6 | +import { routePaths } from '../routePaths'; |
81 | 7 |
|
82 | 8 | const isUnauthenticatedOrMissingRoute = ( |
83 | 9 | currentLocation: RouteInterface | undefined, |
@@ -117,7 +43,12 @@ export const replaceRouteIfNeeded = ({ |
117 | 43 | clearTimeout(timeout); |
118 | 44 |
|
119 | 45 | const routeToReplace = () => { |
120 | | - const logRoute = user?.emailOptedIn === null ? `/user-email` : '/'; |
| 46 | + // const url = window.location.search; |
| 47 | + const logRoute = |
| 48 | + user?.emailOptedIn === null |
| 49 | + ? `/user-email` |
| 50 | + : routePaths.home(DEFAULT_PROJECT_NAME); |
| 51 | + |
121 | 52 | return isAuthenticated ? logRoute : loggedOutRoute; |
122 | 53 | }; |
123 | 54 | const replaceToLoggedInRoute = |
|
0 commit comments