From f362531d426972b5b99314f43c11ffa488dfc1f2 Mon Sep 17 00:00:00 2001 From: Arthur Jamet Date: Wed, 21 Jun 2023 15:17:21 +0100 Subject: [PATCH] Front: Reanme Settings' subroutes for URLs --- front/Navigation.tsx | 2 +- front/views/settings/SettingsView.tsx | 37 ++++++++++++++------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/front/Navigation.tsx b/front/Navigation.tsx index c6c9d47..efcbb29 100644 --- a/front/Navigation.tsx +++ b/front/Navigation.tsx @@ -39,7 +39,7 @@ const protectedRoutes = () => Settings: { component: SetttingsNavigator, options: { title: 'Settings' }, - link: '/settings', + link: '/settings/:screen?', }, Song: { component: SongLobbyView, diff --git a/front/views/settings/SettingsView.tsx b/front/views/settings/SettingsView.tsx index ab25aef..84f609d 100644 --- a/front/views/settings/SettingsView.tsx +++ b/front/views/settings/SettingsView.tsx @@ -12,6 +12,7 @@ import PreferencesView from './PreferencesView'; import GuestToUserView from './GuestToUserView'; import { useQuery } from 'react-query'; import API from '../../API'; +import { RouteProps } from '../../Navigation'; const handleChangeEmail = async (newEmail: string): Promise => { await API.updateUserEmail(newEmail); @@ -65,17 +66,17 @@ const TabRow = createTabRowNavigator(); type SetttingsNavigatorProps = { screen?: - | 'Profile' - | 'Preferences' - | 'Notifications' - | 'Privacy' - | 'ChangePassword' - | 'ChangeEmail' - | 'GoogleAccount' - | 'PianoSettings'; + | 'profile' + | 'preferences' + | 'notifications' + | 'privacy' + | 'changePassword' + | 'changeEmail' + | 'googleAccount' + | 'pianoSettings'; }; -const SetttingsNavigator = (props?: SetttingsNavigatorProps) => { +const SetttingsNavigator = (props?: RouteProps) => { const userQuery = useQuery(['user'], () => API.getUserInfo()); const user = useMemo(() => userQuery.data, [userQuery]); @@ -98,7 +99,7 @@ const SetttingsNavigator = (props?: SetttingsNavigatorProps) => { {user && user.isGuest && ( { /> )} { }} /> { }} /> { }} /> { }} /> { }} /> { }} /> { }} />