@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.
Files changed (90) hide show
  1. package/dist/module/actions/JobActions.js +20 -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 +5 -0
  6. package/dist/module/actions/types.js.map +1 -0
  7. package/dist/module/apis/index.js +2 -0
  8. package/dist/module/apis/index.js.map +1 -0
  9. package/dist/module/apis/maintenanceActions.js +171 -0
  10. package/dist/module/apis/maintenanceActions.js.map +1 -0
  11. package/dist/module/components/FilterPopupMenu.js +271 -0
  12. package/dist/module/components/FilterPopupMenu.js.map +1 -0
  13. package/dist/module/components/MaintenanceList.js +360 -0
  14. package/dist/module/components/MaintenanceList.js.map +1 -0
  15. package/dist/module/components/MaintenanceListItem.js +322 -0
  16. package/dist/module/components/MaintenanceListItem.js.map +1 -0
  17. package/dist/module/components/MaintenanceWidgetItem.js +149 -0
  18. package/dist/module/components/MaintenanceWidgetItem.js.map +1 -0
  19. package/dist/module/components/StatusSelectorPopup.js +89 -0
  20. package/dist/module/components/StatusSelectorPopup.js.map +1 -0
  21. package/dist/module/components/WidgetLarge.js +9 -0
  22. package/dist/module/components/WidgetLarge.js.map +1 -0
  23. package/dist/module/components/WidgetSmall.js +171 -0
  24. package/dist/module/components/WidgetSmall.js.map +1 -0
  25. package/dist/module/core.config.js +17 -0
  26. package/dist/module/core.config.js.map +1 -0
  27. package/dist/module/feature.config.js +75 -0
  28. package/dist/module/feature.config.js.map +1 -0
  29. package/dist/module/helper.js +33 -0
  30. package/dist/module/helper.js.map +1 -0
  31. package/dist/module/images/speechbubble.png +0 -0
  32. package/dist/module/index.js +25 -0
  33. package/dist/module/index.js.map +1 -0
  34. package/dist/module/reducers/JobsReducer.js +63 -0
  35. package/dist/module/reducers/JobsReducer.js.map +1 -0
  36. package/dist/module/screens/JobTypePicker.js +130 -0
  37. package/dist/module/screens/JobTypePicker.js.map +1 -0
  38. package/dist/module/screens/MaintenancePage.js +92 -0
  39. package/dist/module/screens/MaintenancePage.js.map +1 -0
  40. package/dist/module/screens/RequestDetail.js +980 -0
  41. package/dist/module/screens/RequestDetail.js.map +1 -0
  42. package/dist/module/screens/RequestNotes.js +390 -0
  43. package/dist/module/screens/RequestNotes.js.map +1 -0
  44. package/dist/module/screens/ServiceRequest.js +1243 -0
  45. package/dist/module/screens/ServiceRequest.js.map +1 -0
  46. package/dist/module/values.config.a.js +30 -0
  47. package/dist/module/values.config.a.js.map +1 -0
  48. package/dist/module/values.config.b.js +30 -0
  49. package/dist/module/values.config.b.js.map +1 -0
  50. package/dist/module/values.config.c.js +30 -0
  51. package/dist/module/values.config.c.js.map +1 -0
  52. package/dist/module/values.config.d.js +30 -0
  53. package/dist/module/values.config.d.js.map +1 -0
  54. package/dist/module/values.config.default.js +35 -0
  55. package/dist/module/values.config.default.js.map +1 -0
  56. package/dist/module/values.config.forms.js +35 -0
  57. package/dist/module/values.config.forms.js.map +1 -0
  58. package/dist/module/values.config.js +35 -0
  59. package/dist/module/values.config.js.map +1 -0
  60. package/package.json +53 -0
  61. package/src/actions/JobActions.js +22 -0
  62. package/src/actions/index.js +1 -0
  63. package/src/actions/types.js +5 -0
  64. package/src/apis/index.js +1 -0
  65. package/src/apis/maintenanceActions.js +163 -0
  66. package/src/components/FilterPopupMenu.js +256 -0
  67. package/src/components/MaintenanceList.js +335 -0
  68. package/src/components/MaintenanceListItem.js +289 -0
  69. package/src/components/MaintenanceWidgetItem.js +132 -0
  70. package/src/components/StatusSelectorPopup.js +87 -0
  71. package/src/components/WidgetLarge.js +10 -0
  72. package/src/components/WidgetSmall.js +152 -0
  73. package/src/core.config.js +5 -0
  74. package/src/feature.config.js +73 -0
  75. package/src/helper.js +39 -0
  76. package/src/images/speechbubble.png +0 -0
  77. package/src/index.js +25 -0
  78. package/src/reducers/JobsReducer.js +51 -0
  79. package/src/screens/JobTypePicker.js +107 -0
  80. package/src/screens/MaintenancePage.js +96 -0
  81. package/src/screens/RequestDetail.js +915 -0
  82. package/src/screens/RequestNotes.js +418 -0
  83. package/src/screens/ServiceRequest.js +1219 -0
  84. package/src/values.config.a.js +30 -0
  85. package/src/values.config.b.js +30 -0
  86. package/src/values.config.c.js +30 -0
  87. package/src/values.config.d.js +30 -0
  88. package/src/values.config.default.js +35 -0
  89. package/src/values.config.forms.js +35 -0
  90. package/src/values.config.js +35 -0
