|
@@ -25,13 +25,14 @@ import { StackNavigationProp } from '@react-navigation/stack';
|
25
|
25
|
import { getDateOnlyString, getTimeOnlyString } from '../../utils/Planning';
|
26
|
26
|
import DateManager from '../../managers/DateManager';
|
27
|
27
|
import BasicLoadingScreen from '../../components/Screens/BasicLoadingScreen';
|
28
|
|
-import { apiRequest, ERROR_TYPE } from '../../utils/WebData';
|
|
28
|
+import { ApiRejectType, apiRequest } from '../../utils/WebData';
|
29
|
29
|
import ErrorView from '../../components/Screens/ErrorView';
|
30
|
30
|
import CustomHTML from '../../components/Overrides/CustomHTML';
|
31
|
31
|
import { TAB_BAR_HEIGHT } from '../../components/Tabbar/CustomTabBar';
|
32
|
32
|
import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
|
33
|
33
|
import type { PlanningEventType } from '../../utils/Planning';
|
34
|
34
|
import ImageGalleryButton from '../../components/Media/ImageGalleryButton';
|
|
35
|
+import { API_REQUEST_CODES, REQUEST_STATUS } from '../../utils/Requests';
|
35
|
36
|
|
36
|
37
|
type PropsType = {
|
37
|
38
|
navigation: StackNavigationProp<any>;
|
|
@@ -67,7 +68,7 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
67
|
68
|
|
68
|
69
|
eventId: number;
|
69
|
70
|
|
70
|
|
- errorCode: number;
|
|
71
|
+ error: ApiRejectType;
|
71
|
72
|
|
72
|
73
|
/**
|
73
|
74
|
* Generates data depending on whether the screen was opened from the planning or from a link
|
|
@@ -81,7 +82,7 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
81
|
82
|
this.displayData = props.route.params.data;
|
82
|
83
|
this.eventId = this.displayData.id;
|
83
|
84
|
this.shouldFetchData = false;
|
84
|
|
- this.errorCode = 0;
|
|
85
|
+ this.error = { status: REQUEST_STATUS.SUCCESS };
|
85
|
86
|
this.state = {
|
86
|
87
|
loading: false,
|
87
|
88
|
};
|
|
@@ -89,7 +90,7 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
89
|
90
|
this.displayData = null;
|
90
|
91
|
this.eventId = props.route.params.eventId;
|
91
|
92
|
this.shouldFetchData = true;
|
92
|
|
- this.errorCode = 0;
|
|
93
|
+ this.error = { status: REQUEST_STATUS.SUCCESS };
|
93
|
94
|
this.state = {
|
94
|
95
|
loading: true,
|
95
|
96
|
};
|
|
@@ -112,8 +113,8 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
112
|
113
|
*
|
113
|
114
|
* @param error
|
114
|
115
|
*/
|
115
|
|
- onFetchError = (error: number) => {
|
116
|
|
- this.errorCode = error;
|
|
116
|
+ onFetchError = (error: ApiRejectType) => {
|
|
117
|
+ this.error = error;
|
117
|
118
|
this.setState({ loading: false });
|
118
|
119
|
};
|
119
|
120
|
|
|
@@ -161,7 +162,7 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
161
|
162
|
* @returns {*}
|
162
|
163
|
*/
|
163
|
164
|
getErrorView() {
|
164
|
|
- if (this.errorCode === ERROR_TYPE.BAD_INPUT) {
|
|
165
|
+ if (this.error.code === API_REQUEST_CODES.BAD_INPUT) {
|
165
|
166
|
return (
|
166
|
167
|
<ErrorView
|
167
|
168
|
message={i18n.t('screens.planning.invalidEvent')}
|
|
@@ -171,7 +172,8 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
171
|
172
|
}
|
172
|
173
|
return (
|
173
|
174
|
<ErrorView
|
174
|
|
- status={this.errorCode}
|
|
175
|
+ status={this.error.status}
|
|
176
|
+ code={this.error.code}
|
175
|
177
|
button={{
|
176
|
178
|
icon: 'refresh',
|
177
|
179
|
text: i18n.t('general.retry'),
|
|
@@ -196,7 +198,10 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
196
|
198
|
if (loading) {
|
197
|
199
|
return <BasicLoadingScreen />;
|
198
|
200
|
}
|
199
|
|
- if (this.errorCode === 0) {
|
|
201
|
+ if (
|
|
202
|
+ this.error.status === REQUEST_STATUS.SUCCESS &&
|
|
203
|
+ this.error.code === undefined
|
|
204
|
+ ) {
|
200
|
205
|
return this.getContent();
|
201
|
206
|
}
|
202
|
207
|
return this.getErrorView();
|