@plusscommunities/pluss-maintenance-app 1.1.15 → 1.2.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.
Files changed (44) hide show
  1. package/dist/module/actions/JobActions.js +14 -0
  2. package/dist/module/actions/JobActions.js.map +1 -0
  3. package/dist/module/actions/index.js +2 -0
  4. package/dist/module/actions/index.js.map +1 -0
  5. package/dist/module/actions/types.js +3 -0
  6. package/dist/module/actions/types.js.map +1 -0
  7. package/dist/module/apis/generalActions.js +145 -0
  8. package/dist/module/apis/generalActions.js.map +1 -0
  9. package/dist/module/apis/index.js +2 -0
  10. package/dist/module/apis/index.js.map +1 -0
  11. package/dist/module/components/MaintenanceList.js +240 -0
  12. package/dist/module/components/MaintenanceList.js.map +1 -0
  13. package/dist/module/components/MaintenanceListItem.js +282 -0
  14. package/dist/module/components/MaintenanceListItem.js.map +1 -0
  15. package/dist/module/components/MaintenanceWidgetItem.js +161 -0
  16. package/dist/module/components/MaintenanceWidgetItem.js.map +1 -0
  17. package/dist/module/components/StatusSelectorPopup.js +93 -0
  18. package/dist/module/components/StatusSelectorPopup.js.map +1 -0
  19. package/dist/module/components/WidgetLarge.js +12 -0
  20. package/dist/module/components/WidgetLarge.js.map +1 -0
  21. package/dist/module/components/WidgetSmall.js +185 -0
  22. package/dist/module/components/WidgetSmall.js.map +1 -0
  23. package/dist/module/core.config.js +17 -0
  24. package/dist/module/core.config.js.map +1 -0
  25. package/dist/module/feature.config.js +91 -0
  26. package/dist/module/feature.config.js.map +1 -0
  27. package/dist/module/helper.js +28 -0
  28. package/dist/module/helper.js.map +1 -0
  29. package/dist/module/images/speechbubble.png +0 -0
  30. package/dist/module/index.js +20 -0
  31. package/dist/module/index.js.map +1 -0
  32. package/dist/module/reducers/JobsReducer.js +59 -0
  33. package/dist/module/reducers/JobsReducer.js.map +1 -0
  34. package/dist/module/screens/JobTypePicker.js +139 -0
  35. package/dist/module/screens/JobTypePicker.js.map +1 -0
  36. package/dist/module/screens/MaintenancePage.js +99 -0
  37. package/dist/module/screens/MaintenancePage.js.map +1 -0
  38. package/dist/module/screens/RequestDetail.js +839 -0
  39. package/dist/module/screens/RequestDetail.js.map +1 -0
  40. package/dist/module/screens/RequestNotes.js +420 -0
  41. package/dist/module/screens/RequestNotes.js.map +1 -0
  42. package/dist/module/screens/ServiceRequest.js +803 -0
  43. package/dist/module/screens/ServiceRequest.js.map +1 -0
  44. package/package.json +25 -12
