diff --git a/src/components/Amicale/AuthenticatedScreen.js b/src/components/Amicale/AuthenticatedScreen.js index 3217421..ac7ddc9 100644 --- a/src/components/Amicale/AuthenticatedScreen.js +++ b/src/components/Amicale/AuthenticatedScreen.js @@ -15,6 +15,12 @@ type Props = { mandatory: boolean }>, renderFunction: (Array<{ [key: string]: any } | null>) => React.Node, + errorViewOverride?: Array<{ + errorCode: number, + message: string, + icon: string, + showRetryButton: boolean + }>, } type State = { @@ -158,13 +164,38 @@ class AuthenticatedScreen extends React.Component { * @return {*} */ getErrorRender() { - return ( - - ); + const errorCode = this.getError(); + let shouldOverride = false; + let override = null; + const overrideList = this.props.errorViewOverride; + if (overrideList != null) { + for (let i = 0; i < overrideList.length; i++) { + if (overrideList[i].errorCode === errorCode) { + shouldOverride = true; + override = overrideList[i]; + break; + } + } + } + if (shouldOverride && override != null) { + return ( + + ); + } else { + return ( + + ); + } + } /** diff --git a/src/screens/Amicale/Clubs/ClubDisplayScreen.js b/src/screens/Amicale/Clubs/ClubDisplayScreen.js index f04ff68..6669f16 100644 --- a/src/screens/Amicale/Clubs/ClubDisplayScreen.js +++ b/src/screens/Amicale/Clubs/ClubDisplayScreen.js @@ -12,6 +12,7 @@ import type {category, club} from "./ClubListScreen"; import type {CustomTheme} from "../../../managers/ThemeManager"; import {StackNavigationProp} from "@react-navigation/stack"; import {Linking} from "expo"; +import {ERROR_TYPE} from "../../../utils/WebData"; type Props = { navigation: StackNavigationProp, @@ -179,7 +180,7 @@ class ClubDisplayScreen extends React.Component { : } {this.getManagersRender(data.responsibles, data.email)} - +q ); } else return null; @@ -198,6 +199,14 @@ class ClubDisplayScreen extends React.Component { } ]} renderFunction={this.getScreen} + errorViewOverride={[ + { + errorCode: ERROR_TYPE.BAD_INPUT, + message: i18n.t("clubs.invalidClub"), + icon: "account-question", + showRetryButton: false + } + ]} />; else return this.getScreen([this.displayData]); diff --git a/src/screens/Planning/PlanningDisplayScreen.js b/src/screens/Planning/PlanningDisplayScreen.js index 8892ab1..904557c 100644 --- a/src/screens/Planning/PlanningDisplayScreen.js +++ b/src/screens/Planning/PlanningDisplayScreen.js @@ -7,10 +7,11 @@ import {Card, withTheme} from 'react-native-paper'; import DateManager from "../../managers/DateManager"; import ImageModal from 'react-native-image-modal'; import BasicLoadingScreen from "../../components/Screens/BasicLoadingScreen"; -import {apiRequest} from "../../utils/WebData"; +import {apiRequest, ERROR_TYPE} from "../../utils/WebData"; import ErrorView from "../../components/Screens/ErrorView"; import CustomHTML from "../../components/Overrides/CustomHTML"; import CustomTabBar from "../../components/Tabbar/CustomTabBar"; +import i18n from 'i18n-js'; type Props = { navigation: Object, @@ -113,13 +114,20 @@ class PlanningDisplayScreen extends React.Component { ); } + getErrorView() { + if (this.errorCode === ERROR_TYPE.BAD_INPUT) + return ; + else + return ; + } + render() { if (this.state.loading) return ; else if (this.errorCode === 0) return this.getContent(); else - return ; + return this.getErrorView(); } } diff --git a/translations/en.json b/translations/en.json index 8f3c6cd..3056bbe 100644 --- a/translations/en.json +++ b/translations/en.json @@ -26,12 +26,6 @@ "vote": "Elections", "scanner": "Scanotron 3000" }, - "sidenav": { - "divider1": "Student websites", - "divider2": "Services", - "divider3": "Personalisation", - "divider4": "Amicale" - }, "intro": { "slide1": { "title": "Welcome to CAMPUS", @@ -263,6 +257,7 @@ "categoriesFilterMessage": "Click on a category to filter the list", "clubContact": "Contact the club", "amicaleContact": "Contact the Amicale", + "invalidClub": "Could not find the club. Please make sure the club you are trying to access is valid.", "about": { "text": "The clubs, making the campus live, with more than sixty clubs offering various activities! From the philosophy club to the PABI (Production Artisanale de Bière Insaienne), without forgetting the multiple music and dance clubs, you will surely find an activity that suits you!", "title": "A question ?", @@ -390,5 +385,8 @@ "students": "Student services", "insa": "INSA services", "notLoggedIn": "Not logged in" + }, + "planningScreen": { + "invalidEvent": "Could not find the event. Please make sure the event you are trying to access is valid." } } diff --git a/translations/fr.json b/translations/fr.json index 8fd9430..c3f9745 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -26,12 +26,6 @@ "vote": "Élections", "scanner": "Scanotron 3000" }, - "sidenav": { - "divider1": "Sites étudiants", - "divider2": "Services", - "divider3": "Personnalisation", - "divider4": "Amicale" - }, "intro": { "slide1": { "title": "Bienvenue sur CAMPUS", @@ -263,6 +257,7 @@ "categoriesFilterMessage": "Cliquez sur une catégorie pour filtrer la liste", "clubContact": "Contacter le club", "amicaleContact": "Contacter l'Amicale", + "invalidClub": "Impossible de trouver le club. Merci de vérifier que le club que vous voulez voir est valide.", "about": { "text": "Les clubs, c'est ce qui fait vivre le campus au quotidien, plus d'une soixantaine de clubs qui proposent des activités diverses et variées ! Du club Philosophie au PABI (Production Artisanale de Bière Insaienne), en passant par les multiples clubs de musique et de danse, vous trouverez forcément une activité qui vous permettra de vous épanouir sur le campus !", "title": "Une question ?", @@ -390,5 +385,8 @@ "students": "Services étudiants", "insa": "Services de l'INSA", "notLoggedIn": "Non connecté" + }, + "planningScreen": { + "invalidEvent": "Impossible de trouver l'événement. Merci de vérifier que l'événement que vous voulez voir est valide." } }