diff --git a/App.tsx b/App.tsx index da8a0da..abd259e 100644 --- a/App.tsx +++ b/App.tsx @@ -50,6 +50,7 @@ import MainApp from './src/screens/MainApp'; import LoginProvider from './src/components/providers/LoginProvider'; import { retrieveLoginToken } from './src/utils/loginToken'; import { setupNotifications } from './src/utils/Notifications'; +import { TabRoutes } from './src/navigation/TabNavigator'; // Native optimizations https://reactnavigation.org/docs/react-native-screens // Crashes app when navigating away from webview on android 9+ @@ -76,11 +77,9 @@ type StateType = { }; export default class App extends React.Component<{}, StateType> { - navigatorRef: { current: null | NavigationContainerRef }; + navigatorRef: { current: null | NavigationContainerRef }; - defaultHomeRoute: string | undefined; - - defaultHomeData: { [key: string]: string } | undefined; + defaultData?: ParsedUrlDataType; urlHandler: URLHandler; @@ -97,8 +96,7 @@ export default class App extends React.Component<{}, StateType> { loginToken: undefined, }; this.navigatorRef = React.createRef(); - this.defaultHomeRoute = undefined; - this.defaultHomeData = undefined; + this.defaultData = undefined; this.urlHandler = new URLHandler(this.onInitialURLParsed, this.onDetectURL); this.urlHandler.listen(); setSafeBounceHeight(Platform.OS === 'ios' ? 100 : 20); @@ -112,8 +110,7 @@ export default class App extends React.Component<{}, StateType> { * @param parsedData The data parsed from the url */ onInitialURLParsed = (parsedData: ParsedUrlDataType) => { - this.defaultHomeRoute = parsedData.route; - this.defaultHomeData = parsedData.data; + this.defaultData = parsedData; }; /** @@ -126,9 +123,9 @@ export default class App extends React.Component<{}, StateType> { // Navigate to nested navigator and pass data to the index screen const nav = this.navigatorRef.current; if (nav != null) { - nav.navigate('home', { - screen: 'index', - params: { nextScreen: parsedData.route, data: parsedData.data }, + nav.navigate(TabRoutes.Home, { + nextScreen: parsedData.route, + data: parsedData.data, }); } }; @@ -213,8 +210,7 @@ export default class App extends React.Component<{}, StateType> { diff --git a/src/components/Amicale/Profile/ProfileClubCard.tsx b/src/components/Amicale/Profile/ProfileClubCard.tsx index efb7876..cf21d10 100644 --- a/src/components/Amicale/Profile/ProfileClubCard.tsx +++ b/src/components/Amicale/Profile/ProfileClubCard.tsx @@ -4,6 +4,7 @@ import i18n from 'i18n-js'; import { FlatList, StyleSheet } from 'react-native'; import { ProfileClubType } from '../../../screens/Amicale/ProfileScreen'; import { useNavigation } from '@react-navigation/core'; +import { MainRoutes } from '../../../navigation/MainNavigator'; type Props = { clubs?: Array; @@ -26,7 +27,10 @@ export default function ProfileClubCard(props: Props) { const getClubListItem = ({ item }: { item: ProfileClubType }) => { const onPress = () => - navigation.navigate('club-information', { clubId: item.id }); + navigation.navigate(MainRoutes.ClubInformation, { + type: 'id', + clubId: item.id, + }); let description = i18n.t('screens.profile.isMember'); let icon = (leftProps: { color: string; diff --git a/src/components/Amicale/Profile/ProfilePersonalCard.tsx b/src/components/Amicale/Profile/ProfilePersonalCard.tsx index 2c8f3b6..96cf9d8 100644 --- a/src/components/Amicale/Profile/ProfilePersonalCard.tsx +++ b/src/components/Amicale/Profile/ProfilePersonalCard.tsx @@ -12,6 +12,7 @@ import { import Urls from '../../../constants/Urls'; import { ProfileDataType } from '../../../screens/Amicale/ProfileScreen'; import i18n from 'i18n-js'; +import { MainRoutes } from '../../../navigation/MainNavigator'; type Props = { profile?: ProfileDataType; @@ -93,7 +94,7 @@ export default function ProfilePersonalCard(props: Props) { icon="account-edit" mode="contained" onPress={() => { - navigation.navigate('website', { + navigation.navigate(MainRoutes.Website, { host: Urls.websites.amicale, path: profile?.link, title: i18n.t('screens.websites.amicale'), diff --git a/src/components/Amicale/Profile/ProfileWelcomeCard.tsx b/src/components/Amicale/Profile/ProfileWelcomeCard.tsx index 66e413b..45aa12c 100644 --- a/src/components/Amicale/Profile/ProfileWelcomeCard.tsx +++ b/src/components/Amicale/Profile/ProfileWelcomeCard.tsx @@ -6,6 +6,7 @@ import i18n from 'i18n-js'; import { StyleSheet } from 'react-native'; import CardList from '../../Lists/CardList/CardList'; import { getAmicaleServices, SERVICES_KEY } from '../../../utils/Services'; +import { MainRoutes } from '../../../navigation/MainNavigator'; type Props = { firstname?: string; @@ -51,9 +52,11 @@ function ProfileWelcomeCard(props: Props) { {i18n.t('screens.profile.welcomeDescription')} navigation.navigate(route), + true, + [SERVICES_KEY.PROFILE] + )} isHorizontal={true} /> {i18n.t('screens.profile.welcomeFeedback')} @@ -63,7 +66,7 @@ function ProfileWelcomeCard(props: Props) { icon="bug" mode="contained" onPress={() => { - navigation.navigate('feedback'); + navigation.navigate(MainRoutes.Feedback); }} style={styles.editButton} > diff --git a/src/components/Animations/PlanexBottomBar.tsx b/src/components/Animations/PlanexBottomBar.tsx index e239cb9..edaca99 100644 --- a/src/components/Animations/PlanexBottomBar.tsx +++ b/src/components/Animations/PlanexBottomBar.tsx @@ -24,6 +24,7 @@ import * as Animatable from 'react-native-animatable'; import { TAB_BAR_HEIGHT } from '../Tabbar/CustomTabBar'; import { useNavigation } from '@react-navigation/core'; import { useCollapsible } from '../../context/CollapsibleContext'; +import { MainRoutes } from '../../navigation/MainNavigator'; type Props = { onPress: (action: string, data?: string) => void; @@ -138,7 +139,7 @@ function PlanexBottomBar(props: Props) { > navigation.navigate('group-select')} + onPress={() => navigation.navigate(MainRoutes.GroupSelect)} /> diff --git a/src/components/Home/ActionsDashboardItem.tsx b/src/components/Home/ActionsDashboardItem.tsx index 158464d..a707425 100644 --- a/src/components/Home/ActionsDashboardItem.tsx +++ b/src/components/Home/ActionsDashboardItem.tsx @@ -22,6 +22,7 @@ import { List } from 'react-native-paper'; import { StyleSheet, View } from 'react-native'; import i18n from 'i18n-js'; import { useNavigation } from '@react-navigation/native'; +import { MainRoutes } from '../../navigation/MainNavigator'; const styles = StyleSheet.create({ item: { @@ -53,7 +54,7 @@ function ActionsDashBoardItem() { icon="chevron-right" /> )} - onPress={(): void => navigation.navigate('feedback')} + onPress={(): void => navigation.navigate(MainRoutes.Feedback)} style={styles.item} /> diff --git a/src/components/Home/FeedItem.tsx b/src/components/Home/FeedItem.tsx index bbd1147..2ba00ab 100644 --- a/src/components/Home/FeedItem.tsx +++ b/src/components/Home/FeedItem.tsx @@ -30,6 +30,7 @@ import type { NewsSourceType } from '../../constants/NewsSourcesConstants'; import ImageGalleryButton from '../Media/ImageGalleryButton'; import { useNavigation } from '@react-navigation/native'; import GENERAL_STYLES from '../../constants/Styles'; +import { MainRoutes } from '../../navigation/MainNavigator'; type PropsType = { item: FeedItemType; @@ -67,7 +68,7 @@ const styles = StyleSheet.create({ function FeedItem(props: PropsType) { const navigation = useNavigation(); const onPress = () => { - navigation.navigate('feed-information', { + navigation.navigate(MainRoutes.FeedInformation, { data: item, date: getFormattedDate(props.item.time), }); diff --git a/src/components/Lists/Equipment/EquipmentListItem.tsx b/src/components/Lists/Equipment/EquipmentListItem.tsx index 9797643..fb77d7f 100644 --- a/src/components/Lists/Equipment/EquipmentListItem.tsx +++ b/src/components/Lists/Equipment/EquipmentListItem.tsx @@ -29,6 +29,7 @@ import { import { StyleSheet } from 'react-native'; import GENERAL_STYLES from '../../../constants/Styles'; import { useNavigation } from '@react-navigation/native'; +import { MainRoutes } from '../../../navigation/MainNavigator'; type PropsType = { userDeviceRentDates: [string, string] | null; @@ -56,14 +57,14 @@ function EquipmentListItem(props: PropsType) { let onPress; if (isRented) { onPress = () => { - navigation.navigate('equipment-confirm', { + navigation.navigate(MainRoutes.EquipmentConfirm, { item, dates: userDeviceRentDates, }); }; } else { onPress = () => { - navigation.navigate('equipment-rent', { item }); + navigation.navigate(MainRoutes.EquipmentRent, { item }); }; } diff --git a/src/components/Media/ImageGalleryButton.tsx b/src/components/Media/ImageGalleryButton.tsx index f840689..d8dc3a6 100644 --- a/src/components/Media/ImageGalleryButton.tsx +++ b/src/components/Media/ImageGalleryButton.tsx @@ -22,6 +22,7 @@ import { TouchableRipple } from 'react-native-paper'; import { Image } from 'react-native-animatable'; import { useNavigation } from '@react-navigation/native'; import { StyleSheet, ViewStyle } from 'react-native'; +import { MainRoutes } from '../../navigation/MainNavigator'; type PropsType = { images: Array<{ url: string }>; @@ -39,7 +40,7 @@ function ImageGalleryButton(props: PropsType) { const navigation = useNavigation(); const onPress = () => { - navigation.navigate('gallery', { images: props.images }); + navigation.navigate(MainRoutes.Gallery, { images: props.images }); }; return ( diff --git a/src/constants/Urls.tsx b/src/constants/Urls.tsx index 10a9480..34fa1a5 100644 --- a/src/constants/Urls.tsx +++ b/src/constants/Urls.tsx @@ -30,7 +30,8 @@ const PROXIMO_ENDPOINT = STUDENT_SERVER + '~proximo/v2/api/'; const PROXIMO_IMAGES_ENDPOINT = STUDENT_SERVER + '~proximo/api_proximo/storage/app/public/'; const APP_IMAGES_ENDPOINT = STUDENT_SERVER + '~amicale_app/images/'; -const PROXIWASH_ENDPOINT = 'https://www.proxiwash.com/weblaverie/ma-laverie-2?s='; +const PROXIWASH_ENDPOINT = + 'https://www.proxiwash.com/weblaverie/ma-laverie-2?s='; export default { amicale: { diff --git a/src/context/preferencesContext.tsx b/src/context/preferencesContext.tsx index 4916c50..15c19d1 100644 --- a/src/context/preferencesContext.tsx +++ b/src/context/preferencesContext.tsx @@ -147,10 +147,10 @@ export function useCurrentDashboard() { }; const allDatasets = [ - ...getAmicaleServices(navigation.navigate, isLoggedIn), - ...getStudentServices(navigation.navigate), - ...getINSAServices(navigation.navigate), - ...getSpecialServices(navigation.navigate), + ...getAmicaleServices((route) => navigation.navigate(route), isLoggedIn), + ...getStudentServices((route) => navigation.navigate(route)), + ...getINSAServices((route) => navigation.navigate(route)), + ...getSpecialServices((route) => navigation.navigate(route)), ]; return { currentDashboard: allDatasets.filter((item) => diff --git a/src/navigation/MainNavigator.tsx b/src/navigation/MainNavigator.tsx index cba437c..6a2cc1b 100644 --- a/src/navigation/MainNavigator.tsx +++ b/src/navigation/MainNavigator.tsx @@ -24,7 +24,7 @@ import SettingsScreen from '../screens/Other/Settings/SettingsScreen'; import AboutScreen from '../screens/About/AboutScreen'; import AboutDependenciesScreen from '../screens/About/AboutDependenciesScreen'; import DebugScreen from '../screens/About/DebugScreen'; -import TabNavigator from './TabNavigator'; +import TabNavigator, { TabRoutes } from './TabNavigator'; import GameMainScreen from '../screens/Game/screens/GameMainScreen'; import VoteScreen from '../screens/Amicale/VoteScreen'; import LoginScreen from '../screens/Amicale/LoginScreen'; @@ -33,7 +33,10 @@ import ProximoMainScreen from '../screens/Services/Proximo/ProximoMainScreen'; import ProximoListScreen from '../screens/Services/Proximo/ProximoListScreen'; import ProximoAboutScreen from '../screens/Services/Proximo/ProximoAboutScreen'; import ProfileScreen from '../screens/Amicale/ProfileScreen'; -import ClubListScreen from '../screens/Amicale/Clubs/ClubListScreen'; +import ClubListScreen, { + ClubCategoryType, + ClubType, +} from '../screens/Amicale/Clubs/ClubListScreen'; import ClubAboutScreen from '../screens/Amicale/Clubs/ClubAboutScreen'; import ClubDisplayScreen from '../screens/Amicale/Clubs/ClubDisplayScreen'; import BugReportScreen from '../screens/Other/FeedbackScreen'; @@ -60,6 +63,10 @@ import FeedItemScreen from '../screens/Home/FeedItemScreen'; import GroupSelectionScreen from '../screens/Planex/GroupSelectionScreen'; import ServicesSectionScreen from '../screens/Services/ServicesSectionScreen'; import AmicaleContactScreen from '../screens/Amicale/AmicaleContactScreen'; +import { FeedItemType } from '../screens/Home/HomeScreen'; +import { PlanningEventType } from '../utils/Planning'; +import { ServiceCategoryType } from '../utils/Services'; +import { ParsedUrlDataType } from '../utils/URLHandler'; export enum MainRoutes { Main = 'main', @@ -77,6 +84,7 @@ export enum MainRoutes { Proximo = 'proximo', ProximoList = 'proximo-list', ProximoAbout = 'proximo-about', + ProxiwashAbout = 'proxiwash-about', Profile = 'profile', ClubList = 'club-list', ClubInformation = 'club-information', @@ -87,28 +95,72 @@ export enum MainRoutes { Vote = 'vote', Feedback = 'feedback', Website = 'website', + PlanningInformation = 'planning-information', + Scanner = 'scanner', + FeedInformation = 'feed-information', + GroupSelect = 'group-select', + ServicesSection = 'services-section', + AmicaleContact = 'amicale-contact', } -type DefaultParams = { [key in MainRoutes]: object | undefined }; +type DefaultParams = { [key in MainRoutes]: object | undefined } & { + [key in TabRoutes]: object | undefined; +}; -export type FullParamsList = DefaultParams & { - 'login': { nextScreen: string }; - 'equipment-confirm': { +export type MainStackParamsList = DefaultParams & { + [MainRoutes.Login]: { nextScreen: string }; + [MainRoutes.EquipmentConfirm]: { item?: DeviceType; dates: [string, string]; }; - 'equipment-rent': { item?: DeviceType }; - 'gallery': { images: Array<{ url: string }> }; + [MainRoutes.EquipmentRent]: { item?: DeviceType }; + [MainRoutes.Gallery]: { images: Array<{ url: string }> }; [MainRoutes.ProximoList]: { shouldFocusSearchBar: boolean; category: number; }; + [MainRoutes.ClubInformation]: ClubInformationScreenParams; + [MainRoutes.Website]: { + host: string; + path?: string; + title: string; + }; + [MainRoutes.FeedInformation]: { + data: FeedItemType; + date: string; + }; + [MainRoutes.PlanningInformation]: PlanningInformationScreenParams; + [MainRoutes.ServicesSection]: { + data: ServiceCategoryType; + }; }; -// Don't know why but TS is complaining without this -// See: https://stackoverflow.com/questions/63652687/interface-does-not-satisfy-the-constraint-recordstring-object-undefined -export type MainStackParamsList = FullParamsList & - Record; +export type ClubInformationScreenParams = + | { + type: 'full'; + data: ClubType; + categories: Array; + } + | { + type: 'id'; + clubId: number; + }; + +export type PlanningInformationScreenParams = + | { + type: 'full'; + data: PlanningEventType; + } + | { + type: 'id'; + eventId: number; + }; + +declare global { + namespace ReactNavigation { + interface RootParamList extends MainStackParamsList {} + } +} const MainStack = createStackNavigator(); @@ -312,41 +364,41 @@ function getRegularScreens(createTabNavigator: () => React.ReactElement) { }} /> @@ -363,7 +415,9 @@ function MainStackComponent(props: { return ( {showIntro ? getIntroScreens() : getRegularScreens(createTabNavigator)} {isloggedIn ? getAmicaleScreens() : null} @@ -372,8 +426,7 @@ function MainStackComponent(props: { } type PropsType = { - defaultHomeRoute?: string; - defaultHomeData?: { [key: string]: string }; + defaultData?: ParsedUrlDataType; }; function MainNavigator(props: PropsType) { @@ -395,7 +448,5 @@ function MainNavigator(props: PropsType) { export default React.memo( MainNavigator, - (pp: PropsType, np: PropsType) => - pp.defaultHomeRoute === np.defaultHomeRoute && - pp.defaultHomeData === np.defaultHomeData + (pp: PropsType, np: PropsType) => pp.defaultData === np.defaultData ); diff --git a/src/navigation/TabNavigator.tsx b/src/navigation/TabNavigator.tsx index b7923bc..ef85a73 100644 --- a/src/navigation/TabNavigator.tsx +++ b/src/navigation/TabNavigator.tsx @@ -36,6 +36,7 @@ import { getPreferenceString, GeneralPreferenceKeys, } from '../utils/asyncStorage'; +import { ParsedUrlDataType } from '../utils/URLHandler'; const styles = StyleSheet.create({ header: { @@ -51,25 +52,24 @@ const styles = StyleSheet.create({ }, }); +export enum TabRoutes { + Services = 'services', + Proxiwash = 'proxiwash', + Home = 'home', + Planning = 'events', + Planex = 'planex', +} + type DefaultParams = { [key in TabRoutes]: object | undefined }; -export type FullParamsList = DefaultParams & { - [TabRoutes.Home]: { - nextScreen: string; - data: Record; - }; +export type TabStackParamsList = DefaultParams & { + [TabRoutes.Home]: ParsedUrlDataType; }; -// Don't know why but TS is complaining without this -// See: https://stackoverflow.com/questions/63652687/interface-does-not-satisfy-the-constraint-recordstring-object-undefined -export type TabStackParamsList = FullParamsList & - Record; - const Tab = createBottomTabNavigator(); type PropsType = { - defaultHomeRoute?: string; - defaultHomeData?: { [key: string]: string }; + defaultData?: ParsedUrlDataType; }; const ICONS: { @@ -111,15 +111,6 @@ function TabNavigator(props: PropsType) { } else { defaultRoute = defaultRoute.toLowerCase(); } - - let params; - if (props.defaultHomeRoute) { - params = { - data: props.defaultHomeData, - nextScreen: props.defaultHomeRoute, - shouldOpen: true, - }; - } const { colors } = useTheme(); const LABELS: { @@ -133,23 +124,23 @@ function TabNavigator(props: PropsType) { }; return ( ( )} > ), }} - initialParams={params} + initialParams={props.defaultData} /> - pp.defaultHomeRoute === np.defaultHomeRoute && - pp.defaultHomeData === np.defaultHomeData + (pp: PropsType, np: PropsType) => pp.defaultData === np.defaultData ); - -export enum TabRoutes { - Services = 'services', - Proxiwash = 'proxiwash', - Home = 'home', - Planning = 'events', - Planex = 'planex', -} diff --git a/src/screens/About/AboutScreen.tsx b/src/screens/About/AboutScreen.tsx index be9efbd..8ec04bb 100644 --- a/src/screens/About/AboutScreen.tsx +++ b/src/screens/About/AboutScreen.tsx @@ -35,6 +35,7 @@ import OptionsDialog from '../../components/Dialogs/OptionsDialog'; import type { OptionsDialogButtonType } from '../../components/Dialogs/OptionsDialog'; import GENERAL_STYLES from '../../constants/Styles'; import Urls from '../../constants/Urls'; +import { MainRoutes } from '../../navigation/MainNavigator'; const APP_LOGO = require('../../../assets/android.icon.round.png'); @@ -179,7 +180,7 @@ class AboutScreen extends React.Component { { onPressCallback: () => { const { navigation } = this.props; - navigation.navigate('feedback'); + navigation.navigate(MainRoutes.Feedback); }, icon: 'bug', text: i18n.t('screens.feedback.homeButtonTitle'), @@ -236,7 +237,7 @@ class AboutScreen extends React.Component { { onPressCallback: () => { const { navigation } = this.props; - navigation.navigate('dependencies'); + navigation.navigate(MainRoutes.Dependencies); }, icon: 'developer-board', text: i18n.t('screens.about.libs'), @@ -275,7 +276,7 @@ class AboutScreen extends React.Component { { onPressCallback: () => { const { navigation } = this.props; - navigation.navigate('feedback'); + navigation.navigate(MainRoutes.Feedback); }, icon: 'hand-pointing-right', text: i18n.t('screens.about.user.you'), diff --git a/src/screens/Amicale/Clubs/ClubDisplayScreen.tsx b/src/screens/Amicale/Clubs/ClubDisplayScreen.tsx index 6dcb770..e736230 100644 --- a/src/screens/Amicale/Clubs/ClubDisplayScreen.tsx +++ b/src/screens/Amicale/Clubs/ClubDisplayScreen.tsx @@ -38,16 +38,13 @@ import { useFocusEffect } from '@react-navigation/core'; import { useCallback } from 'react'; import { useNavigation } from '@react-navigation/native'; import { useAuthenticatedRequest } from '../../../context/loginContext'; +import { StackScreenProps } from '@react-navigation/stack'; +import { + MainRoutes, + MainStackParamsList, +} from '../../../navigation/MainNavigator'; -type Props = { - route: { - params?: { - data?: ClubType; - categories?: Array; - clubId?: number; - }; - }; -}; +type Props = StackScreenProps; type ResponseType = ClubType; @@ -94,18 +91,19 @@ function ClubDisplayScreen(props: Props) { const theme = useTheme(); const [displayData, setDisplayData] = useState(); - const [categories, setCategories] = - useState | undefined>(); + const [categories, setCategories] = useState< + Array | undefined + >(); const [clubId, setClubId] = useState(); useFocusEffect( useCallback(() => { - if (props.route.params?.data && props.route.params?.categories) { + if (props.route.params.type === 'full') { setDisplayData(props.route.params.data); setCategories(props.route.params.categories); setClubId(props.route.params.data.id); } else { - const id = props.route.params?.clubId; + const id = props.route.params.clubId; setClubId(id ? id : 0); } }, [props.route.params]) diff --git a/src/screens/Amicale/Clubs/ClubListScreen.tsx b/src/screens/Amicale/Clubs/ClubListScreen.tsx index e20c934..260ad1b 100644 --- a/src/screens/Amicale/Clubs/ClubListScreen.tsx +++ b/src/screens/Amicale/Clubs/ClubListScreen.tsx @@ -33,6 +33,7 @@ import MaterialHeaderButtons, { import WebSectionList from '../../../components/Screens/WebSectionList'; import { useNavigation } from '@react-navigation/native'; import { useAuthenticatedRequest } from '../../../context/loginContext'; +import { MainRoutes } from '../../../navigation/MainNavigator'; export type ClubCategoryType = { id: number; @@ -80,7 +81,7 @@ function ClubListScreen() { navigation.navigate('club-about')} + onPress={() => navigation.navigate(MainRoutes.ClubAbout)} /> ); @@ -108,7 +109,8 @@ function ClubListScreen() { * @param item The article pressed */ const onListItemPress = (item: ClubType) => { - navigation.navigate('club-information', { + navigation.navigate(MainRoutes.ClubInformation, { + type: 'full', data: item, categories: categories.current, }); diff --git a/src/screens/Amicale/Equipment/EquipmentConfirmScreen.tsx b/src/screens/Amicale/Equipment/EquipmentConfirmScreen.tsx index a7e4e87..9bcb8eb 100644 --- a/src/screens/Amicale/Equipment/EquipmentConfirmScreen.tsx +++ b/src/screens/Amicale/Equipment/EquipmentConfirmScreen.tsx @@ -31,12 +31,15 @@ import i18n from 'i18n-js'; import { getRelativeDateString } from '../../../utils/EquipmentBooking'; import CollapsibleScrollView from '../../../components/Collapsible/CollapsibleScrollView'; import { StackScreenProps } from '@react-navigation/stack'; -import { MainStackParamsList } from '../../../navigation/MainNavigator'; +import { + MainRoutes, + MainStackParamsList, +} from '../../../navigation/MainNavigator'; import GENERAL_STYLES from '../../../constants/Styles'; type EquipmentConfirmScreenNavigationProp = StackScreenProps< MainStackParamsList, - 'equipment-confirm' + MainRoutes.EquipmentConfirm >; type Props = EquipmentConfirmScreenNavigationProp; diff --git a/src/screens/Amicale/Equipment/EquipmentListScreen.tsx b/src/screens/Amicale/Equipment/EquipmentListScreen.tsx index f83949c..52448b2 100644 --- a/src/screens/Amicale/Equipment/EquipmentListScreen.tsx +++ b/src/screens/Amicale/Equipment/EquipmentListScreen.tsx @@ -60,15 +60,15 @@ const styles = StyleSheet.create({ function EquipmentListScreen() { const userRents = useRef>(); - const [mascotDialogVisible, setMascotDialogVisible] = - useState(undefined); + const [mascotDialogVisible, setMascotDialogVisible] = useState< + undefined | boolean + >(undefined); const requestAll = useAuthenticatedRequest<{ devices: Array }>('location/all'); - const requestOwn = - useAuthenticatedRequest<{ - locations: Array; - }>('location/my'); + const requestOwn = useAuthenticatedRequest<{ + locations: Array; + }>('location/my'); const getRenderItem = ({ item }: { item: DeviceType }) => { return ( diff --git a/src/screens/Amicale/Equipment/EquipmentRentScreen.tsx b/src/screens/Amicale/Equipment/EquipmentRentScreen.tsx index d2f119c..a16fb53 100644 --- a/src/screens/Amicale/Equipment/EquipmentRentScreen.tsx +++ b/src/screens/Amicale/Equipment/EquipmentRentScreen.tsx @@ -42,7 +42,10 @@ import { isEquipmentAvailable, } from '../../../utils/EquipmentBooking'; import CollapsibleScrollView from '../../../components/Collapsible/CollapsibleScrollView'; -import { MainStackParamsList } from '../../../navigation/MainNavigator'; +import { + MainRoutes, + MainStackParamsList, +} from '../../../navigation/MainNavigator'; import GENERAL_STYLES from '../../../constants/Styles'; import { ApiRejectType } from '../../../utils/WebData'; import { REQUEST_STATUS } from '../../../utils/Requests'; @@ -50,7 +53,7 @@ import { useFocusEffect } from '@react-navigation/core'; import { useNavigation } from '@react-navigation/native'; import { useAuthenticatedRequest } from '../../../context/loginContext'; -type Props = StackScreenProps; +type Props = StackScreenProps; export type MarkedDatesObjectType = { [key: string]: PeriodMarking; diff --git a/src/screens/Amicale/LoginScreen.tsx b/src/screens/Amicale/LoginScreen.tsx index 146d6d7..5b958b0 100644 --- a/src/screens/Amicale/LoginScreen.tsx +++ b/src/screens/Amicale/LoginScreen.tsx @@ -26,7 +26,10 @@ import ErrorDialog from '../../components/Dialogs/ErrorDialog'; import { MASCOT_STYLE } from '../../components/Mascot/Mascot'; import MascotPopup from '../../components/Mascot/MascotPopup'; import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView'; -import { MainStackParamsList } from '../../navigation/MainNavigator'; +import { + MainRoutes, + MainStackParamsList, +} from '../../navigation/MainNavigator'; import GENERAL_STYLES from '../../constants/Styles'; import Urls from '../../constants/Urls'; import { ApiRejectType, connectToAmicale } from '../../utils/WebData'; @@ -37,15 +40,16 @@ import { TabRoutes } from '../../navigation/TabNavigator'; import { useShouldShowMascot } from '../../context/preferencesContext'; import { useLogin } from '../../context/loginContext'; -type Props = StackScreenProps; +type Props = StackScreenProps; function LoginScreen(props: Props) { const navigation = useNavigation>(); const { setLogin } = useLogin(); const [loading, setLoading] = useState(false); const [nextScreen, setNextScreen] = useState(undefined); - const [mascotDialogVisible, setMascotDialogVisible] = - useState(undefined); + const [mascotDialogVisible, setMascotDialogVisible] = useState< + undefined | boolean + >(undefined); const [currentError, setCurrentError] = useState({ status: REQUEST_STATUS.SUCCESS, }); @@ -58,7 +62,7 @@ function LoginScreen(props: Props) { ); const onResetPasswordClick = () => { - navigation.navigate('website', { + navigation.navigate(MainRoutes.Website, { host: Urls.websites.amicale, path: Urls.amicale.resetPassword, title: i18n.t('screens.websites.amicale'), diff --git a/src/screens/Amicale/VoteScreen.tsx b/src/screens/Amicale/VoteScreen.tsx index 9ea3cb4..0f65889 100644 --- a/src/screens/Amicale/VoteScreen.tsx +++ b/src/screens/Amicale/VoteScreen.tsx @@ -133,8 +133,9 @@ const styles = StyleSheet.create({ */ export default function VoteScreen() { const [hasVoted, setHasVoted] = useState(false); - const [mascotDialogVisible, setMascotDialogVisible] = - useState(undefined); + const [mascotDialogVisible, setMascotDialogVisible] = useState< + undefined | boolean + >(undefined); const datesRequest = useAuthenticatedRequest('elections/dates'); diff --git a/src/screens/Game/screens/GameMainScreen.tsx b/src/screens/Game/screens/GameMainScreen.tsx index d25e3b9..f21c31d 100644 --- a/src/screens/Game/screens/GameMainScreen.tsx +++ b/src/screens/Game/screens/GameMainScreen.tsx @@ -79,13 +79,12 @@ export default function GameMainScreen() { gameLevel: 0, }); - const [dialogContent, setDialogContent] = - useState<{ - dialogTitle: string; - dialogMessage: string; - dialogButtons: Array; - onDialogDismiss: () => void; - }>(); + const [dialogContent, setDialogContent] = useState<{ + dialogTitle: string; + dialogMessage: string; + dialogButtons: Array; + onDialogDismiss: () => void; + }>(); const { preferences, updatePreferences } = usePreferences(); diff --git a/src/screens/Home/FeedItemScreen.tsx b/src/screens/Home/FeedItemScreen.tsx index 02b2cc1..6dc13cf 100644 --- a/src/screens/Home/FeedItemScreen.tsx +++ b/src/screens/Home/FeedItemScreen.tsx @@ -21,7 +21,7 @@ import * as React from 'react'; import { Linking, Image, StyleSheet } from 'react-native'; import { Card, Text } from 'react-native-paper'; import Autolink from 'react-native-autolink'; -import { StackNavigationProp } from '@react-navigation/stack'; +import { StackScreenProps } from '@react-navigation/stack'; import MaterialHeaderButtons, { Item, } from '../../components/Overrides/CustomHeaderButton'; @@ -33,11 +33,15 @@ import NewsSourcesConstants, { AvailablePages, } from '../../constants/NewsSourcesConstants'; import type { NewsSourceType } from '../../constants/NewsSourcesConstants'; +import { + MainRoutes, + MainStackParamsList, +} from '../../navigation/MainNavigator'; -type PropsType = { - navigation: StackNavigationProp; - route: { params: { data: FeedItemType; date: string } }; -}; +type PropsType = StackScreenProps< + MainStackParamsList, + MainRoutes.FeedInformation +>; const styles = StyleSheet.create({ container: { diff --git a/src/screens/Home/HomeScreen.tsx b/src/screens/Home/HomeScreen.tsx index c129034..b230949 100644 --- a/src/screens/Home/HomeScreen.tsx +++ b/src/screens/Home/HomeScreen.tsx @@ -154,7 +154,7 @@ function HomeScreen(props: Props) { useLayoutEffect(() => { const getHeaderButton = () => { let onPressLog = () => - navigation.navigate('login', { nextScreen: 'profile' }); + navigation.navigate(MainRoutes.Login, { nextScreen: 'profile' }); let logIcon = 'login'; let logColor = theme.colors.primary; if (isLoggedIn) { @@ -190,8 +190,8 @@ function HomeScreen(props: Props) { const handleNavigationParams = () => { const { route } = props; if (route.params != null) { - if (route.params.nextScreen != null) { - navigation.navigate(route.params.nextScreen, route.params.data); + if (route.params.route != null) { + navigation.navigate(route.params.route, route.params.data); // reset params to prevent infinite loop navigation.dispatch(CommonActions.setParams({ nextScreen: null })); } @@ -328,7 +328,7 @@ function HomeScreen(props: Props) { const hideDisconnectDialog = () => setDialogVisible(false); - const openScanner = () => navigation.navigate('scanner'); + const openScanner = () => navigation.navigate(MainRoutes.Scanner); /** * Creates the dataset to be used in the FlatList diff --git a/src/screens/MainApp.tsx b/src/screens/MainApp.tsx index 2807a04..72cbdee 100644 --- a/src/screens/MainApp.tsx +++ b/src/screens/MainApp.tsx @@ -13,13 +13,13 @@ import { Platform, SafeAreaView, View } from 'react-native'; import { useDarkTheme } from '../context/preferencesContext'; import { CustomDarkTheme, CustomWhiteTheme } from '../utils/Themes'; import { setupStatusBar } from '../utils/Utils'; +import { ParsedUrlDataType } from '../utils/URLHandler'; type Props = { - defaultHomeRoute?: string; - defaultHomeData?: { [key: string]: string }; + defaultData?: ParsedUrlDataType; }; -function MainApp(props: Props, ref?: Ref) { +function MainApp(props: Props, ref?: Ref>) { const darkTheme = useDarkTheme(); const theme = darkTheme ? CustomDarkTheme : CustomWhiteTheme; @@ -44,10 +44,7 @@ function MainApp(props: Props, ref?: Ref) { > - + diff --git a/src/screens/Media/ImageGalleryScreen.tsx b/src/screens/Media/ImageGalleryScreen.tsx index 13789c8..9889468 100644 --- a/src/screens/Media/ImageGalleryScreen.tsx +++ b/src/screens/Media/ImageGalleryScreen.tsx @@ -23,11 +23,14 @@ import ImageViewer from 'react-native-image-zoom-viewer'; import { StackNavigationProp, StackScreenProps } from '@react-navigation/stack'; import * as Animatable from 'react-native-animatable'; import { StyleSheet, View } from 'react-native'; -import { MainStackParamsList } from '../../navigation/MainNavigator'; +import { + MainRoutes, + MainStackParamsList, +} from '../../navigation/MainNavigator'; type ImageGalleryScreenNavigationProp = StackScreenProps< MainStackParamsList, - 'gallery' + MainRoutes.Gallery >; type Props = ImageGalleryScreenNavigationProp & { diff --git a/src/screens/Other/Settings/DashboardEditScreen.tsx b/src/screens/Other/Settings/DashboardEditScreen.tsx index 76c7dce..cd9ecad 100644 --- a/src/screens/Other/Settings/DashboardEditScreen.tsx +++ b/src/screens/Other/Settings/DashboardEditScreen.tsx @@ -149,6 +149,7 @@ function DashboardEditScreen() { return ( {getStartScreenPicker()} {getNavigateItem( - 'dashboard-edit', + MainRoutes.DashboardEdit, 'view-dashboard', i18n.t('screens.settings.dashboard'), i18n.t('screens.settings.dashboardSub') @@ -328,21 +329,21 @@ function SettingsScreen() { {isDebugUnlocked ? getNavigateItem( - 'debug', + MainRoutes.Debug, 'bug-check', i18n.t('screens.debug.title'), '' ) : null} {getNavigateItem( - 'about', + MainRoutes.About, 'information', i18n.t('screens.about.title'), i18n.t('screens.about.buttonDesc'), unlockDebugMode )} {getNavigateItem( - 'feedback', + MainRoutes.Feedback, 'comment-quote', i18n.t('screens.feedback.homeButtonTitle'), i18n.t('screens.feedback.homeButtonSubtitle') diff --git a/src/screens/Planex/PlanexScreen.tsx b/src/screens/Planex/PlanexScreen.tsx index 06a49e3..32bd146 100644 --- a/src/screens/Planex/PlanexScreen.tsx +++ b/src/screens/Planex/PlanexScreen.tsx @@ -42,6 +42,7 @@ import { } from '../../utils/asyncStorage'; import { usePlanexPreferences } from '../../context/preferencesContext'; import BasicLoadingScreen from '../../components/Screens/BasicLoadingScreen'; +import { MainRoutes } from '../../navigation/MainNavigator'; const styles = StyleSheet.create({ container: { @@ -59,15 +60,14 @@ function PlanexScreen() { const theme = useTheme(); const { preferences } = usePlanexPreferences(); - const [dialogContent, setDialogContent] = - useState< - | undefined - | { - title: string | React.ReactElement; - message: string | React.ReactElement; - color: string; - } - >(); + const [dialogContent, setDialogContent] = useState< + | undefined + | { + title: string | React.ReactElement; + message: string | React.ReactElement; + color: string; + } + >(); const [injectJS, setInjectJS] = useState(''); const [loading, setLoading] = useState(true); @@ -106,7 +106,7 @@ function PlanexScreen() { * Callback used when the user clicks on the navigate to settings button. * This will hide the banner and open the SettingsScreen */ - const onGoToSettings = () => navigation.navigate('settings'); + const onGoToSettings = () => navigation.navigate(MainRoutes.Settings); /** * Sends a FullCalendar action to the web page inside the webview. diff --git a/src/screens/Planning/PlanningDisplayScreen.tsx b/src/screens/Planning/PlanningDisplayScreen.tsx index 8e1ea4b..0eee991 100644 --- a/src/screens/Planning/PlanningDisplayScreen.tsx +++ b/src/screens/Planning/PlanningDisplayScreen.tsx @@ -21,7 +21,7 @@ import * as React from 'react'; import { StyleSheet, View } from 'react-native'; import { Card } from 'react-native-paper'; import i18n from 'i18n-js'; -import { StackNavigationProp } from '@react-navigation/stack'; +import { StackScreenProps } from '@react-navigation/stack'; import { getDateOnlyString, getTimeOnlyString } from '../../utils/Planning'; import DateManager from '../../managers/DateManager'; import BasicLoadingScreen from '../../components/Screens/BasicLoadingScreen'; @@ -33,11 +33,15 @@ import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrol import type { PlanningEventType } from '../../utils/Planning'; import ImageGalleryButton from '../../components/Media/ImageGalleryButton'; import { API_REQUEST_CODES, REQUEST_STATUS } from '../../utils/Requests'; +import { + MainRoutes, + MainStackParamsList, +} from '../../navigation/MainNavigator'; -type PropsType = { - navigation: StackNavigationProp; - route: { params: { data: PlanningEventType; id: number; eventId: number } }; -}; +type PropsType = StackScreenProps< + MainStackParamsList, + MainRoutes.PlanningInformation +>; type StateType = { loading: boolean; @@ -78,7 +82,7 @@ class PlanningDisplayScreen extends React.Component { constructor(props: PropsType) { super(props); - if (props.route.params.data != null) { + if (props.route.params.type === 'full') { this.displayData = props.route.params.data; this.eventId = this.displayData.id; this.shouldFetchData = false; diff --git a/src/screens/Planning/PlanningScreen.tsx b/src/screens/Planning/PlanningScreen.tsx index 92b2a8f..6bc74e3 100644 --- a/src/screens/Planning/PlanningScreen.tsx +++ b/src/screens/Planning/PlanningScreen.tsx @@ -36,6 +36,7 @@ import { MASCOT_STYLE } from '../../components/Mascot/Mascot'; import MascotPopup from '../../components/Mascot/MascotPopup'; import GENERAL_STYLES from '../../constants/Styles'; import Urls from '../../constants/Urls'; +import { MainRoutes } from '../../navigation/MainNavigator'; LocaleConfig.locales.fr = { monthNames: [ @@ -217,7 +218,7 @@ class PlanningScreen extends React.Component { getRenderItem = (item: PlanningEventType) => { const { navigation } = this.props; const onPress = () => { - navigation.navigate('planning-information', { + navigation.navigate(MainRoutes.PlanningInformation, { data: item, }); }; diff --git a/src/screens/Proxiwash/ProxiwashScreen.tsx b/src/screens/Proxiwash/ProxiwashScreen.tsx index 4e89dd0..d354dac 100644 --- a/src/screens/Proxiwash/ProxiwashScreen.tsx +++ b/src/screens/Proxiwash/ProxiwashScreen.tsx @@ -61,6 +61,7 @@ import { } from '../../utils/asyncStorage'; import { useProxiwashPreferences } from '../../context/preferencesContext'; import { useSubsequentEffect } from '../../utils/customHooks'; +import { MainRoutes } from '../../navigation/MainNavigator'; const REFRESH_TIME = 1000 * 10; // Refresh every 10 seconds const LIST_ITEM_HEIGHT = 64; @@ -170,7 +171,7 @@ function ProxiwashScreen() { navigation.navigate('proxiwash-about')} + onPress={() => navigation.navigate(MainRoutes.ProxiwashAbout)} /> ), @@ -494,7 +495,7 @@ function ProxiwashScreen() { action: { message: i18n.t('screens.proxiwash.mascotDialog.ok'), icon: 'cog', - onPress: () => navigation.navigate('settings'), + onPress: () => navigation.navigate(MainRoutes.Settings), }, cancel: { message: i18n.t('screens.proxiwash.mascotDialog.cancel'), diff --git a/src/screens/Services/Proximo/ProximoListScreen.tsx b/src/screens/Services/Proximo/ProximoListScreen.tsx index 4304cc1..2f67cc6 100644 --- a/src/screens/Services/Proximo/ProximoListScreen.tsx +++ b/src/screens/Services/Proximo/ProximoListScreen.tsx @@ -123,8 +123,9 @@ function ProximoListScreen(props: Props) { const [currentSearchString, setCurrentSearchString] = useState(''); const [currentSortMode, setCurrentSortMode] = useState(2); - const [modalCurrentDisplayItem, setModalCurrentDisplayItem] = - useState(); + const [modalCurrentDisplayItem, setModalCurrentDisplayItem] = useState< + React.ReactChild | undefined + >(); const sortModes = [sortPrice, sortPriceReverse, sortName, sortNameReverse]; diff --git a/src/screens/Services/Proximo/ProximoMainScreen.tsx b/src/screens/Services/Proximo/ProximoMainScreen.tsx index 031a9bf..a4cdc0d 100644 --- a/src/screens/Services/Proximo/ProximoMainScreen.tsx +++ b/src/screens/Services/Proximo/ProximoMainScreen.tsx @@ -32,6 +32,7 @@ import { useNavigation } from '@react-navigation/core'; import { useLayoutEffect } from 'react'; import { useCachedProximoCategories } from '../../../context/cacheContext'; import GENERAL_STYLES from '../../../constants/Styles'; +import { MainRoutes } from '../../../navigation/MainNavigator'; const LIST_ITEM_HEIGHT = 84; @@ -122,10 +123,10 @@ function ProximoMainScreen() { shouldFocusSearchBar: true, category: -1, }; - navigation.navigate('proximo-list', searchScreenData); + navigation.navigate(MainRoutes.ProximoList, searchScreenData); }; - const onPressAboutBtn = () => navigation.navigate('proximo-about'); + const onPressAboutBtn = () => navigation.navigate(MainRoutes.ProximoAbout); const getHeaderButtons = () => { return ( @@ -170,7 +171,8 @@ function ProximoMainScreen() { ? i18n.t('screens.proximo.articles') : i18n.t('screens.proximo.article') }`; - const onPress = () => navigation.navigate('proximo-list', dataToSend); + const onPress = () => + navigation.navigate(MainRoutes.ProximoList, dataToSend); if (article_number > 0) { return ( navigation.navigate('amicale-contact')} + onPress={() => navigation.navigate(MainRoutes.AmicaleContact)} /> ); @@ -114,7 +116,9 @@ function ServicesScreen() { return ( navigation.navigate('services-section', { data: item })} + onPress={() => + navigation.navigate(MainRoutes.ServicesSection, { data: item }) + } > ; - route: { params: { data: ServiceCategoryType | null } }; - collapsibleStack: Collapsible; -}; +type PropsType = StackScreenProps< + MainStackParamsList, + MainRoutes.ServicesSection +>; class ServicesSectionScreen extends React.Component { finalDataset: null | ServiceCategoryType; diff --git a/src/screens/Services/WebsiteScreen.tsx b/src/screens/Services/WebsiteScreen.tsx index cd36522..3a1bea4 100644 --- a/src/screens/Services/WebsiteScreen.tsx +++ b/src/screens/Services/WebsiteScreen.tsx @@ -18,15 +18,16 @@ */ import * as React from 'react'; -import { StackNavigationProp } from '@react-navigation/stack'; +import { StackScreenProps } from '@react-navigation/stack'; import WebViewScreen from '../../components/Screens/WebViewScreen'; import BasicLoadingScreen from '../../components/Screens/BasicLoadingScreen'; import Urls from '../../constants/Urls'; +import { + MainRoutes, + MainStackParamsList, +} from '../../navigation/MainNavigator'; -type Props = { - navigation: StackNavigationProp; - route: { params: { host: string; path: string | null; title: string } }; -}; +type Props = StackScreenProps; type State = { url: string; diff --git a/src/utils/Services.ts b/src/utils/Services.ts index ee4d5e1..5b28622 100644 --- a/src/utils/Services.ts +++ b/src/utils/Services.ts @@ -87,8 +87,8 @@ export type ServiceCategoryType = { }; function getAmicaleOnPress( - route: string, - onPress: (route: string, params?: { [key: string]: any }) => void, + route: MainRoutes, + onPress: (route: MainRoutes, params?: { [key: string]: any }) => void, isLoggedIn: boolean ) { if (isLoggedIn) { @@ -99,7 +99,7 @@ function getAmicaleOnPress( } export function getAmicaleServices( - onPress: (route: string, params?: { [key: string]: any }) => void, + onPress: (route: MainRoutes, params?: { [key: string]: any }) => void, isLoggedIn: boolean, excludedItems?: Array ): Array { @@ -148,7 +148,7 @@ export function getAmicaleServices( } export function getStudentServices( - onPress: (route: string, params?: { [key: string]: any }) => void, + onPress: (route: MainRoutes, params?: { [key: string]: any }) => void, excludedItems?: Array ): Array { const studentsDataset = [ @@ -201,7 +201,7 @@ export function getStudentServices( } export function getINSAServices( - onPress: (route: string, params?: { [key: string]: any }) => void, + onPress: (route: MainRoutes, params?: { [key: string]: any }) => void, excludedItems?: Array ): Array { const insaDataset = [ @@ -274,7 +274,10 @@ export function getINSAServices( } export function getSpecialServices( - onPress: (route: string, params?: { [key: string]: any }) => void, + onPress: ( + route: MainRoutes | TabRoutes, + params?: { [key: string]: any } + ) => void, excludedItems?: Array ): Array { const specialDataset = [ @@ -301,7 +304,10 @@ export function getSpecialServices( } export function getCategories( - onPress: (route: string, params?: { [key: string]: any }) => void, + onPress: ( + route: MainRoutes | TabRoutes, + params?: { [key: string]: any } + ) => void, isLoggedIn: boolean, excludedItems?: Array ): Array { diff --git a/src/utils/URLHandler.ts b/src/utils/URLHandler.ts index a498b9f..c18a0c5 100644 --- a/src/utils/URLHandler.ts +++ b/src/utils/URLHandler.ts @@ -18,10 +18,15 @@ */ import { Linking } from 'react-native'; +import { + ClubInformationScreenParams, + MainRoutes, + PlanningInformationScreenParams, +} from '../navigation/MainNavigator'; export type ParsedUrlDataType = { - route: string; - data: { [key: string]: string }; + route: MainRoutes.ClubInformation | MainRoutes.PlanningInformation; + data: ClubInformationScreenParams | PlanningInformationScreenParams; }; export type ParsedUrlCallbackType = (parsedData: ParsedUrlDataType) => void; @@ -41,10 +46,6 @@ export default class URLHandler { static EVENT_INFO_URL_PATH = 'event'; - static CLUB_INFO_ROUTE = 'club-information'; - - static EVENT_INFO_ROUTE = 'planning-information'; - onInitialURLParsed: ParsedUrlCallbackType; onDetectURL: ParsedUrlCallbackType; @@ -152,8 +153,11 @@ export default class URLHandler { const id = parseInt(params.id, 10); if (!Number.isNaN(id)) { return { - route: URLHandler.CLUB_INFO_ROUTE, - data: { clubId: id.toString() }, + route: MainRoutes.ClubInformation, + data: { + type: 'id', + clubId: id, + }, }; } } @@ -173,8 +177,11 @@ export default class URLHandler { const id = parseInt(params.id, 10); if (!Number.isNaN(id)) { return { - route: URLHandler.EVENT_INFO_ROUTE, - data: { eventId: id.toString() }, + route: MainRoutes.PlanningInformation, + data: { + type: 'id', + eventId: id, + }, }; } }