@@ -0,0 +1,803 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import React, { Component } from 'react';
4
+ import { Dimensions, Platform, KeyboardAvoidingView, ScrollView, Text, TouchableOpacity, View, Switch, FlatList, ImageBackground, Keyboard } from 'react-native';
5
+ import _ from 'lodash';
6
+ import { Icon } from 'react-native-elements';
7
+ import { connect } from 'react-redux';
8
+ import { jobAdded } from '../actions';
9
+ import { generalActions } from '../apis';
10
+ import { Services } from '../feature.config';
11
+ import { Components, Colours, Helper, Config } from '../core.config';
12
+ const PHOTO_SIZE = (Dimensions.get('window').width - 64) / 3;
13
+
14
+ class MaintenanceRequest extends Component {
15
+ constructor(props) {
16
+ super(props);
17
+
18
+ _defineProperty(this, "onUploadStarted", (uploadUri, imageUri) => {
19
+ const images = [...this.state.images];
20
+ images.splice(images.length - 1, 0, {
21
+ uploading: true,
22
+ uploadProgress: '0%',
23
+ uploadUri,
24
+ imageUri,
25
+ allowRetry: true
26
+ });
27
+ this.setState({
28
+ images
29
+ });
30
+ });
31
+
32
+ _defineProperty(this, "onUploadProgress", progress => {
33
+ const images = [...this.state.images];
34
+ images.map(img => {
35
+ if (img.uploadUri === progress.uri) {
36
+ img.uploadProgress = progress.percentage;
37
+ img.uploading = true;
38
+ img.allowRetry = true;
39
+ }
40
+ });
41
+ this.setState({
42
+ images
43
+ });
44
+ });
45
+
46
+ _defineProperty(this, "onUploadSuccess", async (uri, uploadUri) => {
47
+ const images = [...this.state.images];
48
+ images.map(img => {
49
+ if (img.uploadUri === uploadUri && img.uploading) {
50
+ img.url = uri.replace('/general/', '/general1400/');
51
+ img.thumbNailExists = false;
52
+ img.thumbNailUrl = Helper.getThumb300(img.url);
53
+ img.allowRetry = true;
54
+ }
55
+ });
56
+ this.setState({
57
+ images
58
+ }, () => this.waitForThumbnails());
59
+ });
60
+
61
+ _defineProperty(this, "onUploadFailed", uploadUri => {
62
+ const images = [...this.state.images];
63
+ images.map(img => {
64
+ if (img.uploadUri === uploadUri) {
65
+ img.uploading = true; // Requried for retry
66
+
67
+ img.uploadProgress = '';
68
+ img.allowRetry = true;
69
+ }
70
+ });
71
+ this.setState({
72
+ images
73
+ });
74
+ });
75
+
76
+ _defineProperty(this, "onLibrarySelected", uri => {
77
+ const images = [...this.state.images];
78
+ images.splice(images.length - 1, 0, {
79
+ uploading: false,
80
+ allowRetry: false,
81
+ url: Helper.get1400(uri),
82
+ thumbNailExists: true,
83
+ thumbNailUrl: Helper.getThumb300(uri)
84
+ });
85
+ this.setState({
86
+ images
87
+ });
88
+ });
89
+
90
+ _defineProperty(this, "showUploadMenu", () => {
91
+ Keyboard.dismiss();
92
+
93
+ if (this.state.uploadingImage || this.state.submitting) {
94
+ return;
95
+ }
96
+
97
+ this.imageUploader.showUploadMenu();
98
+ });
99
+
100
+ _defineProperty(this, "submit", async () => {
101
+ this.setState({
102
+ submitting: true
103
+ });
104
+ let description = this.state.description;
105
+
106
+ if (this.state.isHome) {
107
+ description = description + `. -- Times Available: ${this.state.times}`;
108
+ }
109
+
110
+ setTimeout(() => {
111
+ this.scrollContainer.scrollTo({
112
+ y: 0
113
+ });
114
+ }, 100);
115
+
116
+ const images = _.filter(this.state.images, img => {
117
+ return !img.uploading && !img.add;
118
+ }).map(img => {
119
+ return img.url;
120
+ });
121
+
122
+ generalActions.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).then(res => {
123
+ if (res.data.success) {
124
+ this.refreshRequest(res.data.searchResult);
125
+ if (this.props.onSubmissionSuccess) this.props.onSubmissionSuccess(res.data);
126
+ this.setState({
127
+ submitting: false,
128
+ success: true,
129
+ confirmationToShow: true
130
+ });
131
+ } else {
132
+ this.setState({
133
+ submitting: false
134
+ });
135
+ }
136
+ }).catch(err => {
137
+ console.log('maintenance submission fail.');
138
+ console.log(err);
139
+ this.setState({
140
+ submitting: false
141
+ });
142
+ });
143
+ });
144
+
145
+ _defineProperty(this, "refreshRequest", async id => {
146
+ try {
147
+ const job = await generalActions.getJob(Helper.getSite(this.props.site), id); // console.log('refreshRequest', job?.data);
148
+
149
+ this.props.jobAdded(job.data);
150
+ } catch (error) {
151
+ console.log('refreshRequest error', error);
152
+ }
153
+ });
154
+
155
+ _defineProperty(this, "waitForThumbnails", () => {
156
+ if (this.checkThumb) return;
157
+ this.checkThumb = setInterval(async () => {
158
+ const images = [];
159
+ await Promise.all(this.state.images.map(image => {
160
+ return new Promise(async resolve => {
161
+ const newImage = { ...image
162
+ };
163
+ images.push(newImage);
164
+
165
+ if (newImage.url && !newImage.thumbNailExists) {
166
+ newImage.uploading = false;
167
+ newImage.allowRetry = false;
168
+ newImage.thumbNailExists = await Helper.imageExists(newImage.thumbNailUrl);
169
+ resolve(newImage.thumbNailExists);
170
+ }
171
+
172
+ resolve(true);
173
+ });
174
+ }));
175
+ const thumbnailsExist = images.every(image => !image.url || image.thumbNailExists);
176
+
177
+ if (thumbnailsExist) {
178
+ clearInterval(this.checkThumb);
179
+ this.checkThumb = null;
180
+ this.setState({
181
+ images
182
+ });
183
+ }
184
+ }, 2000);
185
+ });
186
+
187
+ _defineProperty(this, "removeImage", index => {
188
+ const images = [...this.state.images];
189
+ images.splice(index, 1);
190
+ this.setState({
191
+ images
192
+ });
193
+ });
194
+
195
+ _defineProperty(this, "toggleFullscreenVideo", url => {
196
+ if (typeof url !== 'string') url = '';
197
+ this.setState({
198
+ showFullscreenVideo: url.length > 0,
199
+ currentVideoUrl: url
200
+ });
201
+ });
202
+
203
+ this.state = {
204
+ submitting: false,
205
+ success: false,
206
+ fail: false,
207
+ error: null,
208
+ showError: false,
209
+ userName: '',
210
+ roomNumber: '',
211
+ phone: '',
212
+ title: '',
213
+ description: '',
214
+ times: '',
215
+ type: 'General',
216
+ uploadingImage: false,
217
+ images: [{
218
+ add: true
219
+ }],
220
+ showFullscreenVideo: false,
221
+ currentVideoUrl: '',
222
+ isHome: false,
223
+ types: [],
224
+ confirmationToShow: false
225
+ };
226
+ this.checkThumb = null;
227
+ }
228
+
229
+ componentDidMount() {
230
+ if (this.props.userType !== 'KIOSK') {
231
+ this.setState({
232
+ userName: this.props.displayName,
233
+ roomNumber: this.props.unit,
234
+ phone: !_.isEmpty(this.props.phoneNumber) ? this.props.phoneNumber : ''
235
+ });
236
+ }
237
+
238
+ this.getJobTypes();
239
+ }
240
+
241
+ componentWillUnmount() {
242
+ clearInterval(this.checkThumb);
243
+ }
244
+
245
+ onPressBack() {
246
+ Services.navigation.goBack();
247
+ }
248
+
249
+ onPressType() {
250
+ Services.navigation.navigate('jobTypePicker', {
251
+ currentType: this.state.type,
252
+ types: this.state.types,
253
+ onSelectType: this.pickType.bind(this)
254
+ });
255
+ }
256
+
257
+ onCloseConfirmationPopup() {
258
+ this.setState({
259
+ confirmationToShow: false
260
+ });
261
+ Services.navigation.goBack();
262
+ this.props.onBack && this.props.onBack();
263
+ }
264
+
265
+ onConfirmationReset() {
266
+ this.setState({
267
+ confirmationToShow: false,
268
+ title: '',
269
+ description: '',
270
+ times: '',
271
+ isHome: false,
272
+ uploadingImage: false,
273
+ images: [{
274
+ add: true
275
+ }],
276
+ submitting: false,
277
+ success: false,
278
+ fail: false
279
+ });
280
+ }
281
+
282
+ getJobTypes() {
283
+ const self = this;
284
+ generalActions.getJobTypes(Helper.getSite(this.props.site)).then(res => {
285
+ self.setState({
286
+ types: res.data
287
+ });
288
+ self.getDefaultJob();
289
+ }).catch(() => {});
290
+ }
291
+
292
+ getDefaultJob() {
293
+ if (this.state.types.length !== 0 && this.state.jobId == null) {
294
+ this.setState({
295
+ type: this.state.types[0].typeName
296
+ });
297
+ }
298
+ }
299
+
300
+ pickType(type) {
301
+ this.setState({
302
+ type
303
+ });
304
+ }
305
+
306
+ submitRequest() {
307
+ if (this.state.submitting || !this.props.connected) {
308
+ if (!this.props.connected) {
309
+ this.setState({
310
+ error: {
311
+ message: 'No internet connection detected'
312
+ }
313
+ });
314
+ }
315
+
316
+ return;
317
+ }
318
+
319
+ if (this.state.uploadingImage) {
320
+ return;
321
+ }
322
+
323
+ this.setState({
324
+ error: null,
325
+ showError: false
326
+ });
327
+
328
+ if (this.state.title.length === 0 || !this.state.roomNumber || this.state.roomNumber.length === 0) {
329
+ this.setState({
330
+ showError: true
331
+ });
332
+ return;
333
+ }
334
+
335
+ if (this.state.isHome && this.state.times.length < 2) {
336
+ this.setState({
337
+ showError: true
338
+ });
339
+ return;
340
+ }
341
+
342
+ this.submit();
343
+ }
344
+
345
+ renderUploadMenu() {
346
+ return /*#__PURE__*/React.createElement(Components.ImageUploader, {
347
+ ref: ref => this.imageUploader = ref,
348
+ onUploadStarted: this.onUploadStarted,
349
+ onUploadSuccess: this.onUploadSuccess,
350
+ onUploadFailed: this.onUploadFailed,
351
+ onUploadProgress: this.onUploadProgress,
352
+ onLibrarySelected: this.onLibrarySelected,
353
+ size: {
354
+ width: 1400
355
+ },
356
+ quality: 0.8,
357
+ fileName: 'serviceImage',
358
+ popupTitle: 'Upload Image',
359
+ userId: this.props.uid,
360
+ allowsEditing: false,
361
+ multiple: true,
362
+ hideLibrary: true
363
+ });
364
+ }
365
+
366
+ renderImage(item, index) {
367
+ const isVideoUrl = Helper.isVideo(item.url);
368
+
369
+ if (item.add) {
370
+ return /*#__PURE__*/React.createElement(TouchableOpacity, {
371
+ activeOpacity: 0.8,
372
+ onPress: this.showUploadMenu
373
+ }, /*#__PURE__*/React.createElement(View, {
374
+ style: [styles.imageContainer, this.state.images.length > 1 && styles.imageContainerNotEmpty, index % 3 === 0 && {
375
+ marginLeft: 0
376
+ }, index > 2 && {
377
+ marginTop: 8
378
+ }]
379
+ }, /*#__PURE__*/React.createElement(View, {
380
+ style: styles.imageCircle
381
+ }, /*#__PURE__*/React.createElement(Icon, {
382
+ name: "camera",
383
+ type: "font-awesome",
384
+ iconStyle: styles.addImageIcon
385
+ }))));
386
+ }
387
+
388
+ return /*#__PURE__*/React.createElement(View, {
389
+ style: [styles.imageContainer, this.state.images.length > 1 && styles.imageContainerNotEmpty, index % 3 === 0 && {
390
+ marginLeft: 0
391
+ }, index > 2 && {
392
+ marginTop: 8
393
+ }]
394
+ }, item.uploading ? /*#__PURE__*/React.createElement(Components.ImageUploadProgress, {
395
+ uploader: this.imageUploader,
396
+ image: item,
397
+ color: this.props.colourBrandingMain
398
+ }) : /*#__PURE__*/React.createElement(ImageBackground, {
399
+ style: styles.imageBackground,
400
+ source: Helper.getImageSource(item.thumbNailExists ? item.thumbNailUrl : item.url)
401
+ }, isVideoUrl && /*#__PURE__*/React.createElement(View, {
402
+ style: styles.imagePlayContainer
403
+ }, /*#__PURE__*/React.createElement(TouchableOpacity, {
404
+ onPress: this.toggleFullscreenVideo.bind(this, item.url)
405
+ }, /*#__PURE__*/React.createElement(Icon, {
406
+ name: "play",
407
+ type: "font-awesome",
408
+ iconStyle: styles.imageControlIcon
409
+ }))), /*#__PURE__*/React.createElement(TouchableOpacity, {
410
+ style: styles.removeImage,
411
+ onPress: this.removeImage.bind(this, index)
412
+ }, /*#__PURE__*/React.createElement(Icon, {
413
+ name: "remove",
414
+ type: "font-awesome",
415
+ iconStyle: styles.imageControlIcon,
416
+ style: styles.removeImage
417
+ }))));
418
+ }
419
+
420
+ renderSuccess() {
421
+ return /*#__PURE__*/React.createElement(View, {
422
+ style: {
423
+ padding: 16,
424
+ flex: 1,
425
+ backgroundColor: '#fff'
426
+ }
427
+ }, /*#__PURE__*/React.createElement(Text, {
428
+ style: styles.requestSuccess
429
+ }, "Your request has been submitted. Thank you."));
430
+ }
431
+
432
+ renderImageList() {
433
+ return /*#__PURE__*/React.createElement(View, {
434
+ style: styles.imageSection
435
+ }, /*#__PURE__*/React.createElement(View, {
436
+ style: [styles.imageListContainer, this.state.images.length < 2 && styles.imageListContainerEmpty]
437
+ }, /*#__PURE__*/React.createElement(FlatList, {
438
+ keyboardShouldPersistTaps: "always",
439
+ enableEmptySections: true,
440
+ data: this.state.images,
441
+ renderItem: _ref => {
442
+ let {
443
+ item,
444
+ index
445
+ } = _ref;
446
+ return this.renderImage(item, index);
447
+ },
448
+ keyExtractor: (item, index) => index,
449
+ numColumns: 3
450
+ })));
451
+ }
452
+
453
+ renderForm() {
454
+ return /*#__PURE__*/React.createElement(View, {
455
+ style: {
456
+ flex: 1
457
+ }
458
+ }, /*#__PURE__*/React.createElement(ScrollView, {
459
+ keyboardShouldPersistTaps: "always",
460
+ style: {
461
+ flex: 1
462
+ },
463
+ ref: ref => this.scrollContainer = ref
464
+ }, /*#__PURE__*/React.createElement(View, {
465
+ style: {
466
+ paddingBottom: 2
467
+ }
468
+ }, /*#__PURE__*/React.createElement(Components.LoadingIndicator, {
469
+ visible: this.state.submitting
470
+ }), this.state.error && /*#__PURE__*/React.createElement(Text, {
471
+ style: styles.errorText
472
+ }, this.state.error), /*#__PURE__*/React.createElement(Components.FormCard, {
473
+ style: {
474
+ marginTop: 16
475
+ }
476
+ }, /*#__PURE__*/React.createElement(Components.FormCardSection, {
477
+ label: 'Name',
478
+ placeholder: 'Enter your name',
479
+ textValue: this.state.userName,
480
+ onChangeText: userName => this.setState({
481
+ userName
482
+ }),
483
+ editable: this.props.userType === 'KIOSK' && this.state.submitting === false,
484
+ isValid: () => {
485
+ return this.state.userName.length > 1;
486
+ },
487
+ required: true,
488
+ errorText: "Please enter your name.",
489
+ showError: this.state.showError && this.state.userName.length < 2,
490
+ hasUnderline: true
491
+ }), /*#__PURE__*/React.createElement(Components.FormCardSection, {
492
+ label: 'Contact number',
493
+ placeholder: 'Enter phone number',
494
+ textValue: this.state.phone,
495
+ onChangeText: phone => this.setState({
496
+ phone
497
+ }),
498
+ editable: this.state.submitting === false,
499
+ hasUnderline: true,
500
+ keyboardType: 'phone-pad'
501
+ }), /*#__PURE__*/React.createElement(Components.FormCardSection, {
502
+ label: 'Address',
503
+ placeholder: 'Enter your address',
504
+ textValue: this.state.roomNumber,
505
+ onChangeText: roomNumber => this.setState({
506
+ roomNumber
507
+ }),
508
+ editable: this.state.submitting === false,
509
+ hasUnderline: true,
510
+ isValid: () => {
511
+ return this.state.roomNumber && this.state.roomNumber.length > 1;
512
+ },
513
+ required: true,
514
+ errorText: "Please provide your address.",
515
+ showError: this.state.showError && this.state.roomNumber && this.state.roomNumber.length < 2
516
+ })), /*#__PURE__*/React.createElement(Components.FormCard, {
517
+ style: {
518
+ marginTop: 16,
519
+ paddingHorizontal: 24,
520
+ paddingVertical: 16,
521
+ flexDirection: 'row',
522
+ justifyContent: 'space-between'
523
+ }
524
+ }, /*#__PURE__*/React.createElement(Text, {
525
+ style: styles.sectionTitle
526
+ }, Config.env.strings.JOB_TYPE), /*#__PURE__*/React.createElement(TouchableOpacity, {
527
+ onPress: this.onPressType.bind(this)
528
+ }, /*#__PURE__*/React.createElement(View, {
529
+ style: {
530
+ flexDirection: 'row'
531
+ }
532
+ }, /*#__PURE__*/React.createElement(Text, {
533
+ style: [styles.sectionTitle, {
534
+ color: this.props.colourBrandingMain,
535
+ marginRight: 16
536
+ }]
537
+ }, this.state.type), /*#__PURE__*/React.createElement(Icon, {
538
+ name: "angle-right",
539
+ type: "font-awesome",
540
+ iconStyle: [styles.sectionTitle, {
541
+ fontSize: 20,
542
+ color: this.props.colourBrandingMain
543
+ }]
544
+ })))), /*#__PURE__*/React.createElement(Components.FormCard, {
545
+ style: {
546
+ marginTop: 16
547
+ }
548
+ }, /*#__PURE__*/React.createElement(Components.FormCardSection, {
549
+ label: 'Title',
550
+ placeholder: 'Enter a title for your request',
551
+ textValue: this.state.title,
552
+ onChangeText: title => this.setState({
553
+ title
554
+ }),
555
+ editable: this.state.submitting === false,
556
+ hasUnderline: true,
557
+ isValid: () => {
558
+ return this.state.title.length > 1;
559
+ },
560
+ required: true,
561
+ errorText: "Please provide a title.",
562
+ showError: this.state.showError && this.state.title.length < 2,
563
+ autoCorrect: true,
564
+ multiline: true,
565
+ autoGrow: true
566
+ }), /*#__PURE__*/React.createElement(Components.FormCardSection, {
567
+ label: 'Description',
568
+ placeholder: 'Describe your request here in detail',
569
+ textValue: this.state.description,
570
+ onChangeText: description => this.setState({
571
+ description
572
+ }),
573
+ editable: this.state.submitting === false,
574
+ hasUnderline: true,
575
+ autoCorrect: true,
576
+ multiline: true,
577
+ autoGrow: true
578
+ })), /*#__PURE__*/React.createElement(Components.FormCard, {
579
+ style: {
580
+ marginTop: 16,
581
+ paddingHorizontal: 24
582
+ }
583
+ }, /*#__PURE__*/React.createElement(View, {
584
+ style: [{
585
+ width: '100%',
586
+ paddingVertical: 16,
587
+ flexDirection: 'row',
588
+ justifyContent: 'space-between',
589
+ alignItems: 'center',
590
+ position: 'relative'
591
+ }, this.state.isHome && {
592
+ borderBottomWidth: 1,
593
+ borderBottomColor: Colours.LINEGREY
594
+ }]
595
+ }, /*#__PURE__*/React.createElement(Text, {
596
+ style: styles.sectionTitle
597
+ }, Config.env.strings.MAINTENANCE_HOME), /*#__PURE__*/React.createElement(Switch, {
598
+ value: this.state.isHome,
599
+ disabled: this.state.submitting,
600
+ onValueChange: value => this.setState({
601
+ isHome: value
602
+ }),
603
+ trackColor: {
604
+ false: '#ddd',
605
+ true: this.props.colourBrandingMain
606
+ },
607
+ thumbColor: Platform.OS === 'android' ? '#fff' : null
608
+ })), this.state.isHome && /*#__PURE__*/React.createElement(Components.FormCardSection, {
609
+ label: 'Available times',
610
+ placeholder: 'Describe your available times here in detail.',
611
+ textValue: this.state.times,
612
+ onChangeText: times => this.setState({
613
+ times
614
+ }),
615
+ editable: this.state.submitting === false,
616
+ hasUnderline: true,
617
+ isValid: () => {
618
+ return this.state.times.length > 1;
619
+ },
620
+ required: true,
621
+ errorText: "Please provide available times.",
622
+ showError: this.state.showError && this.state.isHome && this.state.times.length < 2,
623
+ minHeight: 40,
624
+ autoCorrect: true,
625
+ multiline: true,
626
+ autoGrow: true
627
+ })), this.renderImageList())));
628
+ }
629
+
630
+ renderRegisterConfirmation() {
631
+ return /*#__PURE__*/React.createElement(Components.ConfirmationPopup, {
632
+ confirmText: 'Request submitted',
633
+ repeatText: 'Submit another',
634
+ visible: this.state.confirmationToShow,
635
+ onClose: this.onCloseConfirmationPopup.bind(this),
636
+ onPressAction: this.onConfirmationReset.bind(this)
637
+ });
638
+ }
639
+
640
+ renderVideoPlayerPopup() {
641
+ const {
642
+ showFullscreenVideo,
643
+ currentVideoUrl
644
+ } = this.state;
645
+ if (!currentVideoUrl) return;
646
+ return /*#__PURE__*/React.createElement(Components.VideoPopup, {
647
+ uri: currentVideoUrl,
648
+ visible: showFullscreenVideo,
649
+ showFullscreenButton: false,
650
+ onClose: this.toggleFullscreenVideo
651
+ });
652
+ }
653
+
654
+ render() {
655
+ return /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
656
+ behavior: Platform.OS === 'ios' && 'padding',
657
+ style: styles.viewContainer
658
+ }, this.renderUploadMenu(), /*#__PURE__*/React.createElement(View, {
659
+ style: styles.container
660
+ }, /*#__PURE__*/React.createElement(Components.Header, {
661
+ leftIcon: "angle-left",
662
+ onPressLeft: this.onPressBack.bind(this),
663
+ text: Config.env.strings.MAINTENANCE,
664
+ rightText: this.state.submitting || this.state.success ? null : 'Done',
665
+ onPressRight: this.submitRequest.bind(this),
666
+ absoluteRight: true
667
+ }), this.renderForm()), this.renderRegisterConfirmation(), this.renderVideoPlayerPopup());
668
+ }
669
+
670
+ }
671
+
672
+ const styles = {
673
+ viewContainer: {
674
+ flex: 1,
675
+ backgroundColor: '#fff'
676
+ },
677
+ container: {
678
+ flex: 1,
679
+ position: 'relative',
680
+ backgroundColor: '#f0f0f5'
681
+ },
682
+ errorText: {
683
+ fontFamily: 'sf-regular',
684
+ color: Colours.COLOUR_TANGERINE,
685
+ fontSize: 16
686
+ },
687
+ requestSuccess: {
688
+ fontFamily: 'sf-regular',
689
+ color: Colours.TEXT_DARK,
690
+ fontSize: 17,
691
+ textAlign: 'center'
692
+ },
693
+ sectionTitle: {
694
+ fontFamily: 'sf-regular',
695
+ fontSize: 17,
696
+ color: Colours.TEXT_DARK
697
+ },
698
+ imageListContainer: {
699
+ marginTop: 8,
700
+ padding: 8,
701
+ flexDirection: 'row',
702
+ backgroundColor: Colours.BOXGREY,
703
+ minHeight: 106
704
+ },
705
+ imageListContainerEmpty: {
706
+ justifyContent: 'center',
707
+ alignItems: 'center',
708
+ flexDirection: 'column'
709
+ },
710
+ imageContainer: {
711
+ width: PHOTO_SIZE,
712
+ height: PHOTO_SIZE,
713
+ borderStyle: 'dashed',
714
+ justifyContent: 'center',
715
+ alignItems: 'center',
716
+ borderWidth: 1,
717
+ borderColor: Colours.LINEGREY,
718
+ borderRadius: 4,
719
+ marginLeft: 8
720
+ },
721
+ imageContainerNotEmpty: {
722
+ borderWidth: 1,
723
+ borderColor: Colours.LINEGREY,
724
+ backgroundColor: '#fff',
725
+ borderStyle: 'dashed'
726
+ },
727
+ imageBackground: {
728
+ flex: 1,
729
+ height: '100%',
730
+ width: '100%',
731
+ borderRadius: 4
732
+ },
733
+ imageCircle: {
734
+ width: 90,
735
+ height: 90,
736
+ borderRadius: 45,
737
+ backgroundColor: Colours.PINKISH_GREY,
738
+ justifyContent: 'center'
739
+ },
740
+ addImageIcon: {
741
+ color: '#fff',
742
+ fontSize: 32
743
+ },
744
+ imagePlayContainer: {
745
+ position: 'absolute',
746
+ top: 0,
747
+ left: 0,
748
+ right: 0,
749
+ bottom: 0,
750
+ alignItems: 'center',
751
+ justifyContent: 'center'
752
+ },
753
+ imageControlIcon: {
754
+ color: '#fff',
755
+ fontSize: 20,
756
+ textShadowColor: 'rgba(0,0,0,0.3)',
757
+ textShadowOffset: {
758
+ width: 2,
759
+ height: 2
760
+ }
761
+ },
762
+ removeImage: {
763
+ position: 'absolute',
764
+ top: 0,
765
+ right: 0,
766
+ padding: 4,
767
+ width: 40,
768
+ height: 40,
769
+ alignItems: 'center',
770
+ justifyContent: 'center'
771
+ }
772
+ };
773
+
774
+ const mapStateToProps = state => {
775
+ const {
776
+ user,
777
+ connection
778
+ } = state;
779
+ const {
780
+ displayName,
781
+ profilePic,
782
+ uid,
783
+ site,
784
+ unit,
785
+ phoneNumber
786
+ } = user;
787
+ return {
788
+ connected: connection.connected,
789
+ userType: user.type,
790
+ displayName,
791
+ profilePic,
792
+ uid,
793
+ site,
794
+ unit,
795
+ phoneNumber,
796
+ colourBrandingMain: Colours.getMainBrandingColourFromState(state)
797
+ };
798
+ };
799
+
800
+ export default connect(mapStateToProps, {
801
+ jobAdded
802
+ })(MaintenanceRequest);
803
+ //# sourceMappingURL=ServiceRequest.js.map