forked from vergnet/application-amicale
Show error dialog on error
This commit is contained in:
parent
ed2bf89d2f
commit
49dced05ab
1 changed files with 17 additions and 2 deletions
|
@ -18,6 +18,7 @@ import AuthenticatedScreen from "../../components/Amicale/AuthenticatedScreen";
|
||||||
import {getTimeOnlyString, stringToDate} from "../../utils/Planning";
|
import {getTimeOnlyString, stringToDate} from "../../utils/Planning";
|
||||||
import LoadingConfirmDialog from "../../components/Dialog/LoadingConfirmDialog";
|
import LoadingConfirmDialog from "../../components/Dialog/LoadingConfirmDialog";
|
||||||
import ConnectionManager from "../../managers/ConnectionManager";
|
import ConnectionManager from "../../managers/ConnectionManager";
|
||||||
|
import ErrorDialog from "../../components/Dialog/ErrorDialog";
|
||||||
|
|
||||||
const ICON_AMICALE = require('../../../assets/amicale.png');
|
const ICON_AMICALE = require('../../../assets/amicale.png');
|
||||||
|
|
||||||
|
@ -72,6 +73,8 @@ type Props = {
|
||||||
type State = {
|
type State = {
|
||||||
selectedTeam: string,
|
selectedTeam: string,
|
||||||
voteDialogVisible: boolean,
|
voteDialogVisible: boolean,
|
||||||
|
errorDialogVisible: boolean,
|
||||||
|
currentError: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
class VoteScreen extends React.Component<Props, State> {
|
class VoteScreen extends React.Component<Props, State> {
|
||||||
|
@ -79,6 +82,8 @@ class VoteScreen extends React.Component<Props, State> {
|
||||||
state = {
|
state = {
|
||||||
selectedTeam: "none",
|
selectedTeam: "none",
|
||||||
voteDialogVisible: false,
|
voteDialogVisible: false,
|
||||||
|
errorDialogVisible: false,
|
||||||
|
currentError: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
colors: Object;
|
colors: Object;
|
||||||
|
@ -133,7 +138,6 @@ class VoteScreen extends React.Component<Props, State> {
|
||||||
renderItem={this.mainRenderItem}
|
renderItem={this.mainRenderItem}
|
||||||
/>
|
/>
|
||||||
<LoadingConfirmDialog
|
<LoadingConfirmDialog
|
||||||
{...this.props}
|
|
||||||
visible={this.state.voteDialogVisible}
|
visible={this.state.voteDialogVisible}
|
||||||
onDismiss={this.onVoteDialogDismiss}
|
onDismiss={this.onVoteDialogDismiss}
|
||||||
onAccept={this.onVoteDialogAccept}
|
onAccept={this.onVoteDialogAccept}
|
||||||
|
@ -141,13 +145,23 @@ class VoteScreen extends React.Component<Props, State> {
|
||||||
titleLoading={"SENDING VOTE..."}
|
titleLoading={"SENDING VOTE..."}
|
||||||
message={"SURE?"}
|
message={"SURE?"}
|
||||||
/>
|
/>
|
||||||
|
<ErrorDialog
|
||||||
|
visible={this.state.errorDialogVisible}
|
||||||
|
onDismiss={this.onErrorDialogDismiss}
|
||||||
|
errorCode={this.state.currentError}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
onVoteDialogDismiss = () => this.setState({voteDialogVisible: false});
|
onVoteDialogDismiss = () => this.setState({voteDialogVisible: false});
|
||||||
|
onErrorDialogDismiss = () => this.setState({errorDialogVisible: false});
|
||||||
|
|
||||||
showVoteDialog = () => this.setState({voteDialogVisible: true});
|
showVoteDialog = () => this.setState({voteDialogVisible: true});
|
||||||
|
showErrorDialog = (error: number) => this.setState({
|
||||||
|
errorDialogVisible: true,
|
||||||
|
currentError: error,
|
||||||
|
});
|
||||||
|
|
||||||
onVoteDialogAccept = async () => {
|
onVoteDialogAccept = async () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -159,8 +173,9 @@ class VoteScreen extends React.Component<Props, State> {
|
||||||
this.onVoteDialogDismiss();
|
this.onVoteDialogDismiss();
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((error: number) => {
|
||||||
this.onVoteDialogDismiss();
|
this.onVoteDialogDismiss();
|
||||||
|
this.showErrorDialog(error);
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue