Browse Source

Fix mascot dialog not showing

Arnaud Vergnet 2 years ago
parent
commit
bdffd01df4

+ 16
- 10
src/navigation/TabNavigator.tsx View File

@@ -78,9 +78,12 @@ const ServicesStack = createStackNavigator();
78 78
 
79 79
 function ServicesStackComponent() {
80 80
   return (
81
-    <ServicesStack.Navigator initialRouteName={'index'} headerMode={'screen'}>
81
+    <ServicesStack.Navigator
82
+      initialRouteName={'services'}
83
+      headerMode={'screen'}
84
+    >
82 85
       <ServicesStack.Screen
83
-        name={'index'}
86
+        name={'services'}
84 87
         component={WebsitesHomeScreen}
85 88
         options={{ title: i18n.t('screens.services.title') }}
86 89
       />
@@ -102,9 +105,12 @@ const ProxiwashStack = createStackNavigator();
102 105
 
103 106
 function ProxiwashStackComponent() {
104 107
   return (
105
-    <ProxiwashStack.Navigator initialRouteName={'index'} headerMode={'screen'}>
108
+    <ProxiwashStack.Navigator
109
+      initialRouteName={'proxiwash'}
110
+      headerMode={'screen'}
111
+    >
106 112
       <ProxiwashStack.Screen
107
-        name={'index-contact'}
113
+        name={'proxiwash'}
108 114
         component={ProxiwashScreen}
109 115
         options={{ title: i18n.t('screens.proxiwash.title') }}
110 116
       />
@@ -121,9 +127,9 @@ const PlanningStack = createStackNavigator();
121 127
 
122 128
 function PlanningStackComponent() {
123 129
   return (
124
-    <PlanningStack.Navigator initialRouteName={'index'} headerMode={'screen'}>
130
+    <PlanningStack.Navigator initialRouteName={'events'} headerMode={'screen'}>
125 131
       <PlanningStack.Screen
126
-        name={'index'}
132
+        name={'events'}
127 133
         component={PlanningScreen}
128 134
         options={{ title: i18n.t('screens.planning.title') }}
129 135
       />
@@ -148,9 +154,9 @@ function HomeStackComponent(
148 154
   }
149 155
   const { colors } = useTheme();
150 156
   return (
151
-    <HomeStack.Navigator initialRouteName={'index'} headerMode={'screen'}>
157
+    <HomeStack.Navigator initialRouteName={'home'} headerMode={'screen'}>
152 158
       <HomeStack.Screen
153
-        name={'index'}
159
+        name={'home'}
154 160
         component={HomeScreen}
155 161
         options={{
156 162
           title: i18n.t('screens.home.title'),
@@ -213,9 +219,9 @@ const PlanexStack = createStackNavigator();
213 219
 
214 220
 function PlanexStackComponent() {
215 221
   return (
216
-    <PlanexStack.Navigator initialRouteName={'index'} headerMode={'screen'}>
222
+    <PlanexStack.Navigator initialRouteName={'planex'} headerMode={'screen'}>
217 223
       <PlanexStack.Screen
218
-        name={'index'}
224
+        name={'planex'}
219 225
         component={PlanexScreen}
220 226
         options={{
221 227
           title: i18n.t('screens.planex.title'),

+ 3
- 1
src/screens/Amicale/Equipment/EquipmentListScreen.tsx View File

@@ -60,7 +60,9 @@ const styles = StyleSheet.create({
60 60
 
61 61
 function EquipmentListScreen() {
62 62
   const userRents = useRef<undefined | Array<RentedDeviceType>>();
63
-  const [mascotDialogVisible, setMascotDialogVisible] = useState(false);
63
+  const [mascotDialogVisible, setMascotDialogVisible] = useState<
64
+    undefined | boolean
65
+  >(undefined);
64 66
 
65 67
   const requestAll = useAuthenticatedRequest<{ devices: Array<DeviceType> }>(
66 68
     'location/all'

+ 5
- 3
src/screens/Amicale/LoginScreen.tsx View File

@@ -44,7 +44,9 @@ function LoginScreen(props: Props) {
44 44
   const { setLogin } = useLogin();
45 45
   const [loading, setLoading] = useState(false);
46 46
   const [nextScreen, setNextScreen] = useState<string | undefined>(undefined);
47
-  const [mascotDialogVisible, setMascotDialogVisible] = useState(false);
47
+  const [mascotDialogVisible, setMascotDialogVisible] = useState<
48
+    undefined | boolean
49
+  >(undefined);
48 50
   const [currentError, setCurrentError] = useState<ApiRejectType>({
49 51
     status: REQUEST_STATUS.SUCCESS,
50 52
   });
@@ -79,9 +81,9 @@ function LoginScreen(props: Props) {
79 81
       .finally(() => setLoading(false));
80 82
   };
81 83
 
82
-  const hideMascotDialog = () => setMascotDialogVisible(true);
84
+  const hideMascotDialog = () => setMascotDialogVisible(false);
83 85
 
84
-  const showMascotDialog = () => setMascotDialogVisible(false);
86
+  const showMascotDialog = () => setMascotDialogVisible(true);
85 87
 
86 88
   const hideErrorDialog = () =>
87 89
     setCurrentError({ status: REQUEST_STATUS.SUCCESS });

+ 3
- 1
src/screens/Amicale/VoteScreen.tsx View File

@@ -133,7 +133,9 @@ const styles = StyleSheet.create({
133 133
  */
134 134
 export default function VoteScreen() {
135 135
   const [hasVoted, setHasVoted] = useState(false);
136
-  const [mascotDialogVisible, setMascotDialogVisible] = useState(false);
136
+  const [mascotDialogVisible, setMascotDialogVisible] = useState<
137
+    undefined | boolean
138
+  >(undefined);
137 139
 
138 140
   const datesRequest = useAuthenticatedRequest<VoteDatesStringType>(
139 141
     'elections/dates'

+ 6
- 2
src/utils/asyncStorage.ts View File

@@ -110,13 +110,17 @@ export const defaultPreferences: { [key in GeneralPreferenceKeys]: string } = {
110 110
 export function isValidGeneralPreferenceKey(
111 111
   key: string
112 112
 ): key is GeneralPreferenceKeys {
113
-  return key in Object.values(GeneralPreferenceKeys);
113
+  return Object.values(GeneralPreferenceKeys).includes(
114
+    key as GeneralPreferenceKeys
115
+  );
114 116
 }
115 117
 
116 118
 export function isValidMascotPreferenceKey(
117 119
   key: string
118 120
 ): key is MascotPreferenceKeys {
119
-  return key in Object.values(MascotPreferenceKeys);
121
+  return Object.values(MascotPreferenceKeys).includes(
122
+    key as MascotPreferenceKeys
123
+  );
120 124
 }
121 125
 
122 126
 /**

Loading…
Cancel
Save