@@ -0,0 +1,980 @@
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 { ScrollView, View, StyleSheet, Text, KeyboardAvoidingView, TouchableOpacity, ImageBackground, Platform } 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 { maintenanceActions } from '../apis';
12
+ import { jobAdded } from '../actions';
13
+ import StatusSelectorPopup from '../components/StatusSelectorPopup';
14
+ import { jobStatusOptions, getJobStatusProps } from '../helper';
15
+ import { Services } from '../feature.config';
16
+ import { Colours, Helper, Components, Config } from '../core.config';
17
+ import { values } from '../values.config';
18
+ class RequestDetail extends Component {
19
+ constructor(props) {
20
+ super(props);
21
+ _defineProperty(this, "getJob", async () => {
22
+ console.log('getting job');
23
+ this.setState({
24
+ loading: true
25
+ }, async () => {
26
+ try {
27
+ const res = await maintenanceActions.getJob(this.props.job.site, this.props.job.id);
28
+ this.props.jobAdded(res.data);
29
+ this.updateJobState(res.data);
30
+ } catch (error) {
31
+ console.log('getJob error', error.toString());
32
+ // check for 403 or 404 error
33
+ if (error.response.status === 403 || error.response.status === 404) {
34
+ this.setState({
35
+ forbidden: true
36
+ });
37
+ }
38
+ console.log('getJob error', error);
39
+ } finally {
40
+ this.setState({
41
+ loading: false
42
+ });
43
+ }
44
+ });
45
+ });
46
+ _defineProperty(this, "getAssignees", async () => {
47
+ if (!this.hasPermission()) return;
48
+ try {
49
+ const res = await maintenanceActions.getAssignees(this.props.user.site);
50
+ this.setState({
51
+ assignees: res.data.Users
52
+ });
53
+ } catch (error) {
54
+ console.log('getAssignees error', error);
55
+ }
56
+ });
57
+ _defineProperty(this, "markSeen", () => {
58
+ const {
59
+ user
60
+ } = this.props;
61
+ const {
62
+ job
63
+ } = this.state;
64
+ // Must have maintenance permission and not the requester
65
+ // console.log('markSeen check', job.userID, user.Id);
66
+ if (job.seen === true) return;
67
+ if (!this.hasPermission()) return;
68
+ if (user.Id === job.userID) return;
69
+ this.setState({
70
+ loading: true
71
+ }, async () => {
72
+ try {
73
+ const updated = {
74
+ id: job.id,
75
+ seen: true,
76
+ status: job.status || 'Unassigned'
77
+ };
78
+ const res = await maintenanceActions.editJob(updated, user.site);
79
+ // console.log('markSeen updated');
80
+ this.props.jobAdded(res.data.job);
81
+ this.getJob();
82
+ this.setState({
83
+ loading: false,
84
+ seen: true
85
+ });
86
+ } catch (error) {
87
+ console.log('markSeen error', error);
88
+ this.setState({
89
+ loading: false
90
+ });
91
+ }
92
+ });
93
+ });
94
+ _defineProperty(this, "updateJob", () => {
95
+ this.setState({
96
+ loading: true
97
+ }, async () => {
98
+ const {
99
+ user
100
+ } = this.props;
101
+ const {
102
+ job
103
+ } = this.state;
104
+ try {
105
+ const updated = {
106
+ id: job.id
107
+ };
108
+ if (this.state.expectedDate) {
109
+ updated.expectedDate = moment(this.state.expectedDate).utc().toISOString();
110
+ }
111
+ const res = await maintenanceActions.editJob(updated, user.site);
112
+ this.props.jobAdded(res.data.job);
113
+ this.getJob();
114
+ } catch (error) {
115
+ console.log('updateJob error', error);
116
+ } finally {
117
+ this.setState({
118
+ loading: false
119
+ });
120
+ }
121
+ });
122
+ });
123
+ _defineProperty(this, "updateJobStatus", () => {
124
+ this.setState({
125
+ loading: true
126
+ }, async () => {
127
+ try {
128
+ const res = await maintenanceActions.editJobStatus(this.props.job.id, this.state.status);
129
+ this.props.jobAdded(res.data.job);
130
+ this.getJob();
131
+ } catch (error) {
132
+ console.log('updateJobStatus error', error);
133
+ } finally {
134
+ this.setState({
135
+ loading: false
136
+ });
137
+ }
138
+ });
139
+ });
140
+ _defineProperty(this, "onPressBack", () => {
141
+ Services.navigation.goBack();
142
+ });
143
+ _defineProperty(this, "onOpenStatusPicker", () => {
144
+ this.setState({
145
+ showStatusPopup: true
146
+ });
147
+ });
148
+ _defineProperty(this, "onCloseStatusPopup", () => {
149
+ this.setState({
150
+ showStatusPopup: false
151
+ });
152
+ });
153
+ _defineProperty(this, "onSelectStatus", status => {
154
+ this.setState({
155
+ status,
156
+ showStatusPopup: false
157
+ }, () => {
158
+ this.updateJobStatus();
159
+ });
160
+ });
161
+ _defineProperty(this, "openStaffNotes", () => {
162
+ Services.navigation.navigate(values.screenRequestNotes, {
163
+ job: this.state.job,
164
+ onChange: this.getJob
165
+ });
166
+ });
167
+ _defineProperty(this, "onOpenDatePicker", () => {
168
+ this.setState({
169
+ popUpType: 'date',
170
+ isDateTimePickerVisible: true
171
+ });
172
+ });
173
+ _defineProperty(this, "onCloseDatePicker", () => {
174
+ this.setState({
175
+ isDateTimePickerVisible: false
176
+ });
177
+ });
178
+ _defineProperty(this, "onDateSelected", date => {
179
+ if (this.state.popUpType === 'date') {
180
+ date = moment(date);
181
+ this.setState({
182
+ expectedDate: date,
183
+ expectedDateText: date.format('DD/MM/YYYY'),
184
+ isDateTimePickerVisible: false
185
+ }, () => {
186
+ this.updateJob();
187
+ });
188
+ }
189
+ });
190
+ _defineProperty(this, "onToggleDetails", () => {
191
+ this.setState({
192
+ showMore: !this.state.showMore
193
+ });
194
+ });
195
+ _defineProperty(this, "onLeaveMessage", () => {
196
+ this.setState({
197
+ showMessages: true
198
+ });
199
+ });
200
+ _defineProperty(this, "onCommentsLoaded", count => {
201
+ if (count > 0) {
202
+ this.setState({
203
+ showMessages: true
204
+ });
205
+ }
206
+ });
207
+ _defineProperty(this, "onCommentAdded", () => {
208
+ this.setState({
209
+ loading: true
210
+ }, async () => {
211
+ try {
212
+ const job = await maintenanceActions.getJob(this.props.user.site, this.props.job.id);
213
+ // console.log('onCommentAdded', job?.data);
214
+ this.props.jobAdded(job.data);
215
+ this.getJob();
216
+ } catch (error) {
217
+ console.log('onCommentAdded error', error);
218
+ } finally {
219
+ this.setState({
220
+ loading: false
221
+ });
222
+ }
223
+ });
224
+ });
225
+ _defineProperty(this, "hasPermission", () => {
226
+ const {
227
+ job
228
+ } = this.state;
229
+ const {
230
+ permissions
231
+ } = this.props.user;
232
+ if (_.includes(permissions, values.permissionMaintenanceTracking)) {
233
+ return true;
234
+ }
235
+ if (_.includes(permissions, values.permissionMaintenanceAssign)) {
236
+ return job.AssigneeId === this.props.user.Id;
237
+ }
238
+ return false;
239
+ });
240
+ _defineProperty(this, "toggleFullscreenVideo", url => {
241
+ if (typeof url !== 'string') url = '';
242
+ this.setState({
243
+ showFullscreenVideo: url.length > 0,
244
+ currentVideoUrl: url
245
+ });
246
+ });
247
+ _defineProperty(this, "onOpenAssigneePicker", () => {
248
+ const options = this.state.assignees.map(a => {
249
+ return {
250
+ key: a.id,
251
+ name: a.displayName
252
+ };
253
+ });
254
+ Services.navigation.navigate('optionSelector', {
255
+ options,
256
+ selection: this.state.job.AssigneeId,
257
+ title: 'Assign request',
258
+ onSelect: this.onSelectAssignee
259
+ });
260
+ });
261
+ _defineProperty(this, "onSelectAssignee", assignee => {
262
+ this.setState({
263
+ loading: true
264
+ }, async () => {
265
+ try {
266
+ console.log('onSelectAssignee', this.props.job.id, assignee.key);
267
+ const res = await maintenanceActions.assignJob(this.props.job.id, assignee.key);
268
+ this.props.jobAdded(res.data.job);
269
+ this.getJob();
270
+ } catch (error) {
271
+ console.log('onSelectAssignee error', error);
272
+ } finally {
273
+ this.setState({
274
+ loading: false
275
+ });
276
+ }
277
+ });
278
+ });
279
+ this.state = {
280
+ job: {},
281
+ isDateTimePickerVisible: false,
282
+ popUpType: '',
283
+ status: '',
284
+ expectedDate: null,
285
+ expectedDateText: '',
286
+ seen: false,
287
+ showMore: true,
288
+ showStatusPopup: false,
289
+ loading: false,
290
+ showFullscreenVideo: false,
291
+ currentVideoUrl: '',
292
+ galleryOpen: false,
293
+ galleryImages: [],
294
+ showMessages: false,
295
+ assignees: []
296
+ };
297
+ this.scrollView = /*#__PURE__*/React.createRef();
298
+ this.commentReply = /*#__PURE__*/React.createRef();
299
+ this.commentSection = /*#__PURE__*/React.createRef();
300
+ }
301
+ componentDidMount() {
302
+ this.getJob();
303
+ this.updateJobState(this.props.job);
304
+ this.getAssignees();
305
+ }
306
+ updateJobState(defaultJob) {
307
+ const job = _.find(this.props.jobs, j => j.id === this.props.job.id) || defaultJob;
308
+ if (!job) {
309
+ this.getJob();
310
+ return;
311
+ }
312
+ const newState = {
313
+ job,
314
+ status: job.status
315
+ };
316
+ if (job.expectedDate) {
317
+ newState.expectedDate = moment(job.expectedDate);
318
+ newState.expectedDateText = newState.expectedDate.format('DD/MM/YYYY');
319
+ }
320
+ if (job.seen) newState.seen = job.seen;
321
+ this.setState(newState, () => {
322
+ this.markSeen();
323
+ });
324
+ }
325
+ openGallery(galleryImages, index) {
326
+ this.setState({
327
+ galleryOpen: true,
328
+ galleryImages
329
+ });
330
+ this.refs.imagePopup.scrollTo(index);
331
+ }
332
+ closeGallery() {
333
+ this.setState({
334
+ galleryOpen: false
335
+ });
336
+ }
337
+ renderLoading() {
338
+ return /*#__PURE__*/React.createElement(Components.LoadingIndicator, {
339
+ visible: this.state.loading
340
+ });
341
+ }
342
+ renderTop() {
343
+ const {
344
+ status,
345
+ job
346
+ } = this.state;
347
+ const {
348
+ statusText,
349
+ statusColor
350
+ } = getJobStatusProps(status);
351
+ const canEdit = this.hasPermission();
352
+ const showSeen = !status || status === jobStatusOptions[0].name;
353
+ return /*#__PURE__*/React.createElement(View, {
354
+ style: {
355
+ ...Helper.getShadowStyle()
356
+ }
357
+ }, /*#__PURE__*/React.createElement(View, {
358
+ style: styles.jobTitleContainer
359
+ }, job.jobId ? /*#__PURE__*/React.createElement(Text, {
360
+ style: [styles.jobIdText, {
361
+ color: this.props.colourBrandingMain
362
+ }]
363
+ }, `${values.textEntityName} #${job.jobId}`) : null, /*#__PURE__*/React.createElement(Text, {
364
+ style: styles.jobTitleText
365
+ }, job.title), /*#__PURE__*/React.createElement(View, {
366
+ style: styles.jobTypeSeenContainer
367
+ }, /*#__PURE__*/React.createElement(View, {
368
+ style: [styles.jobTypeContainer, {
369
+ backgroundColor: Colours.hexToRGBAstring(this.props.colourBrandingMain, 0.2)
370
+ }]
371
+ }, /*#__PURE__*/React.createElement(Text, {
372
+ style: [styles.jobTypeText, {
373
+ color: this.props.colourBrandingMain
374
+ }],
375
+ numberOfLines: 2
376
+ }, job.type)), showSeen && this.state.seen && /*#__PURE__*/React.createElement(View, {
377
+ style: styles.jobSeenContainer
378
+ }, /*#__PURE__*/React.createElement(Icon, {
379
+ name: "check",
380
+ type: "font-awesome",
381
+ iconStyle: [styles.jobSeenIcon, {
382
+ color: this.props.colourBrandingMain
383
+ }]
384
+ }), /*#__PURE__*/React.createElement(Text, {
385
+ style: [styles.jobSeenText, {
386
+ color: this.props.colourBrandingMain
387
+ }]
388
+ }, "Seen"))), job.lastActivityUnix && /*#__PURE__*/React.createElement(View, {
389
+ style: styles.textSectionInner
390
+ }, /*#__PURE__*/React.createElement(Text, {
391
+ style: styles.textSectionLabel
392
+ }, "Last Updated On"), /*#__PURE__*/React.createElement(View, {
393
+ style: styles.textSectionTextContainer
394
+ }, /*#__PURE__*/React.createElement(Text, {
395
+ style: styles.textSectionText
396
+ }, moment(job.lastActivityUnix).format('ddd D MMMM, h:mm A'))))), /*#__PURE__*/React.createElement(View, {
397
+ style: styles.jobStatusExpectedContainer
398
+ }, /*#__PURE__*/React.createElement(View, {
399
+ style: styles.jobStatusOuterContainer
400
+ }, /*#__PURE__*/React.createElement(Text, {
401
+ style: styles.jobStatusHeading
402
+ }, "STATUS"), /*#__PURE__*/React.createElement(TouchableOpacity, {
403
+ onPress: canEdit ? this.onOpenStatusPicker : null
404
+ }, /*#__PURE__*/React.createElement(View, {
405
+ style: [styles.jobStatusContainer, {
406
+ backgroundColor: statusColor
407
+ }]
408
+ }, /*#__PURE__*/React.createElement(Text, {
409
+ style: styles.jobStatusText
410
+ }, statusText)))), this.hasPermission() && /*#__PURE__*/React.createElement(View, {
411
+ style: styles.jobStatusOuterContainer
412
+ }, /*#__PURE__*/React.createElement(Text, {
413
+ style: styles.jobStatusHeading
414
+ }, "STAFF NOTES"), /*#__PURE__*/React.createElement(TouchableOpacity, {
415
+ onPress: this.openStaffNotes
416
+ }, /*#__PURE__*/React.createElement(View, {
417
+ style: [styles.jobStatusContainer, {
418
+ backgroundColor: this.props.colourBrandingMain
419
+ }]
420
+ }, /*#__PURE__*/React.createElement(Icon, {
421
+ name: "pencil-square-o",
422
+ type: "font-awesome",
423
+ iconStyle: styles.jobStatusIcon
424
+ }), /*#__PURE__*/React.createElement(Text, {
425
+ style: styles.jobStatusText
426
+ }, "Notes (", (job.Notes || []).length, ")"))))));
427
+ }
428
+ renderPlayableImageUrl(images, index, containerStyle, showMore) {
429
+ const url = images[index || 0];
430
+ const thumbUrl = Helper.getThumb300(url);
431
+ if (Helper.isVideo(url)) {
432
+ return /*#__PURE__*/React.createElement(ImageBackground, {
433
+ style: [{
434
+ flex: 1
435
+ }, containerStyle],
436
+ source: {
437
+ uri: thumbUrl
438
+ }
439
+ }, /*#__PURE__*/React.createElement(View, {
440
+ style: styles.imagePlayContainer
441
+ }, /*#__PURE__*/React.createElement(TouchableOpacity, {
442
+ onPress: this.toggleFullscreenVideo.bind(this, url)
443
+ }, /*#__PURE__*/React.createElement(Icon, {
444
+ name: "play",
445
+ type: "font-awesome",
446
+ iconStyle: styles.imageControlIcon
447
+ }))));
448
+ }
449
+ const imageUrl = Helper.get1400(url);
450
+ return /*#__PURE__*/React.createElement(TouchableOpacity, {
451
+ style: containerStyle,
452
+ onPress: this.openGallery.bind(this, images, index || 0)
453
+ }, /*#__PURE__*/React.createElement(ImageBackground, {
454
+ style: styles.imageContainer,
455
+ source: {
456
+ uri: imageUrl
457
+ }
458
+ }, showMore && /*#__PURE__*/React.createElement(Text, {
459
+ style: styles.plusImages
460
+ }, "+", this.state.job.images.length - 2)));
461
+ }
462
+ renderPlayableImage(images, index, containerStyle, showMore) {
463
+ return this.renderPlayableImageUrl(images, index, containerStyle, showMore);
464
+ }
465
+ renderImage(images, image = null) {
466
+ if (!_.isNil(images) && !_.isEmpty(images)) {
467
+ if (images.length >= 2) {
468
+ return /*#__PURE__*/React.createElement(View, {
469
+ style: styles.sideBySideImages
470
+ }, this.renderPlayableImage(images, 0, styles.sideBySideImageContainer), this.renderPlayableImage(images, 1, styles.sideBySideImageContainer, images.length > 2));
471
+ } else {
472
+ return /*#__PURE__*/React.createElement(View, {
473
+ style: styles.singleImageContainer
474
+ }, this.renderPlayableImage(images, 0));
475
+ }
476
+ } else if (!_.isNil(image)) {
477
+ return /*#__PURE__*/React.createElement(View, {
478
+ style: styles.singleImageContainer
479
+ }, this.renderPlayableImageUrl([image], 0));
480
+ }
481
+ return null;
482
+ }
483
+ renderImagePopup() {
484
+ return /*#__PURE__*/React.createElement(Components.ImagePopup, {
485
+ visible: this.state.galleryOpen,
486
+ images: this.state.galleryImages,
487
+ onClose: this.closeGallery.bind(this),
488
+ ref: "imagePopup"
489
+ });
490
+ }
491
+ renderAssignee() {
492
+ const {
493
+ job
494
+ } = this.state;
495
+ if (!this.hasPermission() && !job.Assignee) return null;
496
+ const content = /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Text, {
497
+ style: styles.locationLabel
498
+ }, "Assigned To"), /*#__PURE__*/React.createElement(View, null, job.Assignee && /*#__PURE__*/React.createElement(View, {
499
+ style: styles.profileContainer
500
+ }, /*#__PURE__*/React.createElement(Components.ProfilePic, {
501
+ ProfilePic: job.Assignee.profilePic,
502
+ Diameter: 40
503
+ }), /*#__PURE__*/React.createElement(View, {
504
+ style: styles.nameContainer
505
+ }, /*#__PURE__*/React.createElement(Text, {
506
+ style: styles.nameText
507
+ }, job.Assignee.displayName)))));
508
+ if (this.hasPermission()) {
509
+ return /*#__PURE__*/React.createElement(Components.FormCardSectionOptionLauncher, {
510
+ onPress: this.onOpenAssigneePicker,
511
+ title: "Assigned To",
512
+ value: job.Assignee ? job.Assignee.displayName : 'Unassigned',
513
+ textStyle: styles.detailsText,
514
+ sectionStyle: styles.detailsSection
515
+ }, content);
516
+ }
517
+ return content;
518
+ }
519
+ renderCustomFields() {
520
+ const {
521
+ job
522
+ } = this.state;
523
+ const {
524
+ customFields
525
+ } = job;
526
+ const renderAnswer = field => {
527
+ switch (field.type) {
528
+ case 'date':
529
+ return /*#__PURE__*/React.createElement(Text, {
530
+ style: styles.customText
531
+ }, field.answer ? moment(field.answer, 'YYYY-MM-DD').format('DD MMM YYYY') : '');
532
+ case 'time':
533
+ return /*#__PURE__*/React.createElement(Text, {
534
+ style: styles.customText
535
+ }, field.answer ? moment(field.answer, 'HH:mm').format('h:mm a') : '');
536
+ case 'yn':
537
+ return /*#__PURE__*/React.createElement(Text, {
538
+ style: styles.customText
539
+ }, field.answer ? 'Yes' : 'No');
540
+ case 'checkbox':
541
+ return /*#__PURE__*/React.createElement(Text, {
542
+ style: styles.customText
543
+ }, field.answer && Array.isArray(field.answer) ? field.answer.join(', ') : '');
544
+ case 'image':
545
+ return /*#__PURE__*/React.createElement(View, {
546
+ style: {
547
+ marginTop: 8
548
+ }
549
+ }, this.renderImage(field.answer));
550
+ default:
551
+ return /*#__PURE__*/React.createElement(Text, {
552
+ style: styles.customText
553
+ }, field.answer);
554
+ }
555
+ };
556
+ return customFields.map((field, index) => {
557
+ if (['staticTitle', 'staticText'].includes(field.type)) return null;
558
+ if (_.isNil(field.answer) || field.answer === '' || Array.isArray(field.answer) && field.answer.length === 0) return null;
559
+ return /*#__PURE__*/React.createElement(View, {
560
+ key: index
561
+ }, /*#__PURE__*/React.createElement(Text, {
562
+ style: styles.customLabel
563
+ }, field.label), renderAnswer(field));
564
+ });
565
+ }
566
+ rendeDetails() {
567
+ const {
568
+ job
569
+ } = this.state;
570
+ const {
571
+ customFields
572
+ } = job;
573
+ const hasCustomFields = customFields && customFields.length > 0;
574
+ return /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Components.FormCardSectionOptionLauncher, {
575
+ onPress: this.onToggleDetails,
576
+ title: "Details",
577
+ icon: this.state.showMore ? 'angle-up' : 'angle-down',
578
+ textStyle: styles.detailsText,
579
+ sectionStyle: styles.detailsSection
580
+ }), this.state.showMore && /*#__PURE__*/React.createElement(View, null, hasCustomFields ? this.renderCustomFields() : null, !hasCustomFields ? /*#__PURE__*/React.createElement(React.Fragment, null, this.renderImage(job.images, job.image), !_.isEmpty(job.description) && /*#__PURE__*/React.createElement(Text, {
581
+ numberOfLines: 10,
582
+ style: styles.jobDescriptionText
583
+ }, job.description)) : null, /*#__PURE__*/React.createElement(Text, {
584
+ style: styles.locationLabel
585
+ }, "Address"), /*#__PURE__*/React.createElement(Text, {
586
+ style: styles.locationText
587
+ }, job.room), !hasCustomFields && job.isHome ? /*#__PURE__*/React.createElement(View, {
588
+ style: styles.detailsSection
589
+ }, /*#__PURE__*/React.createElement(Text, {
590
+ style: styles.locationLabel
591
+ }, "Must be home"), /*#__PURE__*/React.createElement(Text, {
592
+ style: styles.locationText
593
+ }, job.homeText)) : null, /*#__PURE__*/React.createElement(Text, {
594
+ style: styles.requesterLabel
595
+ }, "Submitted By"), /*#__PURE__*/React.createElement(View, {
596
+ style: styles.profileContainer
597
+ }, /*#__PURE__*/React.createElement(Components.ProfilePic, {
598
+ ProfilePic: job.userProfilePic,
599
+ Diameter: 40
600
+ }), /*#__PURE__*/React.createElement(View, {
601
+ style: styles.nameContainer
602
+ }, /*#__PURE__*/React.createElement(Text, {
603
+ style: styles.nameText
604
+ }, job.userName), !_.isEmpty(job.phone) && /*#__PURE__*/React.createElement(Text, {
605
+ style: styles.phoneText
606
+ }, job.phone)))));
607
+ }
608
+ renderMessages() {
609
+ return /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Components.CommentSection, {
610
+ ref: this.commentSection,
611
+ commentReply: this.commentReply,
612
+ scrollView: this.scrollView,
613
+ adminPermission: values.permissionMaintenanceTracking,
614
+ entityType: values.featureKey,
615
+ entityId: this.props.job.id,
616
+ entityName: this.props.job.title,
617
+ site: this.state.job.site || this.state.job.location,
618
+ live: true,
619
+ refreshFrequency: 10000,
620
+ placeHolder: '',
621
+ style: {
622
+ flex: 1,
623
+ paddingHorizontal: 0,
624
+ paddingTop: 16
625
+ },
626
+ onCommentsLoaded: this.onCommentsLoaded,
627
+ onCommentAdded: this.onCommentAdded,
628
+ hideAddComment: true,
629
+ disableFlag: true
630
+ }), !this.state.showMessages && /*#__PURE__*/React.createElement(Components.InlineButton, {
631
+ onPress: this.onLeaveMessage,
632
+ color: this.props.colourBrandingMain,
633
+ touchableStyle: {
634
+ marginTop: 10
635
+ },
636
+ style: {
637
+ height: 36
638
+ },
639
+ textStyle: {
640
+ color: '#fff'
641
+ },
642
+ fullWidth: true
643
+ }, "Leave Message"));
644
+ }
645
+ renderMessagesReply() {
646
+ if (!this.state.showMessages) return null;
647
+ return /*#__PURE__*/React.createElement(Components.CommentReply, {
648
+ ref: this.commentReply,
649
+ commentSection: this.commentSection,
650
+ scrollView: this.scrollView,
651
+ entityType: values.featureKey,
652
+ entityId: this.props.job.id,
653
+ entityName: this.props.job.title,
654
+ site: this.state.job.site || this.state.job.location
655
+ // noScroll={true}
656
+ // style={{ position: 'absolute', bottom: 0, left: 0, right: 0 }}
657
+ });
658
+ }
659
+ renderStatusPopup() {
660
+ if (!this.state.showStatusPopup) return null;
661
+ return /*#__PURE__*/React.createElement(StatusSelectorPopup, {
662
+ onClose: this.onCloseStatusPopup,
663
+ onSelect: this.onSelectStatus
664
+ });
665
+ }
666
+ render() {
667
+ if (this.state.forbidden) {
668
+ return /*#__PURE__*/React.createElement(Components.Forbidden, null);
669
+ }
670
+ return /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
671
+ behavior: Platform.OS === 'ios' && 'padding',
672
+ style: styles.container
673
+ }, /*#__PURE__*/React.createElement(Components.Header, {
674
+ leftIcon: "angle-left",
675
+ onPressLeft: this.onPressBack,
676
+ text: Config.env.strings.MAINTENANCE_REQUEST_DETAILS
677
+ }), this.renderLoading(), /*#__PURE__*/React.createElement(ScrollView, {
678
+ ref: this.scrollView,
679
+ contentContainerStyle: {
680
+ paddingBottom: 26
681
+ },
682
+ style: {
683
+ height: '100%'
684
+ }
685
+ }, /*#__PURE__*/React.createElement(View, {
686
+ style: styles.innerContainer
687
+ }, this.renderTop(), this.renderAssignee(), this.rendeDetails(), this.renderMessages())), this.renderMessagesReply(), this.renderStatusPopup(), this.renderImagePopup(), /*#__PURE__*/React.createElement(DateTimePicker, {
688
+ isVisible: this.state.isDateTimePickerVisible,
689
+ onConfirm: this.onDateSelected,
690
+ onCancel: this.onCloseDatePicker,
691
+ mode: this.state.popUpType,
692
+ headerTextIOS: `Pick a ${this.state.popUpType}`
693
+ }));
694
+ }
695
+ }
696
+ const styles = StyleSheet.create({
697
+ container: {
698
+ flex: 1,
699
+ backgroundColor: '#fff'
700
+ },
701
+ innerContainer: {
702
+ paddingTop: 23,
703
+ paddingHorizontal: 16
704
+ },
705
+ jobTitleContainer: {
706
+ paddingVertical: 14,
707
+ paddingHorizontal: 12
708
+ },
709
+ jobIdText: {
710
+ fontFamily: 'sf-medium',
711
+ fontSize: 12,
712
+ marginBottom: 4
713
+ },
714
+ jobTitleText: {
715
+ fontFamily: 'sf-semibold',
716
+ fontSize: 20,
717
+ color: Colours.TEXT_DARKEST,
718
+ marginBottom: 8
719
+ },
720
+ jobTypeSeenContainer: {
721
+ flexDirection: 'row',
722
+ alignItems: 'center'
723
+ },
724
+ jobTypeContainer: {
725
+ padding: 4,
726
+ minWidth: 80,
727
+ maxWidth: 140,
728
+ borderRadius: 4,
729
+ justifyContent: 'center'
730
+ },
731
+ jobTypeText: {
732
+ fontFamily: 'sf-semibold',
733
+ fontSize: 12,
734
+ textAlign: 'center',
735
+ maxWidth: '100%'
736
+ },
737
+ jobSeenContainer: {
738
+ flexDirection: 'row',
739
+ alignItems: 'center',
740
+ marginLeft: 10
741
+ },
742
+ jobSeenIcon: {
743
+ fontSize: 12
744
+ },
745
+ jobSeenText: {
746
+ fontFamily: 'sf-semibold',
747
+ fontSize: 12,
748
+ marginLeft: 4
749
+ },
750
+ jobStatusDateText: {
751
+ marginTop: 8,
752
+ fontFamily: 'sf-medium',
753
+ fontSize: 13,
754
+ color: Colours.TEXT_LIGHT
755
+ },
756
+ jobStatusExpectedContainer: {
757
+ flexDirection: 'row',
758
+ alignItems: 'flex-start',
759
+ justifyContent: 'space-between',
760
+ borderTopWidth: 1,
761
+ borderTopColor: Colours.LINEGREY,
762
+ paddingVertical: 14,
763
+ paddingHorizontal: 12
764
+ },
765
+ jobStatusOuterContainer: {
766
+ // marginRight: 50,
767
+ },
768
+ jobStatusHeading: {
769
+ fontFamily: 'sf-bold',
770
+ fontSize: 11,
771
+ letterSpacing: 0.8,
772
+ color: Colours.TEXT_DARK,
773
+ marginBottom: 6
774
+ },
775
+ jobStatusContainer: {
776
+ flexDirection: 'row',
777
+ alignItems: 'center',
778
+ width: 120,
779
+ height: 30,
780
+ paddingHorizontal: 8,
781
+ borderRadius: 4
782
+ },
783
+ jobStatusIcon: {
784
+ color: '#fff',
785
+ fontSize: 14,
786
+ marginRight: 8
787
+ },
788
+ jobStatusText: {
789
+ color: '#fff',
790
+ textAlign: 'center',
791
+ fontFamily: 'sf-semibold',
792
+ fontSize: 13,
793
+ flex: 1,
794
+ textAlign: 'center'
795
+ },
796
+ jobExpectedDateContainer: {
797
+ backgroundColor: Colours.BOXGREY,
798
+ flexDirection: 'row',
799
+ width: 115,
800
+ height: 30,
801
+ borderRadius: 4,
802
+ alignItems: 'center',
803
+ paddingLeft: 8
804
+ },
805
+ jobExpectedDate: {
806
+ fontFamily: 'sf-regular',
807
+ fontSize: 13,
808
+ color: Colours.hexToRGBAstring(Colours.TEXT_DARKEST, 0.5)
809
+ },
810
+ detailsText: {
811
+ fontFamily: 'sf-semibold',
812
+ fontSize: 16,
813
+ color: Colours.TEXT_DARKEST
814
+ },
815
+ detailsSection: {
816
+ marginTop: 8,
817
+ paddingHorizontal: 0,
818
+ paddingBottom: 12
819
+ },
820
+ sideBySideImages: {
821
+ flex: 1,
822
+ flexDirection: 'row',
823
+ justifyContent: 'space-between',
824
+ marginBottom: 16
825
+ },
826
+ sideBySideImageContainer: {
827
+ backgroundColor: '#fff',
828
+ width: '48%',
829
+ height: 150,
830
+ borderRadius: 2,
831
+ overflow: 'hidden'
832
+ },
833
+ singleImageContainer: {
834
+ backgroundColor: '#fff',
835
+ width: '100%',
836
+ height: 150,
837
+ flex: 1,
838
+ borderRadius: 2,
839
+ overflow: 'hidden',
840
+ marginBottom: 16
841
+ },
842
+ imageContainer: {
843
+ height: 150,
844
+ width: 'auto',
845
+ justifyContent: 'center'
846
+ },
847
+ imagePlayContainer: {
848
+ position: 'absolute',
849
+ top: 0,
850
+ left: 0,
851
+ right: 0,
852
+ bottom: 0,
853
+ alignItems: 'center',
854
+ justifyContent: 'center'
855
+ },
856
+ imageControlIcon: {
857
+ color: '#fff',
858
+ fontSize: 30,
859
+ textShadowColor: 'rgba(0,0,0,0.3)',
860
+ textShadowOffset: {
861
+ width: 2,
862
+ height: 2
863
+ }
864
+ },
865
+ plusImages: {
866
+ fontFamily: 'sf-bold',
867
+ fontSize: 32,
868
+ textAlign: 'center',
869
+ color: '#fff',
870
+ textShadowColor: 'rgba(0, 0, 0, 0.5)',
871
+ textShadowOffset: {
872
+ width: 0,
873
+ height: 2
874
+ },
875
+ textShadowRadius: 8
876
+ },
877
+ jobDescriptionText: {
878
+ fontFamily: 'sf-medium',
879
+ fontSize: 14,
880
+ color: Colours.TEXT_LIGHT,
881
+ paddingBottom: 16
882
+ },
883
+ locationLabel: {
884
+ fontFamily: 'sf-bold',
885
+ fontSize: 14,
886
+ color: Colours.TEXT_DARKEST
887
+ },
888
+ locationText: {
889
+ fontFamily: 'sf-regular',
890
+ fontSize: 16,
891
+ color: Colours.TEXT_DARKEST,
892
+ paddingVertical: 8
893
+ },
894
+ requesterLabel: {
895
+ fontFamily: 'sf-bold',
896
+ fontSize: 14,
897
+ color: Colours.TEXT_DARKEST,
898
+ paddingVertical: 10
899
+ },
900
+ profileContainer: {
901
+ flexDirection: 'row',
902
+ alignItems: 'center'
903
+ },
904
+ nameContainer: {
905
+ marginLeft: 18
906
+ },
907
+ nameText: {
908
+ fontSize: 'sf-semibold',
909
+ fontSize: 14,
910
+ color: Colours.TEXT_DARKEST,
911
+ marginBottom: 4
912
+ },
913
+ phoneText: {
914
+ fontSize: 'sf-medium',
915
+ fontSize: 14,
916
+ color: Colours.TEXT_LIGHT
917
+ },
918
+ textSectionInner: {
919
+ flexDirection: 'row',
920
+ justifyContent: 'space-between',
921
+ alignItems: 'center',
922
+ marginTop: 8
923
+ },
924
+ textSectionLabel: {
925
+ fontFamily: 'sf-semibold',
926
+ fontSize: 12,
927
+ lineHeight: 24,
928
+ color: Colours.TEXT_DARKEST
929
+ },
930
+ textSectionTextContainer: {
931
+ flexDirection: 'row',
932
+ alignItems: 'center'
933
+ },
934
+ textSectionText: {
935
+ fontFamily: 'sf-regular',
936
+ fontSize: 13,
937
+ lineHeight: 24,
938
+ color: Colours.TEXT_LIGHT
939
+ },
940
+ textSectionAngleRight: {
941
+ fontSize: 24,
942
+ marginLeft: 10,
943
+ lineHeight: 24
944
+ },
945
+ customLabel: {
946
+ fontFamily: 'sf-bold',
947
+ fontSize: 14,
948
+ color: Colours.TEXT_DARKEST
949
+ },
950
+ customText: {
951
+ fontFamily: 'sf-regular',
952
+ fontSize: 16,
953
+ color: Colours.TEXT_DARKEST,
954
+ paddingVertical: 8
955
+ },
956
+ customStaticTitle: {
957
+ fontSize: 20,
958
+ fontFamily: 'sf-semibold',
959
+ color: Colours.TEXT_DARKEST,
960
+ marginBottom: 10
961
+ },
962
+ customStaticText: {
963
+ fontSize: 17,
964
+ fontFamily: 'sf-regular',
965
+ color: Colours.TEXT_DARKEST,
966
+ lineHeight: 24,
967
+ marginBottom: 10
968
+ }
969
+ });
970
+ const mapStateToProps = state => {
971
+ return {
972
+ user: state.user,
973
+ colourBrandingMain: Colours.getMainBrandingColourFromState(state),
974
+ jobs: state[values.reducerKey].jobs
975
+ };
976
+ };
977
+ export default connect(mapStateToProps, {
978
+ jobAdded
979
+ })(RequestDetail);
980
+ //# sourceMappingURL=RequestDetail.js.map