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

View file

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

View file

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

View file

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

View file

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