From 49dced05ab5b1ed91774fc80ef97716e917e568d Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Tue, 7 Apr 2020 12:34:55 +0200 Subject: [PATCH] Show error dialog on error --- src/screens/Amicale/VoteScreen.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/screens/Amicale/VoteScreen.js b/src/screens/Amicale/VoteScreen.js index 1be102c..2a54a23 100644 --- a/src/screens/Amicale/VoteScreen.js +++ b/src/screens/Amicale/VoteScreen.js @@ -18,6 +18,7 @@ import AuthenticatedScreen from "../../components/Amicale/AuthenticatedScreen"; import {getTimeOnlyString, stringToDate} from "../../utils/Planning"; import LoadingConfirmDialog from "../../components/Dialog/LoadingConfirmDialog"; import ConnectionManager from "../../managers/ConnectionManager"; +import ErrorDialog from "../../components/Dialog/ErrorDialog"; const ICON_AMICALE = require('../../../assets/amicale.png'); @@ -72,6 +73,8 @@ type Props = { type State = { selectedTeam: string, voteDialogVisible: boolean, + errorDialogVisible: boolean, + currentError: number, } class VoteScreen extends React.Component { @@ -79,6 +82,8 @@ class VoteScreen extends React.Component { state = { selectedTeam: "none", voteDialogVisible: false, + errorDialogVisible: false, + currentError: 0, }; colors: Object; @@ -133,7 +138,6 @@ class VoteScreen extends React.Component { renderItem={this.mainRenderItem} /> { titleLoading={"SENDING VOTE..."} message={"SURE?"} /> + ); }; onVoteDialogDismiss = () => this.setState({voteDialogVisible: false}); + onErrorDialogDismiss = () => this.setState({errorDialogVisible: false}); showVoteDialog = () => this.setState({voteDialogVisible: true}); + showErrorDialog = (error: number) => this.setState({ + errorDialogVisible: true, + currentError: error, + }); onVoteDialogAccept = async () => { return new Promise((resolve, reject) => { @@ -159,8 +173,9 @@ class VoteScreen extends React.Component { this.onVoteDialogDismiss(); resolve(); }) - .catch(() => { + .catch((error: number) => { this.onVoteDialogDismiss(); + this.showErrorDialog(error); resolve(); }); });