|
@@ -18,6 +18,7 @@ import AuthenticatedScreen from "../../components/Amicale/AuthenticatedScreen";
|
18
|
18
|
import {getTimeOnlyString, stringToDate} from "../../utils/Planning";
|
19
|
19
|
import LoadingConfirmDialog from "../../components/Dialog/LoadingConfirmDialog";
|
20
|
20
|
import ConnectionManager from "../../managers/ConnectionManager";
|
|
21
|
+import ErrorDialog from "../../components/Dialog/ErrorDialog";
|
21
|
22
|
|
22
|
23
|
const ICON_AMICALE = require('../../../assets/amicale.png');
|
23
|
24
|
|
|
@@ -72,6 +73,8 @@ type Props = {
|
72
|
73
|
type State = {
|
73
|
74
|
selectedTeam: string,
|
74
|
75
|
voteDialogVisible: boolean,
|
|
76
|
+ errorDialogVisible: boolean,
|
|
77
|
+ currentError: number,
|
75
|
78
|
}
|
76
|
79
|
|
77
|
80
|
class VoteScreen extends React.Component<Props, State> {
|
|
@@ -79,6 +82,8 @@ class VoteScreen extends React.Component<Props, State> {
|
79
|
82
|
state = {
|
80
|
83
|
selectedTeam: "none",
|
81
|
84
|
voteDialogVisible: false,
|
|
85
|
+ errorDialogVisible: false,
|
|
86
|
+ currentError: 0,
|
82
|
87
|
};
|
83
|
88
|
|
84
|
89
|
colors: Object;
|
|
@@ -133,7 +138,6 @@ class VoteScreen extends React.Component<Props, State> {
|
133
|
138
|
renderItem={this.mainRenderItem}
|
134
|
139
|
/>
|
135
|
140
|
<LoadingConfirmDialog
|
136
|
|
- {...this.props}
|
137
|
141
|
visible={this.state.voteDialogVisible}
|
138
|
142
|
onDismiss={this.onVoteDialogDismiss}
|
139
|
143
|
onAccept={this.onVoteDialogAccept}
|
|
@@ -141,13 +145,23 @@ class VoteScreen extends React.Component<Props, State> {
|
141
|
145
|
titleLoading={"SENDING VOTE..."}
|
142
|
146
|
message={"SURE?"}
|
143
|
147
|
/>
|
|
148
|
+ <ErrorDialog
|
|
149
|
+ visible={this.state.errorDialogVisible}
|
|
150
|
+ onDismiss={this.onErrorDialogDismiss}
|
|
151
|
+ errorCode={this.state.currentError}
|
|
152
|
+ />
|
144
|
153
|
</View>
|
145
|
154
|
);
|
146
|
155
|
};
|
147
|
156
|
|
148
|
157
|
onVoteDialogDismiss = () => this.setState({voteDialogVisible: false});
|
|
158
|
+ onErrorDialogDismiss = () => this.setState({errorDialogVisible: false});
|
149
|
159
|
|
150
|
160
|
showVoteDialog = () => this.setState({voteDialogVisible: true});
|
|
161
|
+ showErrorDialog = (error: number) => this.setState({
|
|
162
|
+ errorDialogVisible: true,
|
|
163
|
+ currentError: error,
|
|
164
|
+ });
|
151
|
165
|
|
152
|
166
|
onVoteDialogAccept = async () => {
|
153
|
167
|
return new Promise((resolve, reject) => {
|
|
@@ -159,8 +173,9 @@ class VoteScreen extends React.Component<Props, State> {
|
159
|
173
|
this.onVoteDialogDismiss();
|
160
|
174
|
resolve();
|
161
|
175
|
})
|
162
|
|
- .catch(() => {
|
|
176
|
+ .catch((error: number) => {
|
163
|
177
|
this.onVoteDialogDismiss();
|
|
178
|
+ this.showErrorDialog(error);
|
164
|
179
|
resolve();
|
165
|
180
|
});
|
166
|
181
|
});
|