Skip to content

Commit 2196a54

Browse files
committed
router cleanup
1 parent ae8cd0a commit 2196a54

1 file changed

Lines changed: 1 addition & 71 deletions

File tree

src/app/router/Router.tsx

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
1-
import React, { useEffect } from 'react';
1+
import React from 'react';
22
import { Routes, Route } from 'react-router-dom';
3-
import { useRouter } from 'next/navigation';
4-
import SignIn from '../screens/SignIn';
5-
import SignUp from '../screens/SignUp';
6-
import Account from '../screens/Account';
7-
import ContactInformation from '../screens/ContactInformation';
8-
import { ProtectedRoute } from './ProtectedRoute';
9-
import CompleteRegistration from '../screens/CompleteRegistration';
10-
import ChangePassword from '../screens/ChangePassword';
113
import ForgotPassword from '../screens/ForgotPassword';
12-
import PostRegistration from '../screens/PostRegistration';
13-
import { SIGN_OUT_TARGET } from '../constants/Navigation';
14-
import {
15-
LOGIN_CHANNEL,
16-
LOGOUT_CHANNEL,
17-
createBroadcastChannel,
18-
} from '../services/channel-service';
19-
import { useAppDispatch } from '../hooks';
20-
import { logout } from '../store/profile-reducer';
214
import FeedSubmission from '../screens/FeedSubmission';
225
import FeedSubmitted from '../screens/FeedSubmitted';
236
import GTFSFeedAnalytics from '../screens/Analytics/GTFSFeedAnalytics';
@@ -28,61 +11,8 @@ import GBFSNoticeAnalytics from '../screens/Analytics/GBFSNoticeAnalytics';
2811
import GBFSVersionAnalytics from '../screens/Analytics/GBFSVersionAnalytics';
2912

3013
export const AppRouter: React.FC = () => {
31-
const router = useRouter();
32-
const dispatch = useAppDispatch();
33-
34-
/**
35-
* Logs out the user and redirects to the sign-out target screen after a logout event is received on the other sessions.
36-
*/
37-
const logoutUserCallback = (): void => {
38-
dispatch(
39-
logout({
40-
redirectScreen: SIGN_OUT_TARGET,
41-
navigateTo: (path) => {
42-
router.push(String(path));
43-
},
44-
propagate: false,
45-
}),
46-
);
47-
};
48-
49-
/**
50-
* Refreshes the page to ensure the user is authenticated after a login event is received on the other sessions.
51-
*/
52-
const loginUserCallback = (): void => {
53-
window.location.reload();
54-
};
55-
56-
/**
57-
* The channel creation is placed in this component rather than the App.tsx file due to the need of the navigateTo instance.
58-
* The navigateTo instance is only available within the scope the Router including its children.
59-
* The callback functions are used to handle the logout and login events received from other sessions.
60-
*/
61-
useEffect(() => {
62-
createBroadcastChannel(LOGOUT_CHANNEL, logoutUserCallback);
63-
createBroadcastChannel(LOGIN_CHANNEL, loginUserCallback);
64-
}, []);
65-
6614
return (
6715
<Routes>
68-
<Route path='sign-in' element={<SignIn />} />
69-
<Route path='sign-up' element={<SignUp />} />
70-
<Route element={<ProtectedRoute targetStatus='authenticated' />}>
71-
<Route
72-
path='complete-registration'
73-
element={<CompleteRegistration />}
74-
/>
75-
</Route>
76-
<Route element={<ProtectedRoute />}>
77-
<Route path='account' element={<Account />} />
78-
</Route>
79-
<Route path='contact-info' element={<ContactInformation />} />
80-
<Route element={<ProtectedRoute />}>
81-
<Route path='change-password' element={<ChangePassword />} />
82-
</Route>
83-
<Route element={<ProtectedRoute targetStatus='unverified' />}>
84-
<Route path='verify-email' element={<PostRegistration />} />
85-
</Route>
8616
<Route path='forgot-password' element={<ForgotPassword />} />
8717
<Route path='contribute' element={<FeedSubmission />} />
8818
<Route path='contribute/submitted' element={<FeedSubmitted />} />

0 commit comments

Comments
 (0)