@plusscommunities/pluss-maintenance-app-forms 6.0.8-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module/actions/JobActions.js +20 -0
- package/dist/module/actions/JobActions.js.map +1 -0
- package/dist/module/actions/index.js +2 -0
- package/dist/module/actions/index.js.map +1 -0
- package/dist/module/actions/types.js +5 -0
- package/dist/module/actions/types.js.map +1 -0
- package/dist/module/apis/index.js +2 -0
- package/dist/module/apis/index.js.map +1 -0
- package/dist/module/apis/maintenanceActions.js +171 -0
- package/dist/module/apis/maintenanceActions.js.map +1 -0
- package/dist/module/components/FilterPopupMenu.js +271 -0
- package/dist/module/components/FilterPopupMenu.js.map +1 -0
- package/dist/module/components/MaintenanceList.js +360 -0
- package/dist/module/components/MaintenanceList.js.map +1 -0
- package/dist/module/components/MaintenanceListItem.js +322 -0
- package/dist/module/components/MaintenanceListItem.js.map +1 -0
- package/dist/module/components/MaintenanceWidgetItem.js +149 -0
- package/dist/module/components/MaintenanceWidgetItem.js.map +1 -0
- package/dist/module/components/StatusSelectorPopup.js +89 -0
- package/dist/module/components/StatusSelectorPopup.js.map +1 -0
- package/dist/module/components/WidgetLarge.js +9 -0
- package/dist/module/components/WidgetLarge.js.map +1 -0
- package/dist/module/components/WidgetSmall.js +171 -0
- package/dist/module/components/WidgetSmall.js.map +1 -0
- package/dist/module/core.config.js +17 -0
- package/dist/module/core.config.js.map +1 -0
- package/dist/module/feature.config.js +75 -0
- package/dist/module/feature.config.js.map +1 -0
- package/dist/module/helper.js +33 -0
- package/dist/module/helper.js.map +1 -0
- package/dist/module/images/speechbubble.png +0 -0
- package/dist/module/index.js +25 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/reducers/JobsReducer.js +63 -0
- package/dist/module/reducers/JobsReducer.js.map +1 -0
- package/dist/module/screens/JobTypePicker.js +130 -0
- package/dist/module/screens/JobTypePicker.js.map +1 -0
- package/dist/module/screens/MaintenancePage.js +92 -0
- package/dist/module/screens/MaintenancePage.js.map +1 -0
- package/dist/module/screens/RequestDetail.js +980 -0
- package/dist/module/screens/RequestDetail.js.map +1 -0
- package/dist/module/screens/RequestNotes.js +390 -0
- package/dist/module/screens/RequestNotes.js.map +1 -0
- package/dist/module/screens/ServiceRequest.js +1243 -0
- package/dist/module/screens/ServiceRequest.js.map +1 -0
- package/dist/module/values.config.a.js +30 -0
- package/dist/module/values.config.a.js.map +1 -0
- package/dist/module/values.config.b.js +30 -0
- package/dist/module/values.config.b.js.map +1 -0
- package/dist/module/values.config.c.js +30 -0
- package/dist/module/values.config.c.js.map +1 -0
- package/dist/module/values.config.d.js +30 -0
- package/dist/module/values.config.d.js.map +1 -0
- package/dist/module/values.config.default.js +35 -0
- package/dist/module/values.config.default.js.map +1 -0
- package/dist/module/values.config.forms.js +35 -0
- package/dist/module/values.config.forms.js.map +1 -0
- package/dist/module/values.config.js +35 -0
- package/dist/module/values.config.js.map +1 -0
- package/package.json +53 -0
- package/src/actions/JobActions.js +22 -0
- package/src/actions/index.js +1 -0
- package/src/actions/types.js +5 -0
- package/src/apis/index.js +1 -0
- package/src/apis/maintenanceActions.js +163 -0
- package/src/components/FilterPopupMenu.js +256 -0
- package/src/components/MaintenanceList.js +335 -0
- package/src/components/MaintenanceListItem.js +289 -0
- package/src/components/MaintenanceWidgetItem.js +132 -0
- package/src/components/StatusSelectorPopup.js +87 -0
- package/src/components/WidgetLarge.js +10 -0
- package/src/components/WidgetSmall.js +152 -0
- package/src/core.config.js +5 -0
- package/src/feature.config.js +73 -0
- package/src/helper.js +39 -0
- package/src/images/speechbubble.png +0 -0
- package/src/index.js +25 -0
- package/src/reducers/JobsReducer.js +51 -0
- package/src/screens/JobTypePicker.js +107 -0
- package/src/screens/MaintenancePage.js +96 -0
- package/src/screens/RequestDetail.js +915 -0
- package/src/screens/RequestNotes.js +418 -0
- package/src/screens/ServiceRequest.js +1219 -0
- package/src/values.config.a.js +30 -0
- package/src/values.config.b.js +30 -0
- package/src/values.config.c.js +30 -0
- package/src/values.config.d.js +30 -0
- package/src/values.config.default.js +35 -0
- package/src/values.config.forms.js +35 -0
- package/src/values.config.js +35 -0
|
@@ -0,0 +1,1243 @@
|
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
+
import React, { Component } from 'react';
|
|
5
|
+
import { Dimensions, Platform, KeyboardAvoidingView, ScrollView, Text, TouchableOpacity, View, Switch, FlatList, ImageBackground, Keyboard } from 'react-native';
|
|
6
|
+
import DateTimePicker from 'react-native-modal-datetime-picker';
|
|
7
|
+
import { Icon } from 'react-native-elements';
|
|
8
|
+
import _ from 'lodash';
|
|
9
|
+
import moment from 'moment';
|
|
10
|
+
import { connect } from 'react-redux';
|
|
11
|
+
import { jobAdded } from '../actions';
|
|
12
|
+
import { maintenanceActions } from '../apis';
|
|
13
|
+
import { Services } from '../feature.config';
|
|
14
|
+
import { Components, Colours, Helper, Config } from '../core.config';
|
|
15
|
+
import { values } from '../values.config';
|
|
16
|
+
const PHOTO_SIZE = (Dimensions.get('window').width - 64) / 3;
|
|
17
|
+
class MaintenanceRequest extends Component {
|
|
18
|
+
constructor(props) {
|
|
19
|
+
super(props);
|
|
20
|
+
_defineProperty(this, "onChangeAnswer", (fieldId, answer) => {
|
|
21
|
+
const update = {
|
|
22
|
+
customFields: _.cloneDeep(this.state.customFields)
|
|
23
|
+
};
|
|
24
|
+
const field = update.customFields[fieldId];
|
|
25
|
+
field.answer = answer;
|
|
26
|
+
if (field.isTitle) update.title = field.answer;
|
|
27
|
+
this.setState(update);
|
|
28
|
+
});
|
|
29
|
+
_defineProperty(this, "onChangeToggleAnswer", (fieldId, answer) => {
|
|
30
|
+
const update = {
|
|
31
|
+
customFields: _.cloneDeep(this.state.customFields)
|
|
32
|
+
};
|
|
33
|
+
const field = update.customFields[fieldId];
|
|
34
|
+
field.answer = field.answer === answer ? undefined : answer;
|
|
35
|
+
if (field.isTitle) update.title = field.answer;
|
|
36
|
+
this.setState(update);
|
|
37
|
+
});
|
|
38
|
+
_defineProperty(this, "onChangeCheckboxAnswer", (fieldId, answer) => {
|
|
39
|
+
const update = {
|
|
40
|
+
customFields: _.cloneDeep(this.state.customFields)
|
|
41
|
+
};
|
|
42
|
+
const field = update.customFields[fieldId];
|
|
43
|
+
field.answer = _.xor(field.answer || [], [answer]);
|
|
44
|
+
if (field.isTitle) update.title = field.answer.join(', ');
|
|
45
|
+
this.setState(update);
|
|
46
|
+
});
|
|
47
|
+
_defineProperty(this, "onOpenDatePicker", (field, fieldId) => {
|
|
48
|
+
Keyboard.dismiss();
|
|
49
|
+
this.setState({
|
|
50
|
+
dateFieldId: fieldId,
|
|
51
|
+
popUpType: field.type,
|
|
52
|
+
isDateTimePickerVisible: true
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
_defineProperty(this, "onClearDate", fieldId => {
|
|
56
|
+
const update = {
|
|
57
|
+
customFields: _.cloneDeep(this.state.customFields)
|
|
58
|
+
};
|
|
59
|
+
const field = update.customFields[fieldId];
|
|
60
|
+
field.answer = undefined;
|
|
61
|
+
if (field.isTitle) update.title = field.answer;
|
|
62
|
+
this.setState(update);
|
|
63
|
+
});
|
|
64
|
+
_defineProperty(this, "onDateSelected", date => {
|
|
65
|
+
const {
|
|
66
|
+
customFields,
|
|
67
|
+
dateFieldId,
|
|
68
|
+
popUpType
|
|
69
|
+
} = this.state;
|
|
70
|
+
const update = {
|
|
71
|
+
customFields: _.cloneDeep(customFields),
|
|
72
|
+
isDateTimePickerVisible: false,
|
|
73
|
+
fieldId: null
|
|
74
|
+
};
|
|
75
|
+
const field = update.customFields[dateFieldId];
|
|
76
|
+
const dateObj = moment(date);
|
|
77
|
+
if (popUpType === 'date') {
|
|
78
|
+
field.answer = dateObj.format('YYYY-MM-DD');
|
|
79
|
+
if (field.isTitle) update.title = dateObj.format('DD MMM YYYY');
|
|
80
|
+
} else {
|
|
81
|
+
field.answer = dateObj.format('HH:mm');
|
|
82
|
+
if (field.isTitle) update.title = dateObj.format('h:mm a');
|
|
83
|
+
}
|
|
84
|
+
this.setState(update);
|
|
85
|
+
});
|
|
86
|
+
_defineProperty(this, "onUploadStarted", (uploadUri, imageUri) => {
|
|
87
|
+
const {
|
|
88
|
+
imageFieldId
|
|
89
|
+
} = this.state;
|
|
90
|
+
const imagesUpdate = this.getImages(imageFieldId);
|
|
91
|
+
imagesUpdate.splice(imagesUpdate.length - 1, 0, {
|
|
92
|
+
uploading: true,
|
|
93
|
+
uploadProgress: '0%',
|
|
94
|
+
uploadUri,
|
|
95
|
+
imageUri,
|
|
96
|
+
allowRetry: true
|
|
97
|
+
});
|
|
98
|
+
this.setImages(imagesUpdate, imageFieldId);
|
|
99
|
+
});
|
|
100
|
+
_defineProperty(this, "onUploadProgress", progress => {
|
|
101
|
+
const {
|
|
102
|
+
imageFieldId
|
|
103
|
+
} = this.state;
|
|
104
|
+
const imagesUpdate = this.getImages(imageFieldId);
|
|
105
|
+
imagesUpdate.map(img => {
|
|
106
|
+
if (img.uploadUri === progress.uri) {
|
|
107
|
+
img.uploadProgress = progress.percentage;
|
|
108
|
+
img.uploading = true;
|
|
109
|
+
img.allowRetry = true;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
this.setImages(imagesUpdate, imageFieldId);
|
|
113
|
+
});
|
|
114
|
+
_defineProperty(this, "onUploadSuccess", async (uri, uploadUri) => {
|
|
115
|
+
const {
|
|
116
|
+
imageFieldId
|
|
117
|
+
} = this.state;
|
|
118
|
+
const imagesUpdate = this.getImages(imageFieldId);
|
|
119
|
+
imagesUpdate.map(img => {
|
|
120
|
+
if (img.uploadUri === uploadUri && img.uploading) {
|
|
121
|
+
img.url = uri.replace('/general/', '/general1400/');
|
|
122
|
+
img.thumbNailExists = false;
|
|
123
|
+
img.thumbNailUrl = Helper.getThumb300(img.url);
|
|
124
|
+
img.allowRetry = true;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
this.setImages(imagesUpdate, imageFieldId, () => this.waitForThumbnails());
|
|
128
|
+
});
|
|
129
|
+
_defineProperty(this, "onUploadFailed", uploadUri => {
|
|
130
|
+
const {
|
|
131
|
+
imageFieldId
|
|
132
|
+
} = this.state;
|
|
133
|
+
const imagesUpdate = this.getImages(imageFieldId);
|
|
134
|
+
imagesUpdate.map(img => {
|
|
135
|
+
if (img.uploadUri === uploadUri) {
|
|
136
|
+
img.uploading = true; // Requried for retry
|
|
137
|
+
img.uploadProgress = '';
|
|
138
|
+
img.allowRetry = true;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
this.setImages(imagesUpdate, imageFieldId);
|
|
142
|
+
});
|
|
143
|
+
_defineProperty(this, "onLibrarySelected", uri => {
|
|
144
|
+
const {
|
|
145
|
+
imageFieldId
|
|
146
|
+
} = this.state;
|
|
147
|
+
const imagesUpdate = this.getImages(imageFieldId);
|
|
148
|
+
imagesUpdate.splice(imagesUpdate.length - 1, 0, {
|
|
149
|
+
uploading: false,
|
|
150
|
+
allowRetry: false,
|
|
151
|
+
url: Helper.get1400(uri),
|
|
152
|
+
thumbNailExists: true,
|
|
153
|
+
thumbNailUrl: Helper.getThumb300(uri)
|
|
154
|
+
});
|
|
155
|
+
this.setImages(imagesUpdate, imageFieldId);
|
|
156
|
+
});
|
|
157
|
+
_defineProperty(this, "isFieldValid", (field, fieldId) => {
|
|
158
|
+
const {
|
|
159
|
+
mandatory,
|
|
160
|
+
type,
|
|
161
|
+
answer
|
|
162
|
+
} = field;
|
|
163
|
+
if (['staticTitle', 'staticText'].includes(type)) return true;
|
|
164
|
+
const imagesList = type === 'image' ? this.getImageUrls(fieldId) : [];
|
|
165
|
+
const checkMandatory = () => {
|
|
166
|
+
if (!mandatory) return true;
|
|
167
|
+
switch (type) {
|
|
168
|
+
case 'yn':
|
|
169
|
+
return _.isBoolean(answer);
|
|
170
|
+
case 'image':
|
|
171
|
+
return imagesList.length > 0;
|
|
172
|
+
case 'checkbox':
|
|
173
|
+
return _.isArray(answer) && answer.length > 0;
|
|
174
|
+
default:
|
|
175
|
+
return !_.isNil(answer) && !_.isEmpty(answer);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const checkFormat = () => {
|
|
179
|
+
if (_.isNil(answer) || _.isEmpty(answer)) return true;
|
|
180
|
+
switch (type) {
|
|
181
|
+
case 'email':
|
|
182
|
+
return Helper.isEmail(answer);
|
|
183
|
+
case 'date':
|
|
184
|
+
return moment(answer, 'YYYY-MM-DD', true).isValid();
|
|
185
|
+
case 'time':
|
|
186
|
+
return moment(answer, 'HH:mm', true).isValid();
|
|
187
|
+
default:
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const valid = checkMandatory() && checkFormat();
|
|
192
|
+
return valid;
|
|
193
|
+
});
|
|
194
|
+
_defineProperty(this, "showUploadMenu", fieldId => {
|
|
195
|
+
Keyboard.dismiss();
|
|
196
|
+
if (this.state.uploadingImage || this.state.submitting) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (fieldId) this.setState({
|
|
200
|
+
imageFieldId: fieldId
|
|
201
|
+
});
|
|
202
|
+
this.imageUploader.showUploadMenu();
|
|
203
|
+
});
|
|
204
|
+
_defineProperty(this, "submit", async () => {
|
|
205
|
+
this.setState({
|
|
206
|
+
submitting: true
|
|
207
|
+
});
|
|
208
|
+
let description = this.state.description;
|
|
209
|
+
if (this.state.isHome) {
|
|
210
|
+
description = description + `. -- Times Available: ${this.state.times}`;
|
|
211
|
+
}
|
|
212
|
+
setTimeout(() => {
|
|
213
|
+
this.scrollContainer.scrollTo({
|
|
214
|
+
y: 0
|
|
215
|
+
});
|
|
216
|
+
}, 100);
|
|
217
|
+
const images = this.getImageUrls();
|
|
218
|
+
|
|
219
|
+
// Fix custom images field answers
|
|
220
|
+
const customFields = _.cloneDeep(this.state.customFields);
|
|
221
|
+
const updatedCustomFields = customFields.map((field, fieldId) => {
|
|
222
|
+
if (field.type === 'image') field.answer = this.getImageUrls(fieldId);
|
|
223
|
+
return field;
|
|
224
|
+
});
|
|
225
|
+
maintenanceActions.sendMaintenanceRequest(this.props.uid, this.state.userName, this.state.phone, this.state.roomNumber, this.state.title, description, null, this.state.type, images, Helper.getSite(this.props.site), this.state.isHome, this.state.times, updatedCustomFields).then(res => {
|
|
226
|
+
if (res.data.success) {
|
|
227
|
+
this.refreshRequest(res.data.searchResult);
|
|
228
|
+
if (this.props.onSubmissionSuccess) this.props.onSubmissionSuccess(res.data);
|
|
229
|
+
this.setState({
|
|
230
|
+
submitting: false,
|
|
231
|
+
success: true,
|
|
232
|
+
confirmationToShow: true
|
|
233
|
+
});
|
|
234
|
+
} else {
|
|
235
|
+
this.setState({
|
|
236
|
+
submitting: false
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}).catch(err => {
|
|
240
|
+
console.log('maintenance submission fail.');
|
|
241
|
+
console.log(err);
|
|
242
|
+
this.setState({
|
|
243
|
+
submitting: false
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
_defineProperty(this, "refreshRequest", async id => {
|
|
248
|
+
try {
|
|
249
|
+
const job = await maintenanceActions.getJob(Helper.getSite(this.props.site), id);
|
|
250
|
+
this.props.jobAdded(job.data);
|
|
251
|
+
} catch (error) {
|
|
252
|
+
console.log('refreshRequest error', error);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
_defineProperty(this, "validateCustomFields", () => {
|
|
256
|
+
const {
|
|
257
|
+
customFields
|
|
258
|
+
} = this.state;
|
|
259
|
+
if (!customFields || customFields.length === 0) return true;
|
|
260
|
+
return customFields.every((field, index) => {
|
|
261
|
+
const isValid = this.isFieldValid(field, index);
|
|
262
|
+
return isValid;
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
_defineProperty(this, "getImages", (fieldId = null) => {
|
|
266
|
+
const {
|
|
267
|
+
images,
|
|
268
|
+
customFieldImages
|
|
269
|
+
} = this.state;
|
|
270
|
+
const imagesList = _.cloneDeep(fieldId ? customFieldImages[fieldId] : images);
|
|
271
|
+
if (!imagesList || !Array.isArray(imagesList) || imagesList.length === 0) {
|
|
272
|
+
return [{
|
|
273
|
+
add: true
|
|
274
|
+
}];
|
|
275
|
+
}
|
|
276
|
+
return imagesList;
|
|
277
|
+
});
|
|
278
|
+
_defineProperty(this, "setImages", (imagesList, fieldId = null, callback = null) => {
|
|
279
|
+
let update = {};
|
|
280
|
+
if (fieldId) {
|
|
281
|
+
const customFieldImages = _.cloneDeep(this.state.customFieldImages);
|
|
282
|
+
customFieldImages[fieldId] = imagesList;
|
|
283
|
+
update = {
|
|
284
|
+
customFieldImages
|
|
285
|
+
};
|
|
286
|
+
} else {
|
|
287
|
+
update = {
|
|
288
|
+
images: imagesList
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
this.setState(update, callback);
|
|
292
|
+
});
|
|
293
|
+
_defineProperty(this, "getImageUrls", (fieldId = null) => {
|
|
294
|
+
const imagesList = this.getImages(fieldId);
|
|
295
|
+
return _.filter(imagesList, img => {
|
|
296
|
+
return !img.uploading && !img.add;
|
|
297
|
+
}).map(img => {
|
|
298
|
+
return img.url;
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
_defineProperty(this, "waitForThumbnails", () => {
|
|
302
|
+
if (this.checkThumb) return;
|
|
303
|
+
this.checkThumb = setInterval(async () => {
|
|
304
|
+
const {
|
|
305
|
+
imageFieldId
|
|
306
|
+
} = this.state;
|
|
307
|
+
const imagesList = this.getImages(imageFieldId);
|
|
308
|
+
const imagesUpdate = [];
|
|
309
|
+
await Promise.all(imagesList.map(image => {
|
|
310
|
+
return new Promise(async resolve => {
|
|
311
|
+
const newImage = {
|
|
312
|
+
...image
|
|
313
|
+
};
|
|
314
|
+
imagesUpdate.push(newImage);
|
|
315
|
+
if (newImage.url && !newImage.thumbNailExists) {
|
|
316
|
+
newImage.uploading = false;
|
|
317
|
+
newImage.allowRetry = false;
|
|
318
|
+
newImage.thumbNailExists = await Helper.imageExists(newImage.thumbNailUrl);
|
|
319
|
+
resolve(newImage.thumbNailExists);
|
|
320
|
+
}
|
|
321
|
+
resolve(true);
|
|
322
|
+
});
|
|
323
|
+
}));
|
|
324
|
+
const thumbnailsExist = imagesUpdate.every(image => !image.url || image.thumbNailExists);
|
|
325
|
+
if (thumbnailsExist) {
|
|
326
|
+
clearInterval(this.checkThumb);
|
|
327
|
+
this.checkThumb = null;
|
|
328
|
+
this.setImages(imagesUpdate, imageFieldId);
|
|
329
|
+
}
|
|
330
|
+
}, 2000);
|
|
331
|
+
});
|
|
332
|
+
_defineProperty(this, "removeImage", (index, fieldId) => {
|
|
333
|
+
const imagesUpdate = this.getImages(fieldId);
|
|
334
|
+
imagesUpdate.splice(index, 1);
|
|
335
|
+
this.setImages(imagesUpdate, fieldId);
|
|
336
|
+
});
|
|
337
|
+
_defineProperty(this, "toggleFullscreenVideo", url => {
|
|
338
|
+
if (typeof url !== 'string') url = '';
|
|
339
|
+
this.setState({
|
|
340
|
+
showFullscreenVideo: url.length > 0,
|
|
341
|
+
currentVideoUrl: url
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
this.state = {
|
|
345
|
+
submitting: false,
|
|
346
|
+
success: false,
|
|
347
|
+
fail: false,
|
|
348
|
+
error: null,
|
|
349
|
+
showError: false,
|
|
350
|
+
loadingTypes: values.forceCustomFields,
|
|
351
|
+
userName: '',
|
|
352
|
+
roomNumber: '',
|
|
353
|
+
phone: '',
|
|
354
|
+
title: '',
|
|
355
|
+
description: '',
|
|
356
|
+
times: '',
|
|
357
|
+
type: 'General',
|
|
358
|
+
uploadingImage: false,
|
|
359
|
+
images: [{
|
|
360
|
+
add: true
|
|
361
|
+
}],
|
|
362
|
+
showFullscreenVideo: false,
|
|
363
|
+
currentVideoUrl: '',
|
|
364
|
+
isHome: false,
|
|
365
|
+
types: [],
|
|
366
|
+
confirmationToShow: false,
|
|
367
|
+
customFields: [],
|
|
368
|
+
customFieldImages: {},
|
|
369
|
+
isDateTimePickerVisible: false,
|
|
370
|
+
popUpType: 'date',
|
|
371
|
+
dateFieldId: null,
|
|
372
|
+
imageFieldId: null
|
|
373
|
+
};
|
|
374
|
+
this.checkThumb = null;
|
|
375
|
+
this.keyboardTypes = {
|
|
376
|
+
phone: 'phone-pad',
|
|
377
|
+
email: 'email-address',
|
|
378
|
+
text: 'default'
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
componentDidMount() {
|
|
382
|
+
if (this.props.userType !== 'KIOSK') {
|
|
383
|
+
this.setState({
|
|
384
|
+
userName: this.props.displayName,
|
|
385
|
+
roomNumber: this.props.unit,
|
|
386
|
+
phone: !_.isEmpty(this.props.phoneNumber) ? this.props.phoneNumber : ''
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
this.getJobTypes();
|
|
390
|
+
}
|
|
391
|
+
componentWillUnmount() {
|
|
392
|
+
clearInterval(this.checkThumb);
|
|
393
|
+
}
|
|
394
|
+
onPressBack() {
|
|
395
|
+
Services.navigation.goBack();
|
|
396
|
+
}
|
|
397
|
+
onPressType() {
|
|
398
|
+
Services.navigation.navigate(values.screenJobTypePicker, {
|
|
399
|
+
currentType: this.state.type,
|
|
400
|
+
types: this.state.types,
|
|
401
|
+
onSelectType: this.pickType.bind(this)
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
onCloseConfirmationPopup() {
|
|
405
|
+
this.setState({
|
|
406
|
+
confirmationToShow: false
|
|
407
|
+
});
|
|
408
|
+
Services.navigation.goBack();
|
|
409
|
+
this.props.onBack && this.props.onBack();
|
|
410
|
+
}
|
|
411
|
+
onConfirmationReset() {
|
|
412
|
+
this.setState({
|
|
413
|
+
confirmationToShow: false,
|
|
414
|
+
title: '',
|
|
415
|
+
description: '',
|
|
416
|
+
times: '',
|
|
417
|
+
isHome: false,
|
|
418
|
+
uploadingImage: false,
|
|
419
|
+
images: [{
|
|
420
|
+
add: true
|
|
421
|
+
}],
|
|
422
|
+
submitting: false,
|
|
423
|
+
success: false,
|
|
424
|
+
fail: false,
|
|
425
|
+
customFields: [],
|
|
426
|
+
customFieldImages: {},
|
|
427
|
+
isDateTimePickerVisible: false,
|
|
428
|
+
popUpType: 'date',
|
|
429
|
+
dateFieldId: null,
|
|
430
|
+
imageFieldId: null
|
|
431
|
+
}, () => this.pickType(this.state.type));
|
|
432
|
+
}
|
|
433
|
+
getJobTypes() {
|
|
434
|
+
maintenanceActions.getJobTypes(Helper.getSite(this.props.site)).then(res => {
|
|
435
|
+
this.setState({
|
|
436
|
+
types: res.data
|
|
437
|
+
});
|
|
438
|
+
console.log(res.data);
|
|
439
|
+
this.getDefaultJob();
|
|
440
|
+
}).catch(() => {});
|
|
441
|
+
}
|
|
442
|
+
pickType(type) {
|
|
443
|
+
const {
|
|
444
|
+
types
|
|
445
|
+
} = this.state;
|
|
446
|
+
const selected = types.find(t => t.typeName === type) || {};
|
|
447
|
+
if (values.forceCustomFields && !selected.hasCustomFields) {
|
|
448
|
+
console.log(selected);
|
|
449
|
+
this.setState({
|
|
450
|
+
type,
|
|
451
|
+
customFields: [],
|
|
452
|
+
noType: true
|
|
453
|
+
});
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
this.setState({
|
|
457
|
+
type,
|
|
458
|
+
customFields: selected.hasCustomFields && selected.customFields.length > 0 ? _.cloneDeep(selected.customFields) : [],
|
|
459
|
+
loadingTypes: false
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
getDefaultJob() {
|
|
463
|
+
const {
|
|
464
|
+
types,
|
|
465
|
+
jobId
|
|
466
|
+
} = this.state;
|
|
467
|
+
if (types.length !== 0 && jobId == null) {
|
|
468
|
+
const defaultType = types[0];
|
|
469
|
+
this.pickType(defaultType.typeName);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
submitRequest() {
|
|
473
|
+
const {
|
|
474
|
+
customFields,
|
|
475
|
+
submitting,
|
|
476
|
+
uploadingImage,
|
|
477
|
+
title,
|
|
478
|
+
roomNumber,
|
|
479
|
+
isHome,
|
|
480
|
+
times
|
|
481
|
+
} = this.state;
|
|
482
|
+
const hasCustomFields = customFields && customFields.length > 0;
|
|
483
|
+
if (submitting || !this.props.connected) {
|
|
484
|
+
if (!this.props.connected) {
|
|
485
|
+
this.setState({
|
|
486
|
+
error: {
|
|
487
|
+
message: 'No internet connection detected'
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
if (uploadingImage) return;
|
|
494
|
+
this.setState({
|
|
495
|
+
error: null,
|
|
496
|
+
showError: false
|
|
497
|
+
});
|
|
498
|
+
if (title.length === 0 || !roomNumber || roomNumber.length === 0) {
|
|
499
|
+
console.log('submitRequest - error', {
|
|
500
|
+
title,
|
|
501
|
+
roomNumber
|
|
502
|
+
});
|
|
503
|
+
this.setState({
|
|
504
|
+
showError: true
|
|
505
|
+
});
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
if (hasCustomFields) {
|
|
509
|
+
if (!this.validateCustomFields()) {
|
|
510
|
+
console.log('submitRequest - custom fields error');
|
|
511
|
+
this.setState({
|
|
512
|
+
showError: true
|
|
513
|
+
});
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
} else {
|
|
517
|
+
if (isHome && times.length < 2) {
|
|
518
|
+
console.log('submitRequest - error', {
|
|
519
|
+
isHome,
|
|
520
|
+
times
|
|
521
|
+
});
|
|
522
|
+
this.setState({
|
|
523
|
+
showError: true
|
|
524
|
+
});
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
this.submit();
|
|
529
|
+
}
|
|
530
|
+
renderUploadMenu() {
|
|
531
|
+
return /*#__PURE__*/React.createElement(Components.ImageUploader, {
|
|
532
|
+
ref: ref => this.imageUploader = ref,
|
|
533
|
+
onUploadStarted: this.onUploadStarted,
|
|
534
|
+
onUploadSuccess: this.onUploadSuccess,
|
|
535
|
+
onUploadFailed: this.onUploadFailed,
|
|
536
|
+
onUploadProgress: this.onUploadProgress,
|
|
537
|
+
onLibrarySelected: this.onLibrarySelected,
|
|
538
|
+
size: {
|
|
539
|
+
width: 1400
|
|
540
|
+
},
|
|
541
|
+
quality: 0.8,
|
|
542
|
+
fileName: 'serviceImage',
|
|
543
|
+
popupTitle: 'Upload Image',
|
|
544
|
+
userId: this.props.uid,
|
|
545
|
+
allowsEditing: false,
|
|
546
|
+
multiple: true,
|
|
547
|
+
hideLibrary: true
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
renderImage(item, index, fieldId = null) {
|
|
551
|
+
const isVideoUrl = Helper.isVideo(item.url);
|
|
552
|
+
const imagesList = this.getImages(fieldId);
|
|
553
|
+
if (item.add) {
|
|
554
|
+
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
555
|
+
activeOpacity: 0.8,
|
|
556
|
+
onPress: () => this.showUploadMenu(fieldId)
|
|
557
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
558
|
+
style: [styles.imageContainer, imagesList.length > 1 && styles.imageContainerNotEmpty, index % 3 === 0 && {
|
|
559
|
+
marginLeft: 0
|
|
560
|
+
}, index > 2 && {
|
|
561
|
+
marginTop: 8
|
|
562
|
+
}]
|
|
563
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
564
|
+
style: styles.imageCircle
|
|
565
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
566
|
+
name: "camera",
|
|
567
|
+
type: "font-awesome",
|
|
568
|
+
iconStyle: styles.addImageIcon
|
|
569
|
+
}))));
|
|
570
|
+
}
|
|
571
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
572
|
+
style: [styles.imageContainer, imagesList.length > 1 && styles.imageContainerNotEmpty, index % 3 === 0 && {
|
|
573
|
+
marginLeft: 0
|
|
574
|
+
}, index > 2 && {
|
|
575
|
+
marginTop: 8
|
|
576
|
+
}]
|
|
577
|
+
}, item.uploading ? /*#__PURE__*/React.createElement(Components.ImageUploadProgress, {
|
|
578
|
+
uploader: this.imageUploader,
|
|
579
|
+
image: item,
|
|
580
|
+
color: this.props.colourBrandingMain
|
|
581
|
+
}) : /*#__PURE__*/React.createElement(ImageBackground, {
|
|
582
|
+
style: styles.imageBackground,
|
|
583
|
+
source: Helper.getImageSource(item.thumbNailExists ? item.thumbNailUrl : item.url)
|
|
584
|
+
}, isVideoUrl && /*#__PURE__*/React.createElement(View, {
|
|
585
|
+
style: styles.imagePlayContainer
|
|
586
|
+
}, /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
587
|
+
onPress: this.toggleFullscreenVideo.bind(this, item.url)
|
|
588
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
589
|
+
name: "play",
|
|
590
|
+
type: "font-awesome",
|
|
591
|
+
iconStyle: styles.imageControlIcon
|
|
592
|
+
}))), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
593
|
+
style: styles.removeImage,
|
|
594
|
+
onPress: () => this.removeImage(index, fieldId)
|
|
595
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
596
|
+
name: "remove",
|
|
597
|
+
type: "font-awesome",
|
|
598
|
+
iconStyle: styles.imageControlIcon,
|
|
599
|
+
style: styles.removeImage
|
|
600
|
+
}))));
|
|
601
|
+
}
|
|
602
|
+
renderSuccess() {
|
|
603
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
604
|
+
style: {
|
|
605
|
+
padding: 16,
|
|
606
|
+
flex: 1,
|
|
607
|
+
backgroundColor: '#fff'
|
|
608
|
+
}
|
|
609
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
610
|
+
style: styles.requestSuccess
|
|
611
|
+
}, "Your request has been submitted. Thank you."));
|
|
612
|
+
}
|
|
613
|
+
renderImageList(fieldId = null) {
|
|
614
|
+
const imagesList = this.getImages(fieldId);
|
|
615
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
616
|
+
style: styles.imageSection
|
|
617
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
618
|
+
style: [styles.imageListContainer, imagesList.length < 2 && styles.imageListContainerEmpty]
|
|
619
|
+
}, /*#__PURE__*/React.createElement(FlatList, {
|
|
620
|
+
keyboardShouldPersistTaps: "always",
|
|
621
|
+
enableEmptySections: true,
|
|
622
|
+
data: imagesList,
|
|
623
|
+
renderItem: ({
|
|
624
|
+
item,
|
|
625
|
+
index
|
|
626
|
+
}) => this.renderImage(item, index, fieldId),
|
|
627
|
+
keyExtractor: (item, index) => index,
|
|
628
|
+
numColumns: 3
|
|
629
|
+
})));
|
|
630
|
+
}
|
|
631
|
+
renderDateField(field, fieldId, sectionStyle) {
|
|
632
|
+
let displayText, placeHolder, icon, errorText;
|
|
633
|
+
if (field.type === 'date') {
|
|
634
|
+
displayText = field.answer ? moment(field.answer, 'YYYY-MM-DD').format('DD MMM YYYY') : '';
|
|
635
|
+
placeHolder = 'dd mmm yyyy';
|
|
636
|
+
icon = 'calendar';
|
|
637
|
+
errorText = 'Not a valid date';
|
|
638
|
+
} else {
|
|
639
|
+
displayText = field.answer ? moment(field.answer, 'HH:mm').format('h:mm a') : '';
|
|
640
|
+
placeHolder = '--:-- --';
|
|
641
|
+
icon = 'clock-o';
|
|
642
|
+
errorText = 'Not a valid time';
|
|
643
|
+
}
|
|
644
|
+
return /*#__PURE__*/React.createElement(Components.GenericInputSection, {
|
|
645
|
+
key: fieldId,
|
|
646
|
+
label: field.label,
|
|
647
|
+
sectionStyle: sectionStyle,
|
|
648
|
+
isValid: () => this.isFieldValid(field, fieldId),
|
|
649
|
+
required: field.mandatory,
|
|
650
|
+
showError: this.state.showError,
|
|
651
|
+
errorText: errorText
|
|
652
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
653
|
+
style: styles.dateContainer
|
|
654
|
+
}, /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
655
|
+
style: styles.dateFieldButton,
|
|
656
|
+
onPress: () => this.onOpenDatePicker(field, fieldId)
|
|
657
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
658
|
+
style: styles.dateFieldContainer
|
|
659
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
660
|
+
style: styles.dateText
|
|
661
|
+
}, displayText || placeHolder), /*#__PURE__*/React.createElement(Icon, {
|
|
662
|
+
type: "font-awesome",
|
|
663
|
+
name: icon,
|
|
664
|
+
iconStyle: styles.dateIcon
|
|
665
|
+
}))), displayText ? /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
666
|
+
style: styles.dateClearButton,
|
|
667
|
+
onPress: () => this.onClearDate(fieldId)
|
|
668
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
669
|
+
type: "font-awesome",
|
|
670
|
+
name: "times",
|
|
671
|
+
iconStyle: styles.removeIcon
|
|
672
|
+
})) : null));
|
|
673
|
+
}
|
|
674
|
+
renderField(field, fieldId) {
|
|
675
|
+
const sectionStyle = {
|
|
676
|
+
marginTop: fieldId === 0 ? 24 : 0,
|
|
677
|
+
marginBottom: 24
|
|
678
|
+
};
|
|
679
|
+
switch (field.type) {
|
|
680
|
+
case 'yn':
|
|
681
|
+
return /*#__PURE__*/React.createElement(Components.GenericInputSection, {
|
|
682
|
+
key: fieldId,
|
|
683
|
+
label: field.label,
|
|
684
|
+
sectionStyle: sectionStyle,
|
|
685
|
+
inputType: "toggle",
|
|
686
|
+
value: field.answer,
|
|
687
|
+
onChange: answer => this.onChangeToggleAnswer(fieldId, answer),
|
|
688
|
+
isValid: () => this.isFieldValid(field, fieldId),
|
|
689
|
+
showError: this.state.showError,
|
|
690
|
+
required: field.mandatory
|
|
691
|
+
});
|
|
692
|
+
case 'multichoice':
|
|
693
|
+
return /*#__PURE__*/React.createElement(Components.GenericInputSection, {
|
|
694
|
+
key: fieldId,
|
|
695
|
+
label: field.label,
|
|
696
|
+
sectionStyle: sectionStyle,
|
|
697
|
+
inputType: "radio",
|
|
698
|
+
value: field.answer,
|
|
699
|
+
onChange: answer => this.onChangeToggleAnswer(fieldId, answer),
|
|
700
|
+
options: field.values.map(o => {
|
|
701
|
+
return {
|
|
702
|
+
Label: o,
|
|
703
|
+
Value: o
|
|
704
|
+
};
|
|
705
|
+
}),
|
|
706
|
+
isValid: () => this.isFieldValid(field, fieldId),
|
|
707
|
+
showError: this.state.showError,
|
|
708
|
+
required: field.mandatory
|
|
709
|
+
});
|
|
710
|
+
case 'checkbox':
|
|
711
|
+
return /*#__PURE__*/React.createElement(Components.GenericInputSection, {
|
|
712
|
+
key: fieldId,
|
|
713
|
+
label: field.label,
|
|
714
|
+
sectionStyle: sectionStyle,
|
|
715
|
+
isValid: () => this.isFieldValid(field, fieldId),
|
|
716
|
+
showError: this.state.showError,
|
|
717
|
+
required: field.mandatory
|
|
718
|
+
}, field.values.map((o, i) => {
|
|
719
|
+
const isActive = field.answer && _.includes(field.answer, o);
|
|
720
|
+
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
721
|
+
onPress: () => this.onChangeCheckboxAnswer(fieldId, o),
|
|
722
|
+
key: i,
|
|
723
|
+
style: styles.multiChoiceOption,
|
|
724
|
+
hitSlop: {
|
|
725
|
+
top: 8,
|
|
726
|
+
left: 8,
|
|
727
|
+
bottom: 8,
|
|
728
|
+
right: 8
|
|
729
|
+
}
|
|
730
|
+
}, isActive ? /*#__PURE__*/React.createElement(Components.TickIcon, {
|
|
731
|
+
style: styles.tick,
|
|
732
|
+
size: 20,
|
|
733
|
+
color: this.props.colourBrandingMain
|
|
734
|
+
}) : /*#__PURE__*/React.createElement(View, {
|
|
735
|
+
style: styles.unticked
|
|
736
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
737
|
+
style: styles.multiChoiceText
|
|
738
|
+
}, o));
|
|
739
|
+
}));
|
|
740
|
+
case 'text':
|
|
741
|
+
case 'email':
|
|
742
|
+
case 'phone':
|
|
743
|
+
return /*#__PURE__*/React.createElement(Components.GenericInputSection, {
|
|
744
|
+
key: fieldId,
|
|
745
|
+
label: field.label,
|
|
746
|
+
placeholder: field.placeHolder,
|
|
747
|
+
value: field.answer,
|
|
748
|
+
onChangeText: val => this.onChangeAnswer(fieldId, val),
|
|
749
|
+
editable: true,
|
|
750
|
+
squaredCorners: true,
|
|
751
|
+
isValid: () => this.isFieldValid(field, fieldId),
|
|
752
|
+
showError: this.state.showError,
|
|
753
|
+
errorText: field.type === 'email' ? 'Not a valid email' : undefined,
|
|
754
|
+
required: field.mandatory,
|
|
755
|
+
sectionStyle: sectionStyle,
|
|
756
|
+
autoCapitalize: "sentences",
|
|
757
|
+
keyboardType: this.keyboardTypes[field.type]
|
|
758
|
+
});
|
|
759
|
+
case 'staticTitle':
|
|
760
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
761
|
+
key: fieldId,
|
|
762
|
+
style: [styles.staticTitle, {
|
|
763
|
+
color: this.props.colourBrandingMain
|
|
764
|
+
}, sectionStyle]
|
|
765
|
+
}, field.label);
|
|
766
|
+
case 'staticText':
|
|
767
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
768
|
+
key: fieldId,
|
|
769
|
+
style: [styles.staticText, sectionStyle]
|
|
770
|
+
}, Helper.toParagraphed(field.label, styles.staticText));
|
|
771
|
+
case 'date':
|
|
772
|
+
case 'time':
|
|
773
|
+
return this.renderDateField(field, fieldId, sectionStyle);
|
|
774
|
+
case 'image':
|
|
775
|
+
return /*#__PURE__*/React.createElement(Components.GenericInputSection, {
|
|
776
|
+
key: fieldId,
|
|
777
|
+
label: field.label,
|
|
778
|
+
sectionStyle: sectionStyle,
|
|
779
|
+
isValid: () => this.isFieldValid(field, fieldId),
|
|
780
|
+
required: field.mandatory,
|
|
781
|
+
showError: this.state.showError
|
|
782
|
+
}, this.renderImageList(fieldId));
|
|
783
|
+
default:
|
|
784
|
+
return null;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
renderCustomFields() {
|
|
788
|
+
const {
|
|
789
|
+
customFields
|
|
790
|
+
} = this.state;
|
|
791
|
+
if (!customFields || customFields.length === 0) return null;
|
|
792
|
+
return /*#__PURE__*/React.createElement(Components.FormCard, {
|
|
793
|
+
style: {
|
|
794
|
+
marginTop: 16
|
|
795
|
+
}
|
|
796
|
+
}, customFields.map((field, i) => this.renderField(field, i)));
|
|
797
|
+
}
|
|
798
|
+
renderForm() {
|
|
799
|
+
const {
|
|
800
|
+
customFields,
|
|
801
|
+
loadingTypes
|
|
802
|
+
} = this.state;
|
|
803
|
+
const hasCustomFields = customFields && customFields.length > 0;
|
|
804
|
+
if (loadingTypes) {
|
|
805
|
+
return /*#__PURE__*/React.createElement(Components.Spinner, null);
|
|
806
|
+
}
|
|
807
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
808
|
+
style: {
|
|
809
|
+
flex: 1
|
|
810
|
+
}
|
|
811
|
+
}, /*#__PURE__*/React.createElement(ScrollView, {
|
|
812
|
+
keyboardShouldPersistTaps: "always",
|
|
813
|
+
style: {
|
|
814
|
+
flex: 1
|
|
815
|
+
},
|
|
816
|
+
ref: ref => this.scrollContainer = ref
|
|
817
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
818
|
+
style: {
|
|
819
|
+
paddingBottom: 2
|
|
820
|
+
}
|
|
821
|
+
}, /*#__PURE__*/React.createElement(Components.LoadingIndicator, {
|
|
822
|
+
visible: this.state.submitting
|
|
823
|
+
}), this.state.error && /*#__PURE__*/React.createElement(Text, {
|
|
824
|
+
style: styles.errorText
|
|
825
|
+
}, this.state.error), /*#__PURE__*/React.createElement(Components.FormCard, {
|
|
826
|
+
style: {
|
|
827
|
+
marginTop: 16
|
|
828
|
+
}
|
|
829
|
+
}, /*#__PURE__*/React.createElement(Components.FormCardSection, {
|
|
830
|
+
label: 'Name',
|
|
831
|
+
placeholder: 'Enter your name',
|
|
832
|
+
textValue: this.state.userName,
|
|
833
|
+
onChangeText: userName => this.setState({
|
|
834
|
+
userName
|
|
835
|
+
}),
|
|
836
|
+
editable: this.props.userType === 'KIOSK' && this.state.submitting === false,
|
|
837
|
+
isValid: () => {
|
|
838
|
+
return this.state.userName.length > 1;
|
|
839
|
+
},
|
|
840
|
+
required: true,
|
|
841
|
+
errorText: "Please enter your name.",
|
|
842
|
+
showError: this.state.showError && this.state.userName.length < 2,
|
|
843
|
+
hasUnderline: true
|
|
844
|
+
}), /*#__PURE__*/React.createElement(Components.FormCardSection, {
|
|
845
|
+
label: 'Contact number',
|
|
846
|
+
placeholder: 'Enter phone number',
|
|
847
|
+
textValue: this.state.phone,
|
|
848
|
+
onChangeText: phone => this.setState({
|
|
849
|
+
phone
|
|
850
|
+
}),
|
|
851
|
+
editable: this.state.submitting === false,
|
|
852
|
+
hasUnderline: true,
|
|
853
|
+
keyboardType: 'phone-pad'
|
|
854
|
+
}), /*#__PURE__*/React.createElement(Components.FormCardSection, {
|
|
855
|
+
label: 'Address',
|
|
856
|
+
placeholder: 'Enter your address',
|
|
857
|
+
textValue: this.state.roomNumber,
|
|
858
|
+
onChangeText: roomNumber => this.setState({
|
|
859
|
+
roomNumber
|
|
860
|
+
}),
|
|
861
|
+
editable: this.state.submitting === false,
|
|
862
|
+
hasUnderline: true,
|
|
863
|
+
isValid: () => {
|
|
864
|
+
return this.state.roomNumber && this.state.roomNumber.length > 1;
|
|
865
|
+
},
|
|
866
|
+
required: true,
|
|
867
|
+
errorText: "Please provide your address.",
|
|
868
|
+
showError: this.state.showError && (!this.state.roomNumber || this.state.roomNumber.length < 2)
|
|
869
|
+
})), /*#__PURE__*/React.createElement(Components.FormCard, {
|
|
870
|
+
style: {
|
|
871
|
+
marginTop: 16,
|
|
872
|
+
paddingHorizontal: 24,
|
|
873
|
+
paddingVertical: 16,
|
|
874
|
+
flexDirection: 'row',
|
|
875
|
+
justifyContent: 'space-between'
|
|
876
|
+
}
|
|
877
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
878
|
+
style: styles.sectionTitle
|
|
879
|
+
}, Config.env.strings.JOB_TYPE), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
880
|
+
onPress: this.onPressType.bind(this)
|
|
881
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
882
|
+
style: {
|
|
883
|
+
flexDirection: 'row'
|
|
884
|
+
}
|
|
885
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
886
|
+
style: [styles.sectionTitle, {
|
|
887
|
+
color: this.props.colourBrandingMain,
|
|
888
|
+
marginRight: 16
|
|
889
|
+
}]
|
|
890
|
+
}, this.state.type), /*#__PURE__*/React.createElement(Icon, {
|
|
891
|
+
name: "angle-right",
|
|
892
|
+
type: "font-awesome",
|
|
893
|
+
iconStyle: [styles.sectionTitle, {
|
|
894
|
+
fontSize: 20,
|
|
895
|
+
color: this.props.colourBrandingMain
|
|
896
|
+
}]
|
|
897
|
+
})))), hasCustomFields ? this.renderCustomFields() : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Components.FormCard, {
|
|
898
|
+
style: {
|
|
899
|
+
marginTop: 16
|
|
900
|
+
}
|
|
901
|
+
}, /*#__PURE__*/React.createElement(Components.FormCardSection, {
|
|
902
|
+
label: 'Title',
|
|
903
|
+
placeholder: 'Enter a title for your request',
|
|
904
|
+
textValue: this.state.title,
|
|
905
|
+
onChangeText: title => this.setState({
|
|
906
|
+
title
|
|
907
|
+
}),
|
|
908
|
+
editable: this.state.submitting === false,
|
|
909
|
+
hasUnderline: true,
|
|
910
|
+
isValid: () => {
|
|
911
|
+
return this.state.title.length > 1;
|
|
912
|
+
},
|
|
913
|
+
required: true,
|
|
914
|
+
errorText: "Please provide a title.",
|
|
915
|
+
showError: this.state.showError && this.state.title.length < 2,
|
|
916
|
+
autoCorrect: true,
|
|
917
|
+
multiline: true,
|
|
918
|
+
autoGrow: true
|
|
919
|
+
}), /*#__PURE__*/React.createElement(Components.FormCardSection, {
|
|
920
|
+
label: 'Description',
|
|
921
|
+
placeholder: 'Describe your request here in detail',
|
|
922
|
+
textValue: this.state.description,
|
|
923
|
+
onChangeText: description => this.setState({
|
|
924
|
+
description
|
|
925
|
+
}),
|
|
926
|
+
editable: this.state.submitting === false,
|
|
927
|
+
hasUnderline: true,
|
|
928
|
+
autoCorrect: true,
|
|
929
|
+
multiline: true,
|
|
930
|
+
autoGrow: true
|
|
931
|
+
})), /*#__PURE__*/React.createElement(Components.FormCard, {
|
|
932
|
+
style: {
|
|
933
|
+
marginTop: 16,
|
|
934
|
+
paddingHorizontal: 24
|
|
935
|
+
}
|
|
936
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
937
|
+
style: [{
|
|
938
|
+
width: '100%',
|
|
939
|
+
paddingVertical: 16,
|
|
940
|
+
flexDirection: 'row',
|
|
941
|
+
justifyContent: 'space-between',
|
|
942
|
+
alignItems: 'center',
|
|
943
|
+
position: 'relative'
|
|
944
|
+
}, this.state.isHome && {
|
|
945
|
+
borderBottomWidth: 1,
|
|
946
|
+
borderBottomColor: Colours.LINEGREY
|
|
947
|
+
}]
|
|
948
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
949
|
+
style: styles.sectionTitle
|
|
950
|
+
}, Config.env.strings.MAINTENANCE_HOME), /*#__PURE__*/React.createElement(Switch, {
|
|
951
|
+
value: this.state.isHome,
|
|
952
|
+
disabled: this.state.submitting,
|
|
953
|
+
onValueChange: value => this.setState({
|
|
954
|
+
isHome: value
|
|
955
|
+
}),
|
|
956
|
+
trackColor: {
|
|
957
|
+
false: '#ddd',
|
|
958
|
+
true: this.props.colourBrandingMain
|
|
959
|
+
},
|
|
960
|
+
thumbColor: Platform.OS === 'android' ? '#fff' : null
|
|
961
|
+
})), this.state.isHome && /*#__PURE__*/React.createElement(Components.FormCardSection, {
|
|
962
|
+
label: 'Available times',
|
|
963
|
+
placeholder: 'Describe your available times here in detail.',
|
|
964
|
+
textValue: this.state.times,
|
|
965
|
+
onChangeText: times => this.setState({
|
|
966
|
+
times
|
|
967
|
+
}),
|
|
968
|
+
editable: this.state.submitting === false,
|
|
969
|
+
hasUnderline: true,
|
|
970
|
+
isValid: () => {
|
|
971
|
+
return this.state.times.length > 1;
|
|
972
|
+
},
|
|
973
|
+
required: true,
|
|
974
|
+
errorText: "Please provide available times.",
|
|
975
|
+
showError: this.state.showError && this.state.isHome && this.state.times.length < 2,
|
|
976
|
+
minHeight: 40,
|
|
977
|
+
autoCorrect: true,
|
|
978
|
+
multiline: true,
|
|
979
|
+
autoGrow: true
|
|
980
|
+
})), this.renderImageList()))));
|
|
981
|
+
}
|
|
982
|
+
renderRegisterConfirmation() {
|
|
983
|
+
return /*#__PURE__*/React.createElement(Components.ConfirmationPopup, {
|
|
984
|
+
confirmText: `${values.textEntityName} submitted`,
|
|
985
|
+
repeatText: 'Submit another',
|
|
986
|
+
visible: this.state.confirmationToShow,
|
|
987
|
+
onClose: this.onCloseConfirmationPopup.bind(this),
|
|
988
|
+
onPressAction: this.onConfirmationReset.bind(this)
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
renderVideoPlayerPopup() {
|
|
992
|
+
const {
|
|
993
|
+
showFullscreenVideo,
|
|
994
|
+
currentVideoUrl
|
|
995
|
+
} = this.state;
|
|
996
|
+
if (!currentVideoUrl) return;
|
|
997
|
+
return /*#__PURE__*/React.createElement(Components.VideoPopup, {
|
|
998
|
+
uri: currentVideoUrl,
|
|
999
|
+
visible: showFullscreenVideo,
|
|
1000
|
+
showFullscreenButton: false,
|
|
1001
|
+
onClose: this.toggleFullscreenVideo
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
renderNoType() {
|
|
1005
|
+
if (!this.state.noType) {
|
|
1006
|
+
return null;
|
|
1007
|
+
}
|
|
1008
|
+
return /*#__PURE__*/React.createElement(Components.WarningPopup, {
|
|
1009
|
+
confirmText: 'No forms are available',
|
|
1010
|
+
infoText: 'Check back later for forms.',
|
|
1011
|
+
visible: this.state.noType,
|
|
1012
|
+
onClose: this.onPressBack.bind(this),
|
|
1013
|
+
padHorizontal: true
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
render() {
|
|
1017
|
+
const {
|
|
1018
|
+
submitting,
|
|
1019
|
+
success,
|
|
1020
|
+
isDateTimePickerVisible,
|
|
1021
|
+
popUpType
|
|
1022
|
+
} = this.state;
|
|
1023
|
+
return /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
|
|
1024
|
+
behavior: Platform.OS === 'ios' && 'padding',
|
|
1025
|
+
style: styles.viewContainer
|
|
1026
|
+
}, this.renderUploadMenu(), /*#__PURE__*/React.createElement(View, {
|
|
1027
|
+
style: styles.container
|
|
1028
|
+
}, /*#__PURE__*/React.createElement(Components.Header, {
|
|
1029
|
+
leftIcon: "angle-left",
|
|
1030
|
+
onPressLeft: this.onPressBack.bind(this),
|
|
1031
|
+
text: this.props.strings[`${values.featureKey}_textFeatureTitle`] || values.textFeatureTitle,
|
|
1032
|
+
rightText: submitting || success ? null : 'Done',
|
|
1033
|
+
onPressRight: this.submitRequest.bind(this),
|
|
1034
|
+
absoluteRight: true
|
|
1035
|
+
}), this.renderForm()), this.renderRegisterConfirmation(), this.renderVideoPlayerPopup(), this.renderNoType(), /*#__PURE__*/React.createElement(DateTimePicker, {
|
|
1036
|
+
isVisible: isDateTimePickerVisible,
|
|
1037
|
+
onConfirm: this.onDateSelected,
|
|
1038
|
+
onCancel: () => this.setState({
|
|
1039
|
+
isDateTimePickerVisible: false
|
|
1040
|
+
}),
|
|
1041
|
+
mode: popUpType,
|
|
1042
|
+
headerTextIOS: `Pick a ${popUpType}`
|
|
1043
|
+
}));
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
const styles = {
|
|
1047
|
+
viewContainer: {
|
|
1048
|
+
flex: 1,
|
|
1049
|
+
backgroundColor: '#fff'
|
|
1050
|
+
},
|
|
1051
|
+
container: {
|
|
1052
|
+
flex: 1,
|
|
1053
|
+
position: 'relative',
|
|
1054
|
+
backgroundColor: '#f0f0f5'
|
|
1055
|
+
},
|
|
1056
|
+
errorText: {
|
|
1057
|
+
fontFamily: 'sf-regular',
|
|
1058
|
+
color: Colours.COLOUR_TANGERINE,
|
|
1059
|
+
fontSize: 16
|
|
1060
|
+
},
|
|
1061
|
+
requestSuccess: {
|
|
1062
|
+
fontFamily: 'sf-regular',
|
|
1063
|
+
color: Colours.TEXT_DARK,
|
|
1064
|
+
fontSize: 17,
|
|
1065
|
+
textAlign: 'center'
|
|
1066
|
+
},
|
|
1067
|
+
sectionTitle: {
|
|
1068
|
+
fontFamily: 'sf-regular',
|
|
1069
|
+
fontSize: 17,
|
|
1070
|
+
color: Colours.TEXT_DARK
|
|
1071
|
+
},
|
|
1072
|
+
imageListContainer: {
|
|
1073
|
+
marginTop: 8,
|
|
1074
|
+
padding: 8,
|
|
1075
|
+
flexDirection: 'row',
|
|
1076
|
+
backgroundColor: Colours.BOXGREY,
|
|
1077
|
+
minHeight: 106
|
|
1078
|
+
},
|
|
1079
|
+
imageListContainerEmpty: {
|
|
1080
|
+
justifyContent: 'center',
|
|
1081
|
+
alignItems: 'center',
|
|
1082
|
+
flexDirection: 'column'
|
|
1083
|
+
},
|
|
1084
|
+
imageContainer: {
|
|
1085
|
+
width: PHOTO_SIZE,
|
|
1086
|
+
height: PHOTO_SIZE,
|
|
1087
|
+
borderStyle: 'dashed',
|
|
1088
|
+
justifyContent: 'center',
|
|
1089
|
+
alignItems: 'center',
|
|
1090
|
+
borderWidth: 1,
|
|
1091
|
+
borderColor: Colours.LINEGREY,
|
|
1092
|
+
borderRadius: 4,
|
|
1093
|
+
marginLeft: 8
|
|
1094
|
+
},
|
|
1095
|
+
imageContainerNotEmpty: {
|
|
1096
|
+
borderWidth: 1,
|
|
1097
|
+
borderColor: Colours.LINEGREY,
|
|
1098
|
+
backgroundColor: '#fff',
|
|
1099
|
+
borderStyle: 'dashed'
|
|
1100
|
+
},
|
|
1101
|
+
imageBackground: {
|
|
1102
|
+
flex: 1,
|
|
1103
|
+
height: '100%',
|
|
1104
|
+
width: '100%',
|
|
1105
|
+
borderRadius: 4
|
|
1106
|
+
},
|
|
1107
|
+
imageCircle: {
|
|
1108
|
+
width: 90,
|
|
1109
|
+
height: 90,
|
|
1110
|
+
borderRadius: 45,
|
|
1111
|
+
backgroundColor: Colours.PINKISH_GREY,
|
|
1112
|
+
justifyContent: 'center'
|
|
1113
|
+
},
|
|
1114
|
+
addImageIcon: {
|
|
1115
|
+
color: '#fff',
|
|
1116
|
+
fontSize: 32
|
|
1117
|
+
},
|
|
1118
|
+
imagePlayContainer: {
|
|
1119
|
+
position: 'absolute',
|
|
1120
|
+
top: 0,
|
|
1121
|
+
left: 0,
|
|
1122
|
+
right: 0,
|
|
1123
|
+
bottom: 0,
|
|
1124
|
+
alignItems: 'center',
|
|
1125
|
+
justifyContent: 'center'
|
|
1126
|
+
},
|
|
1127
|
+
imageControlIcon: {
|
|
1128
|
+
color: '#fff',
|
|
1129
|
+
fontSize: 20,
|
|
1130
|
+
textShadowColor: 'rgba(0,0,0,0.3)',
|
|
1131
|
+
textShadowOffset: {
|
|
1132
|
+
width: 2,
|
|
1133
|
+
height: 2
|
|
1134
|
+
}
|
|
1135
|
+
},
|
|
1136
|
+
removeImage: {
|
|
1137
|
+
position: 'absolute',
|
|
1138
|
+
top: 0,
|
|
1139
|
+
right: 0,
|
|
1140
|
+
padding: 4,
|
|
1141
|
+
width: 40,
|
|
1142
|
+
height: 40,
|
|
1143
|
+
alignItems: 'center',
|
|
1144
|
+
justifyContent: 'center'
|
|
1145
|
+
},
|
|
1146
|
+
staticTitle: {
|
|
1147
|
+
fontSize: 20,
|
|
1148
|
+
fontFamily: 'sf-semibold',
|
|
1149
|
+
color: Colours.TEXT_DARKEST
|
|
1150
|
+
},
|
|
1151
|
+
staticText: {
|
|
1152
|
+
fontSize: 17,
|
|
1153
|
+
fontFamily: 'sf-regular',
|
|
1154
|
+
color: Colours.TEXT_DARKEST,
|
|
1155
|
+
lineHeight: 24
|
|
1156
|
+
},
|
|
1157
|
+
multiChoiceOption: {
|
|
1158
|
+
marginTop: 16,
|
|
1159
|
+
flexDirection: 'row',
|
|
1160
|
+
alignItems: 'center',
|
|
1161
|
+
minHeight: 20
|
|
1162
|
+
},
|
|
1163
|
+
multiChoiceText: {
|
|
1164
|
+
flex: 1,
|
|
1165
|
+
fontFamily: 'sf-medium',
|
|
1166
|
+
fontSize: 14,
|
|
1167
|
+
color: Colours.TEXT_DARK
|
|
1168
|
+
},
|
|
1169
|
+
tick: {
|
|
1170
|
+
marginRight: 10,
|
|
1171
|
+
borderRadius: 4
|
|
1172
|
+
},
|
|
1173
|
+
unticked: {
|
|
1174
|
+
marginRight: 10,
|
|
1175
|
+
width: 20,
|
|
1176
|
+
height: 20,
|
|
1177
|
+
borderColor: Colours.LINEGREY,
|
|
1178
|
+
borderWidth: 1,
|
|
1179
|
+
borderRadius: 4
|
|
1180
|
+
},
|
|
1181
|
+
dateContainer: {
|
|
1182
|
+
flexDirection: 'row',
|
|
1183
|
+
alignItems: 'center'
|
|
1184
|
+
},
|
|
1185
|
+
dateFieldButton: {
|
|
1186
|
+
flex: 1
|
|
1187
|
+
},
|
|
1188
|
+
dateFieldContainer: {
|
|
1189
|
+
flexDirection: 'row',
|
|
1190
|
+
borderRadius: 2,
|
|
1191
|
+
backgroundColor: '#ebeff2',
|
|
1192
|
+
padding: 8,
|
|
1193
|
+
marginTop: 8
|
|
1194
|
+
},
|
|
1195
|
+
dateText: {
|
|
1196
|
+
flex: 1,
|
|
1197
|
+
fontFamily: 'sf-regular',
|
|
1198
|
+
fontSize: 16,
|
|
1199
|
+
color: '#65686D'
|
|
1200
|
+
},
|
|
1201
|
+
dateIcon: {
|
|
1202
|
+
fontSize: 18,
|
|
1203
|
+
color: Colours.TEXT_BLUEGREY
|
|
1204
|
+
},
|
|
1205
|
+
dateClearButton: {
|
|
1206
|
+
paddingLeft: 12
|
|
1207
|
+
},
|
|
1208
|
+
removeIcon: {
|
|
1209
|
+
fontSize: 26,
|
|
1210
|
+
color: Colours.TEXT_BLUEGREY
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
const mapStateToProps = state => {
|
|
1214
|
+
var _state$strings;
|
|
1215
|
+
const {
|
|
1216
|
+
user,
|
|
1217
|
+
connection
|
|
1218
|
+
} = state;
|
|
1219
|
+
const {
|
|
1220
|
+
displayName,
|
|
1221
|
+
profilePic,
|
|
1222
|
+
uid,
|
|
1223
|
+
site,
|
|
1224
|
+
unit,
|
|
1225
|
+
phoneNumber
|
|
1226
|
+
} = user;
|
|
1227
|
+
return {
|
|
1228
|
+
connected: connection.connected,
|
|
1229
|
+
userType: user.type,
|
|
1230
|
+
displayName,
|
|
1231
|
+
profilePic,
|
|
1232
|
+
uid,
|
|
1233
|
+
site,
|
|
1234
|
+
unit,
|
|
1235
|
+
phoneNumber,
|
|
1236
|
+
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
|
1237
|
+
strings: ((_state$strings = state.strings) === null || _state$strings === void 0 ? void 0 : _state$strings.config) || {}
|
|
1238
|
+
};
|
|
1239
|
+
};
|
|
1240
|
+
export default connect(mapStateToProps, {
|
|
1241
|
+
jobAdded
|
|
1242
|
+
})(MaintenanceRequest);
|
|
1243
|
+
//# sourceMappingURL=ServiceRequest.js.map
|