Fix mascot dialog not showing

This commit is contained in:
Arnaud Vergnet 2021-05-23 16:12:42 +02:00
parent c500ae05e6
commit bdffd01df4
5 changed files with 33 additions and 17 deletions

View file

@ -78,9 +78,12 @@ const ServicesStack = createStackNavigator();
function ServicesStackComponent() {
return (
<ServicesStack.Navigator initialRouteName={'index'} headerMode={'screen'}>
<ServicesStack.Navigator
initialRouteName={'services'}
headerMode={'screen'}
>
<ServicesStack.Screen
name={'index'}
name={'services'}
component={WebsitesHomeScreen}
options={{ title: i18n.t('screens.services.title') }}
/>
@ -102,9 +105,12 @@ const ProxiwashStack = createStackNavigator();
function ProxiwashStackComponent() {
return (
<ProxiwashStack.Navigator initialRouteName={'index'} headerMode={'screen'}>
<ProxiwashStack.Navigator
initialRouteName={'proxiwash'}
headerMode={'screen'}
>
<ProxiwashStack.Screen
name={'index-contact'}
name={'proxiwash'}
component={ProxiwashScreen}
options={{ title: i18n.t('screens.proxiwash.title') }}
/>
@ -121,9 +127,9 @@ const PlanningStack = createStackNavigator();
function PlanningStackComponent() {
return (
<PlanningStack.Navigator initialRouteName={'index'} headerMode={'screen'}>
<PlanningStack.Navigator initialRouteName={'events'} headerMode={'screen'}>
<PlanningStack.Screen
name={'index'}
name={'events'}
component={PlanningScreen}
options={{ title: i18n.t('screens.planning.title') }}
/>
@ -148,9 +154,9 @@ function HomeStackComponent(
}
const { colors } = useTheme();
return (
<HomeStack.Navigator initialRouteName={'index'} headerMode={'screen'}>
<HomeStack.Navigator initialRouteName={'home'} headerMode={'screen'}>
<HomeStack.Screen
name={'index'}
name={'home'}
component={HomeScreen}
options={{
title: i18n.t('screens.home.title'),
@ -213,9 +219,9 @@ const PlanexStack = createStackNavigator();
function PlanexStackComponent() {
return (
<PlanexStack.Navigator initialRouteName={'index'} headerMode={'screen'}>
<PlanexStack.Navigator initialRouteName={'planex'} headerMode={'screen'}>
<PlanexStack.Screen
name={'index'}
name={'planex'}
component={PlanexScreen}
options={{
title: i18n.t('screens.planex.title'),

View file

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

View file

@ -44,7 +44,9 @@ function LoginScreen(props: Props) {
const { setLogin } = useLogin();
const [loading, setLoading] = useState(false);
const [nextScreen, setNextScreen] = useState<string | undefined>(undefined);
const [mascotDialogVisible, setMascotDialogVisible] = useState(false);
const [mascotDialogVisible, setMascotDialogVisible] = useState<
undefined | boolean
>(undefined);
const [currentError, setCurrentError] = useState<ApiRejectType>({
status: REQUEST_STATUS.SUCCESS,
});
@ -79,9 +81,9 @@ function LoginScreen(props: Props) {
.finally(() => setLoading(false));
};
const hideMascotDialog = () => setMascotDialogVisible(true);
const hideMascotDialog = () => setMascotDialogVisible(false);
const showMascotDialog = () => setMascotDialogVisible(false);
const showMascotDialog = () => setMascotDialogVisible(true);
const hideErrorDialog = () =>
setCurrentError({ status: REQUEST_STATUS.SUCCESS });

View file

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

View file

@ -110,13 +110,17 @@ export const defaultPreferences: { [key in GeneralPreferenceKeys]: string } = {
export function isValidGeneralPreferenceKey(
key: string
): key is GeneralPreferenceKeys {
return key in Object.values(GeneralPreferenceKeys);
return Object.values(GeneralPreferenceKeys).includes(
key as GeneralPreferenceKeys
);
}
export function isValidMascotPreferenceKey(
key: string
): key is MascotPreferenceKeys {
return key in Object.values(MascotPreferenceKeys);
return Object.values(MascotPreferenceKeys).includes(
key as MascotPreferenceKeys
);
}
/**