forked from vergnet/application-amicale
Show information message when no group is selected
This commit is contained in:
parent
ffb0b03b41
commit
ac59121609
4 changed files with 86 additions and 53 deletions
|
@ -12,6 +12,9 @@ type Props = {
|
|||
route: Object,
|
||||
errorCode: number,
|
||||
onRefresh: Function,
|
||||
icon: string,
|
||||
message: string,
|
||||
showRetryButton: boolean,
|
||||
}
|
||||
|
||||
type State = {
|
||||
|
@ -27,6 +30,13 @@ class ErrorView extends React.PureComponent<Props, State> {
|
|||
|
||||
showLoginButton: boolean;
|
||||
|
||||
static defaultProps = {
|
||||
errorCode: 0,
|
||||
icon: '',
|
||||
message: '',
|
||||
showRetryButton: true,
|
||||
}
|
||||
|
||||
state = {
|
||||
refreshing: false,
|
||||
};
|
||||
|
@ -38,6 +48,7 @@ class ErrorView extends React.PureComponent<Props, State> {
|
|||
|
||||
generateMessage() {
|
||||
this.showLoginButton = false;
|
||||
if (this.props.errorCode !== 0) {
|
||||
switch (this.props.errorCode) {
|
||||
case ERROR_TYPE.BAD_CREDENTIALS:
|
||||
this.message = i18n.t("errors.badCredentials");
|
||||
|
@ -73,6 +84,11 @@ class ErrorView extends React.PureComponent<Props, State> {
|
|||
this.icon = "alert-circle-outline";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
this.message = this.props.message;
|
||||
this.icon = this.props.icon;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getRetryButton() {
|
||||
|
@ -91,7 +107,8 @@ class ErrorView extends React.PureComponent<Props, State> {
|
|||
{
|
||||
screen: 'login',
|
||||
params: {nextScreen: this.props.route.name}
|
||||
})};
|
||||
})
|
||||
};
|
||||
|
||||
getLoginButton() {
|
||||
return <Button
|
||||
|
@ -124,9 +141,11 @@ class ErrorView extends React.PureComponent<Props, State> {
|
|||
}}>
|
||||
{this.message}
|
||||
</Subheading>
|
||||
{this.showLoginButton
|
||||
{this.props.showRetryButton
|
||||
? (this.showLoginButton
|
||||
? this.getLoginButton()
|
||||
: this.getRetryButton()}
|
||||
: this.getRetryButton())
|
||||
: null}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
@ -148,6 +167,7 @@ const styles = StyleSheet.create({
|
|||
},
|
||||
subheading: {
|
||||
textAlign: 'center',
|
||||
paddingHorizontal: 20
|
||||
},
|
||||
button: {
|
||||
marginTop: 10,
|
||||
|
|
|
@ -13,6 +13,7 @@ import {dateToString, getTimeOnlyString} from "../../utils/Planning";
|
|||
import DateManager from "../../managers/DateManager";
|
||||
import AnimatedBottomBar from "../../components/Custom/AnimatedBottomBar";
|
||||
import {CommonActions} from "@react-navigation/native";
|
||||
import ErrorView from "../../components/Custom/ErrorView";
|
||||
|
||||
type Props = {
|
||||
navigation: Object,
|
||||
|
@ -143,7 +144,7 @@ class PlanexScreen extends React.Component<Props, State> {
|
|||
|
||||
let currentGroup = AsyncStorageManager.getInstance().preferences.planexCurrentGroup.current;
|
||||
if (currentGroup === '')
|
||||
currentGroup = {name: "SELECT GROUP", id: 0};
|
||||
currentGroup = {name: "SELECT GROUP", id: -1};
|
||||
else
|
||||
currentGroup = JSON.parse(currentGroup);
|
||||
this.state = {
|
||||
|
@ -260,6 +261,7 @@ class PlanexScreen extends React.Component<Props, State> {
|
|||
};
|
||||
|
||||
getWebView() {
|
||||
if (this.state.currentGroup.id !== -1) {
|
||||
return (
|
||||
<WebViewScreen
|
||||
ref={this.webScreenRef}
|
||||
|
@ -270,6 +272,15 @@ class PlanexScreen extends React.Component<Props, State> {
|
|||
onScroll={this.onScroll}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return <ErrorView
|
||||
{...this.props}
|
||||
icon={'account-clock'}
|
||||
message={i18n.t("planexScreen.noGroupSelected")}
|
||||
showRetryButton={false}
|
||||
/>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
@ -212,7 +212,8 @@
|
|||
"planexScreen": {
|
||||
"enableStartScreen": "Come here often? Set it as default screen!",
|
||||
"enableStartOK": "Yes please!",
|
||||
"enableStartCancel": "Later"
|
||||
"enableStartCancel": "Later",
|
||||
"noGroupSelected": "No group selected. Please select your group using the big beautiful red button bellow."
|
||||
},
|
||||
"availableRoomScreen": {
|
||||
"normalRoom": "Work",
|
||||
|
|
|
@ -212,7 +212,8 @@
|
|||
"planexScreen": {
|
||||
"enableStartScreen": "Vous venez souvent ici ? Démarrez l'appli sur cette page!",
|
||||
"enableStartOK": "Oui svp!",
|
||||
"enableStartCancel": "Plus tard"
|
||||
"enableStartCancel": "Plus tard",
|
||||
"noGroupSelected": "Pas de group sélectionné. Merci de choisir un groupe avec le beau bouton rouge ci-dessous."
|
||||
},
|
||||
"availableRoomScreen": {
|
||||
"normalRoom": "Travail",
|
||||
|
|
Loading…
Reference in a new issue