@plusscommunities/pluss-maintenance-app 6.0.20 → 6.0.21-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 +4 -4
- package/dist/module/actions/JobActions.js.map +1 -1
- package/dist/module/actions/index.js +1 -1
- package/dist/module/actions/index.js.map +1 -1
- package/dist/module/actions/types.js +1 -1
- package/dist/module/actions/types.js.map +1 -1
- package/dist/module/apis/index.js +3 -3
- package/dist/module/apis/index.js.map +1 -1
- package/dist/module/apis/maintenanceActions.js +36 -36
- package/dist/module/apis/maintenanceActions.js.map +1 -1
- package/dist/module/apis/userActions.js +5 -5
- package/dist/module/apis/userActions.js.map +1 -1
- package/dist/module/components/FilterPopupMenu.js +49 -49
- package/dist/module/components/FilterPopupMenu.js.map +1 -1
- package/dist/module/components/MaintenanceList.js +38 -38
- package/dist/module/components/MaintenanceList.js.map +1 -1
- package/dist/module/components/MaintenanceListItem.js +62 -62
- package/dist/module/components/MaintenanceListItem.js.map +1 -1
- package/dist/module/components/MaintenanceWidgetItem.js +27 -27
- package/dist/module/components/MaintenanceWidgetItem.js.map +1 -1
- package/dist/module/components/PrioritySelectorPopup.js +15 -15
- package/dist/module/components/PrioritySelectorPopup.js.map +1 -1
- package/dist/module/components/StatusSelectorPopup.js +16 -16
- package/dist/module/components/StatusSelectorPopup.js.map +1 -1
- package/dist/module/components/WidgetLarge.js +2 -2
- package/dist/module/components/WidgetLarge.js.map +1 -1
- package/dist/module/components/WidgetSmall.js +19 -19
- package/dist/module/components/WidgetSmall.js.map +1 -1
- package/dist/module/core.config.js +1 -1
- package/dist/module/core.config.js.map +1 -1
- package/dist/module/feature.config.js +17 -17
- package/dist/module/feature.config.js.map +1 -1
- package/dist/module/helper.js +10 -10
- package/dist/module/helper.js.map +1 -1
- package/dist/module/index.js +11 -11
- package/dist/module/index.js.map +1 -1
- package/dist/module/reducers/JobsReducer.js +13 -13
- package/dist/module/reducers/JobsReducer.js.map +1 -1
- package/dist/module/screens/JobTypePicker.js +17 -17
- package/dist/module/screens/JobTypePicker.js.map +1 -1
- package/dist/module/screens/MaintenancePage.js +10 -10
- package/dist/module/screens/MaintenancePage.js.map +1 -1
- package/dist/module/screens/MaintenanceUserPicker.js +129 -22
- package/dist/module/screens/MaintenanceUserPicker.js.map +1 -1
- package/dist/module/screens/RequestDetail.js +145 -145
- package/dist/module/screens/RequestDetail.js.map +1 -1
- package/dist/module/screens/RequestNotes.js +59 -59
- package/dist/module/screens/RequestNotes.js.map +1 -1
- package/dist/module/screens/ServiceRequest.js +187 -187
- package/dist/module/screens/ServiceRequest.js.map +1 -1
- package/dist/module/values.config.a.js +30 -30
- package/dist/module/values.config.a.js.map +1 -1
- package/dist/module/values.config.default.js +34 -34
- package/dist/module/values.config.default.js.map +1 -1
- package/dist/module/values.config.enquiry.js +34 -34
- package/dist/module/values.config.enquiry.js.map +1 -1
- package/dist/module/values.config.feedback.js +34 -34
- package/dist/module/values.config.feedback.js.map +1 -1
- package/dist/module/values.config.food.js +34 -34
- package/dist/module/values.config.food.js.map +1 -1
- package/dist/module/values.config.forms.js +34 -34
- package/dist/module/values.config.forms.js.map +1 -1
- package/dist/module/values.config.js +34 -34
- package/dist/module/values.config.js.map +1 -1
- package/package.json +51 -51
- package/src/actions/JobActions.js +67 -60
- package/src/actions/index.js +1 -1
- package/src/actions/types.js +1 -2
- package/src/apis/index.js +3 -3
- package/src/apis/maintenanceActions.js +189 -178
- package/src/apis/userActions.js +17 -17
- package/src/components/FilterPopupMenu.js +313 -256
- package/src/components/MaintenanceList.js +396 -317
- package/src/components/MaintenanceListItem.js +347 -288
- package/src/components/MaintenanceWidgetItem.js +145 -124
- package/src/components/PrioritySelectorPopup.js +81 -68
- package/src/components/StatusSelectorPopup.js +81 -70
- package/src/components/WidgetLarge.js +5 -5
- package/src/components/WidgetSmall.js +153 -133
- package/src/core.config.js +27 -3
- package/src/feature.config.js +62 -62
- package/src/helper.js +58 -53
- package/src/index.js +22 -22
- package/src/reducers/JobsReducer.js +85 -66
- package/src/screens/JobTypePicker.js +115 -92
- package/src/screens/MaintenancePage.js +89 -80
- package/src/screens/MaintenanceUserPicker.js +252 -100
- package/src/screens/RequestDetail.js +1348 -1125
- package/src/screens/RequestNotes.js +950 -806
- package/src/screens/ServiceRequest.js +1778 -1550
- package/src/values.config.a.js +33 -33
- package/src/values.config.default.js +39 -39
- package/src/values.config.enquiry.js +39 -39
- package/src/values.config.feedback.js +39 -39
- package/src/values.config.food.js +39 -39
- package/src/values.config.forms.js +39 -39
- package/src/values.config.js +39 -39
|
@@ -1,1564 +1,1792 @@
|
|
|
1
|
-
import React, { Component } from
|
|
1
|
+
import React, { Component } from "react";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from
|
|
15
|
-
import DateTimePicker from
|
|
16
|
-
import { Icon } from
|
|
17
|
-
import _ from
|
|
18
|
-
import moment from
|
|
19
|
-
import { connect } from
|
|
20
|
-
import { jobAdded } from
|
|
21
|
-
import { maintenanceActions, userActions } from
|
|
22
|
-
import { Services } from
|
|
23
|
-
import { Components, Colours, Helper, Config } from
|
|
24
|
-
import { values } from
|
|
25
|
-
|
|
26
|
-
const PHOTO_SIZE = (Dimensions.get(
|
|
3
|
+
Dimensions,
|
|
4
|
+
Platform,
|
|
5
|
+
KeyboardAvoidingView,
|
|
6
|
+
ScrollView,
|
|
7
|
+
Text,
|
|
8
|
+
TouchableOpacity,
|
|
9
|
+
View,
|
|
10
|
+
Switch,
|
|
11
|
+
FlatList,
|
|
12
|
+
ImageBackground,
|
|
13
|
+
Keyboard,
|
|
14
|
+
} from "react-native";
|
|
15
|
+
import DateTimePicker from "react-native-modal-datetime-picker";
|
|
16
|
+
import { Icon } from "react-native-elements";
|
|
17
|
+
import _ from "lodash";
|
|
18
|
+
import moment from "moment";
|
|
19
|
+
import { connect } from "react-redux";
|
|
20
|
+
import { jobAdded } from "../actions";
|
|
21
|
+
import { maintenanceActions, userActions } from "../apis";
|
|
22
|
+
import { Services } from "../feature.config";
|
|
23
|
+
import { Components, Colours, Helper, Config } from "../core.config";
|
|
24
|
+
import { values } from "../values.config";
|
|
25
|
+
|
|
26
|
+
const PHOTO_SIZE = (Dimensions.get("window").width - 64) / 3;
|
|
27
27
|
|
|
28
28
|
class MaintenanceRequest extends Component {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
componentDidMount() {
|
|
85
|
-
this.checkUserPermissions();
|
|
86
|
-
this.getJobTypes();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
checkUserPermissions = async () => {
|
|
90
|
-
// PC-1255: Check if user has userManagement permission
|
|
91
|
-
const hasUserManagement = this.props.permissions?.includes('userManagement') || false;
|
|
92
|
-
|
|
93
|
-
if (hasUserManagement) {
|
|
94
|
-
this.setState({ canCreateOnBehalf: true });
|
|
95
|
-
// Load site users for picker
|
|
96
|
-
await this.loadSiteUsers();
|
|
97
|
-
} else {
|
|
98
|
-
// Default to logged-in user for non-staff or staff without permission
|
|
99
|
-
this.setDefaultUser();
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
loadSiteUsers = async () => {
|
|
104
|
-
try {
|
|
105
|
-
const response = await userActions.getSiteUsers(this.props.site);
|
|
106
|
-
// PC-1255: Load all users (not just residents) to match web admin behavior
|
|
107
|
-
const users = _.sortBy(response.data.Items || [], u => (u.displayName || '').toLowerCase());
|
|
108
|
-
this.setState({ users });
|
|
109
|
-
} catch (error) {
|
|
110
|
-
console.log('Error loading site users:', error);
|
|
111
|
-
// Fall back to default user if loading fails
|
|
112
|
-
this.setDefaultUser();
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
setDefaultUser = () => {
|
|
117
|
-
if (this.props.userType !== 'KIOSK') {
|
|
118
|
-
const defaultUser = {
|
|
119
|
-
userId: this.props.uid,
|
|
120
|
-
displayName: this.props.displayName,
|
|
121
|
-
profilePic: this.props.profilePic,
|
|
122
|
-
};
|
|
123
|
-
this.setState({
|
|
124
|
-
selectedUser: defaultUser,
|
|
125
|
-
userName: this.props.displayName,
|
|
126
|
-
roomNumber: this.props.unit,
|
|
127
|
-
phone: !_.isEmpty(this.props.phoneNumber) ? this.props.phoneNumber : '',
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
componentWillUnmount() {
|
|
133
|
-
clearInterval(this.checkThumb);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
onChangeName = userName => {
|
|
137
|
-
const update = { userName };
|
|
138
|
-
if (!this.state.customFields || !_.some(this.state.customFields, 'isTitle')) {
|
|
139
|
-
update.title = userName;
|
|
140
|
-
}
|
|
141
|
-
this.setState(update);
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
// PC-1255: Handle user picker navigation
|
|
145
|
-
onPressUser = () => {
|
|
146
|
-
const { users, selectedUser } = this.state;
|
|
147
|
-
if (!users || users.length === 0) return;
|
|
148
|
-
|
|
149
|
-
Services.navigation.navigate(values.screenUserPicker, {
|
|
150
|
-
currentUser: selectedUser,
|
|
151
|
-
users,
|
|
152
|
-
onSelectUser: this.onSelectUser.bind(this),
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
// PC-1255: Handle user selection and auto-populate contact details
|
|
157
|
-
onSelectUser = async user => {
|
|
158
|
-
const update = {
|
|
159
|
-
selectedUser: user,
|
|
160
|
-
userName: user.displayName,
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
// PC-1255: Try to fetch full user details for auto-population
|
|
164
|
-
try {
|
|
165
|
-
// getSiteUsers returns 'Id', but fetchUser expects 'userId'
|
|
166
|
-
const userId = user.userId || user.Id;
|
|
167
|
-
const response = await userActions.fetchUser(this.props.site, userId);
|
|
168
|
-
if (response.data && response.data.user) {
|
|
169
|
-
const userDetails = response.data.user;
|
|
170
|
-
if (userDetails.phoneNumber) {
|
|
171
|
-
update.phone = userDetails.phoneNumber;
|
|
172
|
-
}
|
|
173
|
-
if (userDetails.unit) {
|
|
174
|
-
update.roomNumber = userDetails.unit;
|
|
175
|
-
}
|
|
176
|
-
if (!this.state.customFields || !_.some(this.state.customFields, 'isTitle')) {
|
|
177
|
-
update.title = userDetails.displayName || null;
|
|
29
|
+
constructor(props) {
|
|
30
|
+
super(props);
|
|
31
|
+
this.state = {
|
|
32
|
+
submitting: false,
|
|
33
|
+
success: false,
|
|
34
|
+
fail: false,
|
|
35
|
+
error: null,
|
|
36
|
+
showError: false,
|
|
37
|
+
loadingTypes: values.forceCustomFields,
|
|
38
|
+
|
|
39
|
+
userName: "",
|
|
40
|
+
roomNumber: "",
|
|
41
|
+
phone: "",
|
|
42
|
+
title: "",
|
|
43
|
+
description: "",
|
|
44
|
+
times: "",
|
|
45
|
+
|
|
46
|
+
type: "General",
|
|
47
|
+
|
|
48
|
+
uploadingImage: false,
|
|
49
|
+
images: [
|
|
50
|
+
{
|
|
51
|
+
add: true,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
showFullscreenVideo: false,
|
|
55
|
+
currentVideoUrl: "",
|
|
56
|
+
|
|
57
|
+
isHome: false,
|
|
58
|
+
|
|
59
|
+
types: [],
|
|
60
|
+
|
|
61
|
+
confirmationToShow: false,
|
|
62
|
+
|
|
63
|
+
customFields: [],
|
|
64
|
+
customFieldImages: {},
|
|
65
|
+
customFieldDocuments: {},
|
|
66
|
+
isDateTimePickerVisible: false,
|
|
67
|
+
popUpType: "date",
|
|
68
|
+
dateFieldId: null,
|
|
69
|
+
imageFieldId: null,
|
|
70
|
+
|
|
71
|
+
// PC-1255: On-behalf request fields
|
|
72
|
+
canCreateOnBehalf: false,
|
|
73
|
+
selectedUser: null,
|
|
74
|
+
users: [],
|
|
75
|
+
};
|
|
76
|
+
this.checkThumb = null;
|
|
77
|
+
this.keyboardTypes = {
|
|
78
|
+
phone: "phone-pad",
|
|
79
|
+
email: "email-address",
|
|
80
|
+
text: "default",
|
|
81
|
+
};
|
|
178
82
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
83
|
+
|
|
84
|
+
componentDidMount() {
|
|
85
|
+
this.checkUserPermissions();
|
|
86
|
+
this.getJobTypes();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
checkUserPermissions = async () => {
|
|
90
|
+
// PC-1255: Check if user has userManagement permission
|
|
91
|
+
const hasUserManagement =
|
|
92
|
+
this.props.permissions?.includes("userManagement") || false;
|
|
93
|
+
|
|
94
|
+
if (hasUserManagement) {
|
|
95
|
+
this.setState({ canCreateOnBehalf: true });
|
|
96
|
+
// Load site users for picker
|
|
97
|
+
await this.loadSiteUsers();
|
|
98
|
+
} else {
|
|
99
|
+
// Default to logged-in user for non-staff or staff without permission
|
|
100
|
+
this.setDefaultUser();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
loadSiteUsers = async () => {
|
|
105
|
+
try {
|
|
106
|
+
const response = await userActions.getSiteUsers(this.props.site);
|
|
107
|
+
// PC-1255: Load all users (not just residents) to match web admin behavior
|
|
108
|
+
const users = _.sortBy(response.data.Items || [], (u) =>
|
|
109
|
+
(u.displayName || "").toLowerCase(),
|
|
110
|
+
);
|
|
111
|
+
this.setState({ users });
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.log("Error loading site users:", error);
|
|
114
|
+
// Fall back to default user if loading fails
|
|
115
|
+
this.setDefaultUser();
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
setDefaultUser = () => {
|
|
120
|
+
if (this.props.userType !== "KIOSK") {
|
|
121
|
+
const defaultUser = {
|
|
122
|
+
userId: this.props.uid,
|
|
123
|
+
displayName: this.props.displayName,
|
|
124
|
+
profilePic: this.props.profilePic,
|
|
125
|
+
};
|
|
126
|
+
this.setState({
|
|
127
|
+
selectedUser: defaultUser,
|
|
128
|
+
userName: this.props.displayName,
|
|
129
|
+
roomNumber: this.props.unit,
|
|
130
|
+
phone: !_.isEmpty(this.props.phoneNumber) ? this.props.phoneNumber : "",
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
componentWillUnmount() {
|
|
136
|
+
clearInterval(this.checkThumb);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
onChangeName = (userName) => {
|
|
140
|
+
const update = { userName };
|
|
141
|
+
if (
|
|
142
|
+
!this.state.customFields ||
|
|
143
|
+
!_.some(this.state.customFields, "isTitle")
|
|
144
|
+
) {
|
|
145
|
+
update.title = userName;
|
|
146
|
+
}
|
|
147
|
+
this.setState(update);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// PC-1255: Handle user picker navigation
|
|
151
|
+
onPressUser = () => {
|
|
152
|
+
const { users, selectedUser } = this.state;
|
|
153
|
+
if (!users || users.length === 0) return;
|
|
154
|
+
|
|
155
|
+
Services.navigation.navigate(values.screenUserPicker, {
|
|
156
|
+
currentUser: selectedUser,
|
|
157
|
+
users,
|
|
158
|
+
onSelectUser: this.onSelectUser.bind(this),
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// PC-1255: Handle user selection and auto-populate contact details
|
|
163
|
+
onSelectUser = async (user) => {
|
|
164
|
+
const update = {
|
|
165
|
+
selectedUser: user,
|
|
166
|
+
userName: user.displayName,
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// PC-1255: Try to fetch full user details for auto-population
|
|
170
|
+
try {
|
|
171
|
+
// getSiteUsers returns 'Id', but fetchUser expects 'userId'
|
|
172
|
+
const userId = user.userId || user.Id;
|
|
173
|
+
const response = await userActions.fetchUser(this.props.site, userId);
|
|
174
|
+
if (response.data && response.data.user) {
|
|
175
|
+
const userDetails = response.data.user;
|
|
176
|
+
if (userDetails.phoneNumber) {
|
|
177
|
+
update.phone = userDetails.phoneNumber;
|
|
178
|
+
}
|
|
179
|
+
if (userDetails.unit) {
|
|
180
|
+
update.roomNumber = userDetails.unit;
|
|
181
|
+
}
|
|
182
|
+
if (
|
|
183
|
+
!this.state.customFields ||
|
|
184
|
+
!_.some(this.state.customFields, "isTitle")
|
|
185
|
+
) {
|
|
186
|
+
update.title = userDetails.displayName || null;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
} catch (error) {
|
|
190
|
+
// Permission denied (403) or other error - continue without auto-population
|
|
191
|
+
// User can still manually enter contact details
|
|
192
|
+
console.log("Could not fetch user details for auto-population:", error);
|
|
193
|
+
} finally {
|
|
194
|
+
// In any case, we still need a title. Inform the user to set one form field as a title.
|
|
195
|
+
if (!state.title && !update.title) {
|
|
196
|
+
update.title =
|
|
197
|
+
"[Missing title - Set one of the form field as title in the community manager]";
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
this.setState(update);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
onChangeAnswer = (fieldId, answer) => {
|
|
204
|
+
const update = { customFields: _.cloneDeep(this.state.customFields) };
|
|
205
|
+
const field = update.customFields[fieldId];
|
|
206
|
+
field.answer = answer;
|
|
207
|
+
if (field.isTitle) update.title = field.answer;
|
|
208
|
+
this.setState(update);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
onChangeToggleAnswer = (fieldId, answer) => {
|
|
212
|
+
const update = { customFields: _.cloneDeep(this.state.customFields) };
|
|
213
|
+
const field = update.customFields[fieldId];
|
|
214
|
+
field.answer = field.answer === answer ? undefined : answer;
|
|
215
|
+
if (field.isTitle) update.title = field.answer;
|
|
216
|
+
this.setState(update);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
onChangeCheckboxAnswer = (fieldId, answer) => {
|
|
220
|
+
const update = { customFields: _.cloneDeep(this.state.customFields) };
|
|
221
|
+
const field = update.customFields[fieldId];
|
|
222
|
+
field.answer = _.xor(field.answer || [], [answer]);
|
|
223
|
+
if (field.isTitle) update.title = field.answer.join(", ");
|
|
224
|
+
this.setState(update);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
onOpenDatePicker = (field, fieldId) => {
|
|
228
|
+
Keyboard.dismiss();
|
|
229
|
+
this.setState({
|
|
230
|
+
dateFieldId: fieldId,
|
|
231
|
+
popUpType: field.type,
|
|
232
|
+
isDateTimePickerVisible: true,
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
onClearDate = (fieldId) => {
|
|
237
|
+
const update = { customFields: _.cloneDeep(this.state.customFields) };
|
|
238
|
+
const field = update.customFields[fieldId];
|
|
239
|
+
field.answer = undefined;
|
|
240
|
+
if (field.isTitle) update.title = field.answer;
|
|
241
|
+
this.setState(update);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
onDateSelected = (date) => {
|
|
245
|
+
const { customFields, dateFieldId, popUpType } = this.state;
|
|
246
|
+
const update = {
|
|
247
|
+
customFields: _.cloneDeep(customFields),
|
|
248
|
+
isDateTimePickerVisible: false,
|
|
249
|
+
fieldId: null,
|
|
250
|
+
};
|
|
251
|
+
const field = update.customFields[dateFieldId];
|
|
252
|
+
const dateObj = moment(date);
|
|
253
|
+
if (popUpType === "date") {
|
|
254
|
+
field.answer = dateObj.format("YYYY-MM-DD");
|
|
255
|
+
if (field.isTitle) update.title = dateObj.format("DD MMM YYYY");
|
|
256
|
+
} else {
|
|
257
|
+
field.answer = dateObj.format("HH:mm");
|
|
258
|
+
if (field.isTitle) update.title = dateObj.format("h:mm a");
|
|
259
|
+
}
|
|
260
|
+
this.setState(update);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
onUploadStartedImage = (uploadUri, imageUri) => {
|
|
264
|
+
const { imageFieldId } = this.state;
|
|
265
|
+
const imagesUpdate = this.getImages(imageFieldId);
|
|
266
|
+
imagesUpdate.splice(imagesUpdate.length - 1, 0, {
|
|
267
|
+
uploading: true,
|
|
268
|
+
uploadProgress: "0%",
|
|
269
|
+
uploadUri,
|
|
270
|
+
imageUri,
|
|
271
|
+
allowRetry: true,
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
this.setImages(imagesUpdate, imageFieldId);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
onUploadProgressImage = (progress) => {
|
|
278
|
+
const { imageFieldId } = this.state;
|
|
279
|
+
const imagesUpdate = this.getImages(imageFieldId);
|
|
280
|
+
imagesUpdate.map((img) => {
|
|
281
|
+
if (img.uploadUri === progress.uri) {
|
|
282
|
+
img.uploadProgress = progress.percentage;
|
|
283
|
+
img.uploading = true;
|
|
284
|
+
img.allowRetry = true;
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
this.setImages(imagesUpdate, imageFieldId);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
onUploadSuccessImage = async (uri, uploadUri) => {
|
|
292
|
+
const { imageFieldId } = this.state;
|
|
293
|
+
const imagesUpdate = this.getImages(imageFieldId);
|
|
294
|
+
imagesUpdate.map((img) => {
|
|
295
|
+
if (img.uploadUri === uploadUri && img.uploading) {
|
|
296
|
+
img.url = uri.replace("/general/", "/general1400/");
|
|
297
|
+
img.thumbNailExists = false;
|
|
298
|
+
img.thumbNailUrl = Helper.getThumb300(img.url);
|
|
299
|
+
img.allowRetry = true;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
this.setImages(imagesUpdate, imageFieldId, () => this.waitForThumbnails());
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
onUploadFailedImage = (uploadUri) => {
|
|
307
|
+
const { imageFieldId } = this.state;
|
|
308
|
+
const imagesUpdate = this.getImages(imageFieldId);
|
|
309
|
+
imagesUpdate.map((img) => {
|
|
310
|
+
if (img.uploadUri === uploadUri) {
|
|
311
|
+
img.uploading = true; // Requried for retry
|
|
312
|
+
img.uploadProgress = "";
|
|
313
|
+
img.allowRetry = true;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
this.setImages(imagesUpdate, imageFieldId);
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
onLibrarySelected = (uri) => {
|
|
321
|
+
const { imageFieldId } = this.state;
|
|
322
|
+
const imagesUpdate = this.getImages(imageFieldId);
|
|
323
|
+
imagesUpdate.splice(imagesUpdate.length - 1, 0, {
|
|
324
|
+
uploading: false,
|
|
325
|
+
allowRetry: false,
|
|
326
|
+
url: Helper.get1400(uri),
|
|
327
|
+
thumbNailExists: true,
|
|
328
|
+
thumbNailUrl: Helper.getThumb300(uri),
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
this.setImages(imagesUpdate, imageFieldId);
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
onUploadStartedDocument = (
|
|
335
|
+
uploadUri,
|
|
336
|
+
documentUri,
|
|
337
|
+
documentName,
|
|
338
|
+
documentExt,
|
|
339
|
+
documentFieldId,
|
|
340
|
+
) => {
|
|
341
|
+
const documentsUpdate = this.getDocuments(documentFieldId);
|
|
342
|
+
documentsUpdate.splice(documentsUpdate.length - 1, 0, {
|
|
343
|
+
uploading: true,
|
|
344
|
+
uploadProgress: "0%",
|
|
345
|
+
uploadUri,
|
|
346
|
+
documentUri,
|
|
347
|
+
documentName,
|
|
348
|
+
documentExt,
|
|
349
|
+
allowRetry: true,
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
this.setDocuments(documentsUpdate, documentFieldId);
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
onUploadProgressDocument = (progress, documentFieldId) => {
|
|
356
|
+
const documentsUpdate = this.getDocuments(documentFieldId);
|
|
357
|
+
documentsUpdate.map((doc) => {
|
|
358
|
+
if (doc.uploadUri === progress.uri) {
|
|
359
|
+
doc.uploadProgress = progress.percentage;
|
|
360
|
+
doc.uploading = true;
|
|
361
|
+
doc.allowRetry = true;
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
this.setDocuments(documentsUpdate, documentFieldId);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
onUploadSuccessDocument = async (uri, uploadUri, documentFieldId) => {
|
|
369
|
+
const documentsUpdate = this.getDocuments(documentFieldId);
|
|
370
|
+
documentsUpdate.map((doc) => {
|
|
371
|
+
if (doc.uploadUri === uploadUri && doc.uploading) {
|
|
372
|
+
doc.uploading = false;
|
|
373
|
+
doc.uploadProgress = "100%";
|
|
374
|
+
doc.url = uri;
|
|
375
|
+
doc.allowRetry = true;
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
this.setDocuments(documentsUpdate, documentFieldId);
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
onUploadFailedDocument = (uploadUri, documentFieldId) => {
|
|
383
|
+
const documentsUpdate = this.getDocuments(documentFieldId);
|
|
384
|
+
documentsUpdate.map((doc) => {
|
|
385
|
+
if (doc.uploadUri === uploadUri) {
|
|
386
|
+
doc.uploading = true; // Requried for retry
|
|
387
|
+
doc.uploadProgress = "";
|
|
388
|
+
doc.allowRetry = true;
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
this.setDocuments(documentsUpdate, documentFieldId);
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
onPressBack() {
|
|
396
|
+
Services.navigation.goBack();
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
onPressType() {
|
|
400
|
+
Services.navigation.navigate(values.screenJobTypePicker, {
|
|
401
|
+
currentType: this.state.type,
|
|
402
|
+
types: this.state.types,
|
|
403
|
+
onSelectType: this.pickType.bind(this),
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
onCloseConfirmationPopup() {
|
|
408
|
+
this.setState({
|
|
409
|
+
confirmationToShow: false,
|
|
410
|
+
});
|
|
411
|
+
Services.navigation.goBack();
|
|
412
|
+
this.props.onBack && this.props.onBack();
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
onConfirmationReset() {
|
|
416
|
+
this.setState(
|
|
417
|
+
{
|
|
418
|
+
confirmationToShow: false,
|
|
419
|
+
title: "",
|
|
420
|
+
description: "",
|
|
421
|
+
times: "",
|
|
422
|
+
isHome: false,
|
|
423
|
+
uploadingImage: false,
|
|
424
|
+
images: [
|
|
425
|
+
{
|
|
426
|
+
add: true,
|
|
427
|
+
},
|
|
428
|
+
],
|
|
429
|
+
submitting: false,
|
|
430
|
+
success: false,
|
|
431
|
+
fail: false,
|
|
432
|
+
customFields: [],
|
|
433
|
+
customFieldImages: {},
|
|
434
|
+
customFieldDocuments: {},
|
|
435
|
+
isDateTimePickerVisible: false,
|
|
436
|
+
popUpType: "date",
|
|
437
|
+
dateFieldId: null,
|
|
438
|
+
imageFieldId: null,
|
|
439
|
+
},
|
|
440
|
+
() => this.pickType(this.state.type),
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
isFieldValid = (field, fieldId) => {
|
|
445
|
+
const { mandatory, type, answer } = field;
|
|
446
|
+
if (["staticTitle", "staticText"].includes(type)) return true;
|
|
447
|
+
|
|
448
|
+
const checkMandatory = () => {
|
|
449
|
+
if (!mandatory) return true;
|
|
450
|
+
switch (type) {
|
|
451
|
+
case "yn":
|
|
452
|
+
return _.isBoolean(answer);
|
|
453
|
+
case "image":
|
|
454
|
+
const imagesList = this.getImageUrls(fieldId);
|
|
455
|
+
return imagesList.length > 0;
|
|
456
|
+
case "document":
|
|
457
|
+
const documentsList = this.getDocumentAnswers(fieldId);
|
|
458
|
+
return documentsList.length > 0;
|
|
459
|
+
case "checkbox":
|
|
460
|
+
return _.isArray(answer) && answer.length > 0;
|
|
461
|
+
default:
|
|
462
|
+
return !_.isNil(answer) && !_.isEmpty(answer);
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
const checkFormat = () => {
|
|
466
|
+
if (_.isNil(answer) || _.isEmpty(answer)) return true;
|
|
467
|
+
switch (type) {
|
|
468
|
+
case "email":
|
|
469
|
+
return Helper.isEmail(answer);
|
|
470
|
+
case "date":
|
|
471
|
+
return moment(answer, "YYYY-MM-DD", true).isValid();
|
|
472
|
+
case "time":
|
|
473
|
+
return moment(answer, "HH:mm", true).isValid();
|
|
474
|
+
default:
|
|
475
|
+
return true;
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
const valid = checkMandatory() && checkFormat();
|
|
480
|
+
return valid;
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
getJobTypes() {
|
|
484
|
+
maintenanceActions
|
|
485
|
+
.getJobTypes(Helper.getSite(this.props.site))
|
|
486
|
+
.then((res) => {
|
|
487
|
+
this.setState({
|
|
488
|
+
types: res.data,
|
|
489
|
+
});
|
|
490
|
+
this.getDefaultJob();
|
|
491
|
+
})
|
|
492
|
+
.catch(() => {});
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
pickType(type) {
|
|
496
|
+
const { types } = this.state;
|
|
497
|
+
const selected = types.find((t) => t.typeName === type) || {};
|
|
498
|
+
if (values.forceCustomFields && !selected.hasCustomFields) {
|
|
499
|
+
this.setState({
|
|
500
|
+
type,
|
|
501
|
+
customFields: [],
|
|
502
|
+
noType: true,
|
|
503
|
+
});
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
const update = {
|
|
507
|
+
type,
|
|
508
|
+
customFields:
|
|
509
|
+
selected.hasCustomFields && selected.customFields.length > 0
|
|
510
|
+
? _.cloneDeep(selected.customFields)
|
|
511
|
+
: [],
|
|
512
|
+
loadingTypes: false,
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
if (
|
|
516
|
+
!_.isEmpty(update.customFields) &&
|
|
517
|
+
!_.some(update.customFields, "isTitle")
|
|
518
|
+
) {
|
|
519
|
+
update.title = this.state.userName;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
this.setState(update);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
getDefaultJob() {
|
|
526
|
+
const { types, jobId } = this.state;
|
|
527
|
+
if (types.length !== 0 && jobId == null) {
|
|
528
|
+
const defaultType = types[0];
|
|
529
|
+
this.pickType(defaultType.typeName);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
showUploadMenu = (fieldId) => {
|
|
534
|
+
Keyboard.dismiss();
|
|
535
|
+
if (this.state.uploadingImage || this.state.submitting) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (fieldId) this.setState({ imageFieldId: fieldId });
|
|
539
|
+
this.imageUploader.showUploadMenu();
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
submit = async () => {
|
|
543
|
+
this.setState({ submitting: true });
|
|
544
|
+
|
|
545
|
+
let description = this.state.description;
|
|
546
|
+
|
|
547
|
+
if (this.state.isHome) {
|
|
548
|
+
description = description + `. -- Times Available: ${this.state.times}`;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
setTimeout(() => {
|
|
552
|
+
this.scrollContainer.scrollTo({ y: 0 });
|
|
553
|
+
}, 100);
|
|
554
|
+
|
|
555
|
+
const images = this.getImageUrls();
|
|
556
|
+
|
|
557
|
+
// Fix custom images field answers
|
|
558
|
+
const customFields = _.cloneDeep(this.state.customFields);
|
|
559
|
+
const updatedCustomFields = customFields.map((field, fieldId) => {
|
|
560
|
+
if (field.type === "image") field.answer = this.getImageUrls(fieldId);
|
|
561
|
+
if (field.type === "document")
|
|
562
|
+
field.answer = this.getDocumentAnswers(fieldId);
|
|
563
|
+
return field;
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
maintenanceActions
|
|
567
|
+
.sendMaintenanceRequest(
|
|
568
|
+
this.props.uid,
|
|
569
|
+
this.state.userName,
|
|
570
|
+
this.state.phone,
|
|
571
|
+
this.state.roomNumber,
|
|
572
|
+
this.state.title,
|
|
573
|
+
description,
|
|
574
|
+
null,
|
|
575
|
+
this.state.type,
|
|
576
|
+
images,
|
|
577
|
+
Helper.getSite(this.props.site),
|
|
578
|
+
this.state.isHome,
|
|
579
|
+
this.state.times,
|
|
580
|
+
updatedCustomFields,
|
|
581
|
+
)
|
|
582
|
+
.then((res) => {
|
|
583
|
+
if (res.data.success) {
|
|
584
|
+
this.refreshRequest(res.data.searchResult);
|
|
585
|
+
if (this.props.onSubmissionSuccess)
|
|
586
|
+
this.props.onSubmissionSuccess(res.data);
|
|
587
|
+
this.setState({
|
|
588
|
+
submitting: false,
|
|
589
|
+
success: true,
|
|
590
|
+
confirmationToShow: true,
|
|
591
|
+
});
|
|
592
|
+
} else {
|
|
593
|
+
this.setState({
|
|
594
|
+
submitting: false,
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
})
|
|
598
|
+
.catch((err) => {
|
|
599
|
+
console.log("maintenance submission fail.");
|
|
600
|
+
console.log(err);
|
|
601
|
+
this.setState({
|
|
602
|
+
submitting: false,
|
|
603
|
+
});
|
|
604
|
+
});
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
refreshRequest = async (id) => {
|
|
608
|
+
try {
|
|
609
|
+
const job = await maintenanceActions.getJob(
|
|
610
|
+
Helper.getSite(this.props.site),
|
|
611
|
+
id,
|
|
612
|
+
);
|
|
613
|
+
this.props.jobAdded(job.data);
|
|
614
|
+
} catch (error) {
|
|
615
|
+
console.log("refreshRequest error", error);
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
validateCustomFields = () => {
|
|
620
|
+
const { customFields } = this.state;
|
|
621
|
+
if (!customFields || customFields.length === 0) return true;
|
|
622
|
+
|
|
623
|
+
return customFields.every((field, index) => {
|
|
624
|
+
const isValid = this.isFieldValid(field, index);
|
|
625
|
+
return isValid;
|
|
626
|
+
});
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
submitRequest() {
|
|
630
|
+
const {
|
|
631
|
+
customFields,
|
|
632
|
+
submitting,
|
|
633
|
+
uploadingImage,
|
|
634
|
+
title,
|
|
635
|
+
roomNumber,
|
|
636
|
+
isHome,
|
|
637
|
+
times,
|
|
638
|
+
} = this.state;
|
|
639
|
+
const hasCustomFields = customFields && customFields.length > 0;
|
|
640
|
+
|
|
641
|
+
if (submitting || !this.props.connected) {
|
|
642
|
+
if (!this.props.connected) {
|
|
643
|
+
this.setState({
|
|
644
|
+
error: { message: "No internet connection detected" },
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
if (uploadingImage) return;
|
|
650
|
+
|
|
651
|
+
this.setState({ error: null, showError: false });
|
|
652
|
+
|
|
653
|
+
// PC-1255: Validate user selection for on-behalf requests
|
|
654
|
+
if (this.state.canCreateOnBehalf && !this.state.selectedUser) {
|
|
655
|
+
console.log("submitRequest - no user selected for on-behalf request");
|
|
656
|
+
this.setState({ showError: true });
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
if (title.length === 0 || !roomNumber || roomNumber.length === 0) {
|
|
661
|
+
console.log("submitRequest - error", { title, roomNumber });
|
|
662
|
+
this.setState({ showError: true });
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
if (hasCustomFields) {
|
|
666
|
+
if (!this.validateCustomFields()) {
|
|
667
|
+
console.log("submitRequest - custom fields error");
|
|
668
|
+
this.setState({ showError: true });
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
} else {
|
|
672
|
+
if (isHome && times.length < 2) {
|
|
673
|
+
console.log("submitRequest - error", { isHome, times });
|
|
674
|
+
this.setState({ showError: true });
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
this.submit();
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
getImages = (fieldId = null) => {
|
|
682
|
+
const { images, customFieldImages } = this.state;
|
|
683
|
+
const imagesList = _.cloneDeep(
|
|
684
|
+
fieldId ? customFieldImages[fieldId] : images,
|
|
685
|
+
);
|
|
686
|
+
if (!imagesList || !Array.isArray(imagesList) || imagesList.length === 0) {
|
|
687
|
+
return [{ add: true }];
|
|
688
|
+
}
|
|
689
|
+
return imagesList;
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
setImages = (imagesList, fieldId = null, callback = null) => {
|
|
693
|
+
let update = {};
|
|
694
|
+
if (fieldId) {
|
|
695
|
+
const customFieldImages = _.cloneDeep(this.state.customFieldImages);
|
|
696
|
+
customFieldImages[fieldId] = imagesList;
|
|
697
|
+
update = { customFieldImages };
|
|
698
|
+
} else {
|
|
699
|
+
update = { images: imagesList };
|
|
700
|
+
}
|
|
701
|
+
this.setState(update, callback);
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
getImageUrls = (fieldId = null) => {
|
|
705
|
+
const imagesList = this.getImages(fieldId);
|
|
706
|
+
return _.filter(imagesList, (img) => {
|
|
707
|
+
return !img.uploading && !img.add;
|
|
708
|
+
}).map((img) => {
|
|
709
|
+
return img.url;
|
|
710
|
+
});
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
waitForThumbnails = () => {
|
|
714
|
+
if (this.checkThumb) return;
|
|
715
|
+
|
|
716
|
+
this.checkThumb = setInterval(async () => {
|
|
717
|
+
const { imageFieldId } = this.state;
|
|
718
|
+
const imagesList = this.getImages(imageFieldId);
|
|
719
|
+
const imagesUpdate = [];
|
|
720
|
+
await Promise.all(
|
|
721
|
+
imagesList.map((image) => {
|
|
722
|
+
return new Promise(async (resolve) => {
|
|
723
|
+
const newImage = { ...image };
|
|
724
|
+
imagesUpdate.push(newImage);
|
|
725
|
+
if (newImage.url && !newImage.thumbNailExists) {
|
|
726
|
+
newImage.uploading = false;
|
|
727
|
+
newImage.allowRetry = false;
|
|
728
|
+
newImage.thumbNailExists = await Helper.imageExists(
|
|
729
|
+
newImage.thumbNailUrl,
|
|
730
|
+
);
|
|
731
|
+
resolve(newImage.thumbNailExists);
|
|
732
|
+
}
|
|
733
|
+
resolve(true);
|
|
734
|
+
});
|
|
735
|
+
}),
|
|
736
|
+
);
|
|
737
|
+
const thumbnailsExist = imagesUpdate.every(
|
|
738
|
+
(image) => !image.url || image.thumbNailExists,
|
|
739
|
+
);
|
|
740
|
+
if (thumbnailsExist) {
|
|
741
|
+
clearInterval(this.checkThumb);
|
|
742
|
+
this.checkThumb = null;
|
|
743
|
+
this.setImages(imagesUpdate, imageFieldId);
|
|
744
|
+
}
|
|
745
|
+
}, 2000);
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
removeImage = (index, fieldId) => {
|
|
749
|
+
const imagesUpdate = this.getImages(fieldId);
|
|
750
|
+
imagesUpdate.splice(index, 1);
|
|
751
|
+
|
|
752
|
+
this.setImages(imagesUpdate, fieldId);
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
getDocuments = (fieldId) => {
|
|
756
|
+
const { customFieldDocuments } = this.state;
|
|
757
|
+
const documentsList = _.cloneDeep(customFieldDocuments[fieldId]) || [];
|
|
758
|
+
return documentsList;
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
setDocuments = (documentsList, fieldId) => {
|
|
762
|
+
let update = {};
|
|
763
|
+
const customFieldDocuments = _.cloneDeep(this.state.customFieldDocuments);
|
|
764
|
+
customFieldDocuments[fieldId] = documentsList;
|
|
765
|
+
update = { customFieldDocuments };
|
|
766
|
+
this.setState(update);
|
|
767
|
+
};
|
|
768
|
+
|
|
769
|
+
getDocumentAnswers = (fieldId) => {
|
|
770
|
+
const documentsList = this.getDocuments(fieldId);
|
|
771
|
+
return _.filter(documentsList, (doc) => {
|
|
772
|
+
return !doc.uploading && doc.url;
|
|
773
|
+
}).map((doc) => {
|
|
774
|
+
return {
|
|
775
|
+
name: doc.documentName,
|
|
776
|
+
ext: doc.documentExt,
|
|
777
|
+
url: doc.url,
|
|
778
|
+
};
|
|
779
|
+
});
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
removeDocument = (index, fieldId) => {
|
|
783
|
+
const documentsUpdate = this.getDocuments(fieldId);
|
|
784
|
+
documentsUpdate.splice(index, 1);
|
|
785
|
+
|
|
786
|
+
this.setDocuments(documentsUpdate, fieldId);
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
toggleFullscreenVideo = (url) => {
|
|
790
|
+
if (typeof url !== "string") url = "";
|
|
791
|
+
this.setState({
|
|
792
|
+
showFullscreenVideo: url.length > 0,
|
|
793
|
+
currentVideoUrl: url,
|
|
794
|
+
});
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
renderImageUploader() {
|
|
798
|
+
return (
|
|
799
|
+
<Components.ImageUploader
|
|
800
|
+
ref={(ref) => (this.imageUploader = ref)}
|
|
801
|
+
onUploadStarted={this.onUploadStartedImage}
|
|
802
|
+
onUploadSuccess={this.onUploadSuccessImage}
|
|
803
|
+
onUploadFailed={this.onUploadFailedImage}
|
|
804
|
+
onUploadProgress={this.onUploadProgressImage}
|
|
805
|
+
onLibrarySelected={this.onLibrarySelectedImage}
|
|
806
|
+
size={{ width: 1400 }}
|
|
807
|
+
quality={0.8}
|
|
808
|
+
fileName={"serviceImage"}
|
|
809
|
+
popupTitle={"Upload Image"}
|
|
810
|
+
userId={this.props.uid}
|
|
811
|
+
allowsEditing={false}
|
|
812
|
+
multiple
|
|
813
|
+
hideLibrary
|
|
814
|
+
/>
|
|
815
|
+
);
|
|
188
816
|
}
|
|
189
817
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
renderField(field, fieldId) {
|
|
924
|
-
const sectionStyle = { marginTop: fieldId === 0 ? 24 : 0, marginBottom: 24 };
|
|
925
|
-
switch (field.type) {
|
|
926
|
-
case 'yn':
|
|
927
|
-
return (
|
|
928
|
-
<Components.GenericInputSection
|
|
929
|
-
key={fieldId}
|
|
930
|
-
label={field.label}
|
|
931
|
-
sectionStyle={sectionStyle}
|
|
932
|
-
inputType="toggle"
|
|
933
|
-
value={field.answer}
|
|
934
|
-
onChange={answer => this.onChangeToggleAnswer(fieldId, answer)}
|
|
935
|
-
isValid={() => this.isFieldValid(field, fieldId)}
|
|
936
|
-
showError={this.state.showError}
|
|
937
|
-
required={field.mandatory}
|
|
938
|
-
/>
|
|
939
|
-
);
|
|
940
|
-
case 'multichoice':
|
|
941
|
-
return (
|
|
942
|
-
<Components.GenericInputSection
|
|
943
|
-
key={fieldId}
|
|
944
|
-
label={field.label}
|
|
945
|
-
sectionStyle={sectionStyle}
|
|
946
|
-
inputType="radio"
|
|
947
|
-
value={field.answer}
|
|
948
|
-
onChange={answer => this.onChangeToggleAnswer(fieldId, answer)}
|
|
949
|
-
options={field.values.map(o => {
|
|
950
|
-
return {
|
|
951
|
-
Label: o,
|
|
952
|
-
Value: o,
|
|
953
|
-
};
|
|
954
|
-
})}
|
|
955
|
-
isValid={() => this.isFieldValid(field, fieldId)}
|
|
956
|
-
showError={this.state.showError}
|
|
957
|
-
required={field.mandatory}
|
|
958
|
-
/>
|
|
959
|
-
);
|
|
960
|
-
case 'checkbox':
|
|
961
|
-
return (
|
|
962
|
-
<Components.GenericInputSection
|
|
963
|
-
key={fieldId}
|
|
964
|
-
label={field.label}
|
|
965
|
-
sectionStyle={sectionStyle}
|
|
966
|
-
isValid={() => this.isFieldValid(field, fieldId)}
|
|
967
|
-
showError={this.state.showError}
|
|
968
|
-
required={field.mandatory}
|
|
969
|
-
>
|
|
970
|
-
{field.values.map((o, i) => {
|
|
971
|
-
const isActive = field.answer && _.includes(field.answer, o);
|
|
972
|
-
return (
|
|
973
|
-
<TouchableOpacity
|
|
974
|
-
onPress={() => this.onChangeCheckboxAnswer(fieldId, o)}
|
|
975
|
-
key={i}
|
|
976
|
-
style={styles.multiChoiceOption}
|
|
977
|
-
hitSlop={{ top: 8, left: 8, bottom: 8, right: 8 }}
|
|
978
|
-
>
|
|
979
|
-
{isActive ? (
|
|
980
|
-
<Components.TickIcon style={styles.tick} size={20} color={this.props.colourBrandingMain} />
|
|
981
|
-
) : (
|
|
982
|
-
<View style={styles.unticked} />
|
|
983
|
-
)}
|
|
984
|
-
<Text style={styles.multiChoiceText}>{o}</Text>
|
|
985
|
-
</TouchableOpacity>
|
|
986
|
-
);
|
|
987
|
-
})}
|
|
988
|
-
</Components.GenericInputSection>
|
|
989
|
-
);
|
|
990
|
-
case 'text':
|
|
991
|
-
case 'email':
|
|
992
|
-
case 'phone':
|
|
993
|
-
return (
|
|
994
|
-
<Components.GenericInputSection
|
|
995
|
-
key={fieldId}
|
|
996
|
-
label={field.label}
|
|
997
|
-
placeholder={field.placeHolder}
|
|
998
|
-
value={field.answer}
|
|
999
|
-
onChangeText={val => this.onChangeAnswer(fieldId, val)}
|
|
1000
|
-
editable
|
|
1001
|
-
squaredCorners
|
|
1002
|
-
isValid={() => this.isFieldValid(field, fieldId)}
|
|
1003
|
-
showError={this.state.showError}
|
|
1004
|
-
errorText={field.type === 'email' ? 'Not a valid email' : undefined}
|
|
1005
|
-
required={field.mandatory}
|
|
1006
|
-
sectionStyle={sectionStyle}
|
|
1007
|
-
autoCapitalize="sentences"
|
|
1008
|
-
keyboardType={this.keyboardTypes[field.type]}
|
|
1009
|
-
/>
|
|
1010
|
-
);
|
|
1011
|
-
case 'staticTitle':
|
|
1012
|
-
return (
|
|
1013
|
-
<Text key={fieldId} style={[styles.staticTitle, { color: this.props.colourBrandingMain }, sectionStyle]}>
|
|
1014
|
-
{field.label}
|
|
1015
|
-
</Text>
|
|
1016
|
-
);
|
|
1017
|
-
case 'staticText':
|
|
1018
|
-
return (
|
|
1019
|
-
<View key={fieldId} style={[styles.staticText, sectionStyle]}>
|
|
1020
|
-
{Helper.toParagraphed(field.label, styles.staticText)}
|
|
1021
|
-
</View>
|
|
1022
|
-
);
|
|
1023
|
-
case 'date':
|
|
1024
|
-
case 'time':
|
|
1025
|
-
return this.renderDateField(field, fieldId, sectionStyle);
|
|
1026
|
-
case 'image':
|
|
1027
|
-
return (
|
|
1028
|
-
<Components.GenericInputSection
|
|
1029
|
-
key={fieldId}
|
|
1030
|
-
label={field.label}
|
|
1031
|
-
sectionStyle={sectionStyle}
|
|
1032
|
-
isValid={() => this.isFieldValid(field, fieldId)}
|
|
1033
|
-
required={field.mandatory}
|
|
1034
|
-
showError={this.state.showError}
|
|
1035
|
-
>
|
|
1036
|
-
{this.renderImageList(fieldId)}
|
|
1037
|
-
</Components.GenericInputSection>
|
|
1038
|
-
);
|
|
1039
|
-
case 'document':
|
|
1040
|
-
return (
|
|
1041
|
-
<Components.GenericInputSection
|
|
1042
|
-
key={fieldId}
|
|
1043
|
-
label={field.label}
|
|
1044
|
-
sectionStyle={sectionStyle}
|
|
1045
|
-
isValid={() => this.isFieldValid(field, fieldId)}
|
|
1046
|
-
required={field.mandatory}
|
|
1047
|
-
showError={this.state.showError}
|
|
1048
|
-
>
|
|
1049
|
-
{this.renderDocumentList(fieldId)}
|
|
1050
|
-
</Components.GenericInputSection>
|
|
1051
|
-
);
|
|
1052
|
-
default:
|
|
1053
|
-
return null;
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
renderCustomFields() {
|
|
1058
|
-
const { customFields } = this.state;
|
|
1059
|
-
if (!customFields || customFields.length === 0) return null;
|
|
1060
|
-
|
|
1061
|
-
return (
|
|
1062
|
-
<Components.FormCard style={{ marginTop: 16 }}>{customFields.map((field, i) => this.renderField(field, i))}</Components.FormCard>
|
|
1063
|
-
);
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
renderForm() {
|
|
1067
|
-
const { customFields, loadingTypes } = this.state;
|
|
1068
|
-
const hasCustomFields = customFields && customFields.length > 0;
|
|
1069
|
-
|
|
1070
|
-
if (loadingTypes) {
|
|
1071
|
-
return <Components.Spinner />;
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
return (
|
|
1075
|
-
<View style={{ flex: 1 }}>
|
|
1076
|
-
<ScrollView keyboardShouldPersistTaps="always" style={{ flex: 1 }} ref={ref => (this.scrollContainer = ref)}>
|
|
1077
|
-
<View style={{ paddingBottom: 2 }}>
|
|
1078
|
-
<Components.LoadingIndicator visible={this.state.submitting} />
|
|
1079
|
-
{this.state.error && <Text style={styles.errorText}>{this.state.error}</Text>}
|
|
1080
|
-
<Components.FormCard style={{ marginTop: 16 }}>
|
|
1081
|
-
{/* PC-1255: User picker for on-behalf requests */}
|
|
1082
|
-
{this.state.canCreateOnBehalf && (
|
|
1083
|
-
<Components.FormCardSection
|
|
1084
|
-
label={'Select User'}
|
|
1085
|
-
textValue={this.state.selectedUser?.displayName}
|
|
1086
|
-
hasContent
|
|
1087
|
-
hasUnderline
|
|
1088
|
-
required
|
|
1089
|
-
errorText="Please select a user."
|
|
1090
|
-
showError={this.state.showError && !this.state.selectedUser}
|
|
1091
|
-
sectionStyle={{ borderBottomWidth: 1, borderBottomColor: Colours.LINEGREY }}
|
|
1092
|
-
>
|
|
1093
|
-
<TouchableOpacity onPress={this.onPressUser}>
|
|
1094
|
-
<View style={styles.userPickerContainer}>
|
|
1095
|
-
<View style={styles.profileContainer}>
|
|
1096
|
-
<Components.ProfilePic ProfilePic={this.state.selectedUser?.profilePic} Diameter={30} />
|
|
1097
|
-
<Text style={styles.nameText}>{this.state.selectedUser?.displayName || 'Select User'}</Text>
|
|
1098
|
-
</View>
|
|
1099
|
-
<Icon
|
|
1100
|
-
name="angle-right"
|
|
1101
|
-
type="font-awesome"
|
|
1102
|
-
iconStyle={[styles.sectionTitle, { fontSize: 20, color: this.props.colourBrandingMain }]}
|
|
1103
|
-
/>
|
|
1104
|
-
</View>
|
|
1105
|
-
</TouchableOpacity>
|
|
1106
|
-
</Components.FormCardSection>
|
|
1107
|
-
)}
|
|
1108
|
-
{/* PC-1255: Hide Name field when creating on behalf - name comes from selected user */}
|
|
1109
|
-
{!this.state.canCreateOnBehalf && (
|
|
1110
|
-
<Components.FormCardSection
|
|
1111
|
-
label={'Name'}
|
|
1112
|
-
placeholder={'Enter your name'}
|
|
1113
|
-
textValue={this.state.userName}
|
|
1114
|
-
onChangeText={userName => this.onChangeName(userName)}
|
|
1115
|
-
editable={this.props.userType === 'KIOSK' && this.state.submitting === false}
|
|
1116
|
-
isValid={() => {
|
|
1117
|
-
return this.state.userName.length > 1;
|
|
1118
|
-
}}
|
|
1119
|
-
required
|
|
1120
|
-
errorText="Please enter your name."
|
|
1121
|
-
showError={this.state.showError && this.state.userName.length < 2}
|
|
1122
|
-
hasUnderline
|
|
1123
|
-
/>
|
|
1124
|
-
)}
|
|
1125
|
-
<Components.FormCardSection
|
|
1126
|
-
label={'Contact number'}
|
|
1127
|
-
placeholder={'Enter phone number'}
|
|
1128
|
-
textValue={this.state.phone}
|
|
1129
|
-
onChangeText={phone => this.setState({ phone })}
|
|
1130
|
-
editable={this.state.submitting === false}
|
|
1131
|
-
hasUnderline
|
|
1132
|
-
keyboardType={'phone-pad'}
|
|
1133
|
-
/>
|
|
1134
|
-
<Components.FormCardSection
|
|
1135
|
-
label={'Address'}
|
|
1136
|
-
placeholder={'Enter your address'}
|
|
1137
|
-
textValue={this.state.roomNumber}
|
|
1138
|
-
onChangeText={roomNumber => this.setState({ roomNumber })}
|
|
1139
|
-
editable={this.state.submitting === false}
|
|
1140
|
-
hasUnderline
|
|
1141
|
-
isValid={() => {
|
|
1142
|
-
return this.state.roomNumber && this.state.roomNumber.length > 1;
|
|
1143
|
-
}}
|
|
1144
|
-
required
|
|
1145
|
-
errorText="Please provide your address."
|
|
1146
|
-
showError={this.state.showError && (!this.state.roomNumber || this.state.roomNumber.length < 2)}
|
|
1147
|
-
/>
|
|
1148
|
-
</Components.FormCard>
|
|
1149
|
-
<Components.FormCard
|
|
1150
|
-
style={{ marginTop: 16, paddingHorizontal: 24, paddingVertical: 16, flexDirection: 'row', justifyContent: 'space-between' }}
|
|
1151
|
-
>
|
|
1152
|
-
<Text style={styles.sectionTitle}>{values.textJobType}</Text>
|
|
1153
|
-
<TouchableOpacity onPress={this.onPressType.bind(this)}>
|
|
1154
|
-
<View style={{ flexDirection: 'row' }}>
|
|
1155
|
-
<Text style={[styles.sectionTitle, { color: this.props.colourBrandingMain, marginRight: 16 }]}>{this.state.type}</Text>
|
|
1156
|
-
<Icon
|
|
1157
|
-
name="angle-right"
|
|
1158
|
-
type="font-awesome"
|
|
1159
|
-
iconStyle={[styles.sectionTitle, { fontSize: 20, color: this.props.colourBrandingMain }]}
|
|
1160
|
-
/>
|
|
1161
|
-
</View>
|
|
1162
|
-
</TouchableOpacity>
|
|
1163
|
-
</Components.FormCard>
|
|
1164
|
-
{hasCustomFields ? (
|
|
1165
|
-
this.renderCustomFields()
|
|
1166
|
-
) : (
|
|
1167
|
-
<>
|
|
1168
|
-
<Components.FormCard style={{ marginTop: 16 }}>
|
|
1169
|
-
<Components.FormCardSection
|
|
1170
|
-
label={'Title'}
|
|
1171
|
-
placeholder={'Enter a title for your request'}
|
|
1172
|
-
textValue={this.state.title}
|
|
1173
|
-
onChangeText={title => this.setState({ title })}
|
|
1174
|
-
editable={this.state.submitting === false}
|
|
1175
|
-
hasUnderline
|
|
1176
|
-
isValid={() => {
|
|
1177
|
-
return this.state.title.length > 1;
|
|
1178
|
-
}}
|
|
1179
|
-
required
|
|
1180
|
-
errorText="Please provide a title."
|
|
1181
|
-
showError={this.state.showError && this.state.title.length < 2}
|
|
1182
|
-
autoCorrect
|
|
1183
|
-
multiline
|
|
1184
|
-
autoGrow
|
|
1185
|
-
/>
|
|
1186
|
-
<Components.FormCardSection
|
|
1187
|
-
label={'Description'}
|
|
1188
|
-
placeholder={'Describe your request here in detail'}
|
|
1189
|
-
textValue={this.state.description}
|
|
1190
|
-
onChangeText={description => this.setState({ description })}
|
|
1191
|
-
editable={this.state.submitting === false}
|
|
1192
|
-
hasUnderline
|
|
1193
|
-
autoCorrect
|
|
1194
|
-
multiline
|
|
1195
|
-
autoGrow
|
|
1196
|
-
/>
|
|
1197
|
-
</Components.FormCard>
|
|
1198
|
-
<Components.FormCard style={{ marginTop: 16, paddingHorizontal: 24 }}>
|
|
1199
|
-
<View
|
|
1200
|
-
style={[
|
|
1201
|
-
{
|
|
1202
|
-
width: '100%',
|
|
1203
|
-
paddingVertical: 16,
|
|
1204
|
-
flexDirection: 'row',
|
|
1205
|
-
justifyContent: 'space-between',
|
|
1206
|
-
alignItems: 'center',
|
|
1207
|
-
position: 'relative',
|
|
1208
|
-
},
|
|
1209
|
-
this.state.isHome && { borderBottomWidth: 1, borderBottomColor: Colours.LINEGREY },
|
|
1210
|
-
]}
|
|
1211
|
-
>
|
|
1212
|
-
<Text style={styles.sectionTitle}>{Config.env.strings.MAINTENANCE_HOME}</Text>
|
|
1213
|
-
<Switch
|
|
1214
|
-
value={this.state.isHome}
|
|
1215
|
-
disabled={this.state.submitting}
|
|
1216
|
-
onValueChange={value => this.setState({ isHome: value })}
|
|
1217
|
-
trackColor={{ false: '#ddd', true: this.props.colourBrandingMain }}
|
|
1218
|
-
thumbColor={Platform.OS === 'android' ? '#fff' : null}
|
|
1219
|
-
/>
|
|
1220
|
-
</View>
|
|
1221
|
-
{this.state.isHome && (
|
|
1222
|
-
<Components.FormCardSection
|
|
1223
|
-
label={'Available times'}
|
|
1224
|
-
placeholder={'Describe your available times here in detail.'}
|
|
1225
|
-
textValue={this.state.times}
|
|
1226
|
-
onChangeText={times => this.setState({ times })}
|
|
1227
|
-
editable={this.state.submitting === false}
|
|
1228
|
-
hasUnderline
|
|
1229
|
-
isValid={() => {
|
|
1230
|
-
return this.state.times.length > 1;
|
|
1231
|
-
}}
|
|
1232
|
-
required
|
|
1233
|
-
errorText="Please provide available times."
|
|
1234
|
-
showError={this.state.showError && this.state.isHome && this.state.times.length < 2}
|
|
1235
|
-
minHeight={40}
|
|
1236
|
-
autoCorrect
|
|
1237
|
-
multiline
|
|
1238
|
-
autoGrow
|
|
1239
|
-
/>
|
|
1240
|
-
)}
|
|
1241
|
-
</Components.FormCard>
|
|
1242
|
-
{this.renderImageList()}
|
|
1243
|
-
</>
|
|
1244
|
-
)}
|
|
1245
|
-
</View>
|
|
1246
|
-
</ScrollView>
|
|
1247
|
-
</View>
|
|
1248
|
-
);
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
renderRegisterConfirmation() {
|
|
1252
|
-
return (
|
|
1253
|
-
<Components.ConfirmationPopup
|
|
1254
|
-
confirmText={`${values.textEntityName} submitted`}
|
|
1255
|
-
repeatText={'Submit another'}
|
|
1256
|
-
visible={this.state.confirmationToShow}
|
|
1257
|
-
onClose={this.onCloseConfirmationPopup.bind(this)}
|
|
1258
|
-
onPressAction={this.onConfirmationReset.bind(this)}
|
|
1259
|
-
/>
|
|
1260
|
-
);
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
renderVideoPlayerPopup() {
|
|
1264
|
-
const { showFullscreenVideo, currentVideoUrl } = this.state;
|
|
1265
|
-
if (!currentVideoUrl) return;
|
|
1266
|
-
|
|
1267
|
-
return (
|
|
1268
|
-
<Components.VideoPopup
|
|
1269
|
-
uri={currentVideoUrl}
|
|
1270
|
-
visible={showFullscreenVideo}
|
|
1271
|
-
showFullscreenButton={false}
|
|
1272
|
-
onClose={this.toggleFullscreenVideo}
|
|
1273
|
-
/>
|
|
1274
|
-
);
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
renderNoType() {
|
|
1278
|
-
if (!this.state.noType) {
|
|
1279
|
-
return null;
|
|
1280
|
-
}
|
|
1281
|
-
return (
|
|
1282
|
-
<Components.WarningPopup
|
|
1283
|
-
confirmText={'No forms are available'}
|
|
1284
|
-
infoText={'Check back later for forms.'}
|
|
1285
|
-
visible={this.state.noType}
|
|
1286
|
-
onClose={this.onPressBack.bind(this)}
|
|
1287
|
-
padHorizontal
|
|
1288
|
-
/>
|
|
1289
|
-
);
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
render() {
|
|
1293
|
-
const { submitting, success, isDateTimePickerVisible, popUpType } = this.state;
|
|
1294
|
-
|
|
1295
|
-
return (
|
|
1296
|
-
<KeyboardAvoidingView behavior={Platform.OS === 'ios' && 'padding'} style={styles.viewContainer}>
|
|
1297
|
-
{this.renderImageUploader()}
|
|
1298
|
-
<View style={styles.container}>
|
|
1299
|
-
<Components.Header
|
|
1300
|
-
leftIcon="angle-left"
|
|
1301
|
-
onPressLeft={this.onPressBack.bind(this)}
|
|
1302
|
-
text={this.props.strings[`${values.featureKey}_textFeatureTitle`] || values.textFeatureTitle}
|
|
1303
|
-
rightText={submitting || success ? null : 'Done'}
|
|
1304
|
-
onPressRight={this.submitRequest.bind(this)}
|
|
1305
|
-
absoluteRight
|
|
1306
|
-
/>
|
|
1307
|
-
{this.renderForm()}
|
|
1308
|
-
</View>
|
|
1309
|
-
{this.renderRegisterConfirmation()}
|
|
1310
|
-
{this.renderVideoPlayerPopup()}
|
|
1311
|
-
{this.renderNoType()}
|
|
1312
|
-
<DateTimePicker
|
|
1313
|
-
isVisible={isDateTimePickerVisible}
|
|
1314
|
-
onConfirm={this.onDateSelected}
|
|
1315
|
-
onCancel={() => this.setState({ isDateTimePickerVisible: false })}
|
|
1316
|
-
mode={popUpType}
|
|
1317
|
-
headerTextIOS={`Pick a ${popUpType}`}
|
|
1318
|
-
/>
|
|
1319
|
-
</KeyboardAvoidingView>
|
|
1320
|
-
);
|
|
1321
|
-
}
|
|
818
|
+
renderImage(item, index, fieldId = null) {
|
|
819
|
+
const isVideoUrl = Helper.isVideo(item.url);
|
|
820
|
+
const imagesList = this.getImages(fieldId);
|
|
821
|
+
|
|
822
|
+
if (item.add) {
|
|
823
|
+
return (
|
|
824
|
+
<TouchableOpacity
|
|
825
|
+
activeOpacity={0.8}
|
|
826
|
+
onPress={() => this.showUploadMenu(fieldId)}
|
|
827
|
+
>
|
|
828
|
+
<View
|
|
829
|
+
style={[
|
|
830
|
+
styles.imageContainer,
|
|
831
|
+
imagesList.length > 1 && styles.imageContainerNotEmpty,
|
|
832
|
+
index % 3 === 0 && { marginLeft: 0 },
|
|
833
|
+
index > 2 && { marginTop: 8 },
|
|
834
|
+
]}
|
|
835
|
+
>
|
|
836
|
+
<View style={styles.imageCircle}>
|
|
837
|
+
<Icon
|
|
838
|
+
name="camera"
|
|
839
|
+
type="font-awesome"
|
|
840
|
+
iconStyle={styles.addImageIcon}
|
|
841
|
+
/>
|
|
842
|
+
</View>
|
|
843
|
+
</View>
|
|
844
|
+
</TouchableOpacity>
|
|
845
|
+
);
|
|
846
|
+
}
|
|
847
|
+
return (
|
|
848
|
+
<View
|
|
849
|
+
style={[
|
|
850
|
+
styles.imageContainer,
|
|
851
|
+
imagesList.length > 1 && styles.imageContainerNotEmpty,
|
|
852
|
+
index % 3 === 0 && { marginLeft: 0 },
|
|
853
|
+
index > 2 && { marginTop: 8 },
|
|
854
|
+
]}
|
|
855
|
+
>
|
|
856
|
+
{item.uploading ? (
|
|
857
|
+
<Components.ImageUploadProgress
|
|
858
|
+
uploader={this.imageUploader}
|
|
859
|
+
image={item}
|
|
860
|
+
color={this.props.colourBrandingMain}
|
|
861
|
+
/>
|
|
862
|
+
) : (
|
|
863
|
+
<ImageBackground
|
|
864
|
+
style={styles.imageBackground}
|
|
865
|
+
source={Helper.getImageSource(
|
|
866
|
+
item.thumbNailExists ? item.thumbNailUrl : item.url,
|
|
867
|
+
)}
|
|
868
|
+
>
|
|
869
|
+
{isVideoUrl && (
|
|
870
|
+
<View style={styles.imagePlayContainer}>
|
|
871
|
+
<TouchableOpacity
|
|
872
|
+
onPress={this.toggleFullscreenVideo.bind(this, item.url)}
|
|
873
|
+
>
|
|
874
|
+
<Icon
|
|
875
|
+
name="play"
|
|
876
|
+
type="font-awesome"
|
|
877
|
+
iconStyle={styles.imageControlIcon}
|
|
878
|
+
/>
|
|
879
|
+
</TouchableOpacity>
|
|
880
|
+
</View>
|
|
881
|
+
)}
|
|
882
|
+
<TouchableOpacity
|
|
883
|
+
style={styles.removeImage}
|
|
884
|
+
onPress={() => this.removeImage(index, fieldId)}
|
|
885
|
+
>
|
|
886
|
+
<Icon
|
|
887
|
+
name="remove"
|
|
888
|
+
type="font-awesome"
|
|
889
|
+
iconStyle={styles.imageControlIcon}
|
|
890
|
+
style={styles.removeImage}
|
|
891
|
+
/>
|
|
892
|
+
</TouchableOpacity>
|
|
893
|
+
</ImageBackground>
|
|
894
|
+
)}
|
|
895
|
+
</View>
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
renderDocument(item, index, fieldId) {
|
|
900
|
+
const { colourBrandingMain } = this.props;
|
|
901
|
+
return (
|
|
902
|
+
<View key={index} style={styles.documentContainer}>
|
|
903
|
+
<View
|
|
904
|
+
style={{
|
|
905
|
+
...styles.documentTypeContainer,
|
|
906
|
+
backgroundColor: colourBrandingMain,
|
|
907
|
+
}}
|
|
908
|
+
>
|
|
909
|
+
<Text style={styles.documentTypeText}>{item.documentExt}</Text>
|
|
910
|
+
</View>
|
|
911
|
+
<Text
|
|
912
|
+
style={styles.documentText}
|
|
913
|
+
>{`${item.documentName}${item.uploading ? ` - ${item.uploadProgress}` : ""}`}</Text>
|
|
914
|
+
{!item.uploading && (
|
|
915
|
+
<TouchableOpacity
|
|
916
|
+
style={styles.removeDocumentButton}
|
|
917
|
+
onPress={() => this.removeDocument(index, fieldId)}
|
|
918
|
+
>
|
|
919
|
+
<Icon
|
|
920
|
+
name="remove"
|
|
921
|
+
type="font-awesome"
|
|
922
|
+
iconStyle={{
|
|
923
|
+
...styles.removeDocumentIcon,
|
|
924
|
+
color: colourBrandingMain,
|
|
925
|
+
}}
|
|
926
|
+
/>
|
|
927
|
+
</TouchableOpacity>
|
|
928
|
+
)}
|
|
929
|
+
</View>
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
renderSuccess() {
|
|
934
|
+
return (
|
|
935
|
+
<View style={{ padding: 16, flex: 1, backgroundColor: "#fff" }}>
|
|
936
|
+
<Text style={styles.requestSuccess}>
|
|
937
|
+
Your request has been submitted. Thank you.
|
|
938
|
+
</Text>
|
|
939
|
+
</View>
|
|
940
|
+
);
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
renderImageList(fieldId = null) {
|
|
944
|
+
const imagesList = this.getImages(fieldId);
|
|
945
|
+
return (
|
|
946
|
+
<View
|
|
947
|
+
style={[
|
|
948
|
+
styles.imageListContainer,
|
|
949
|
+
imagesList.length < 2 && styles.imageListContainerEmpty,
|
|
950
|
+
]}
|
|
951
|
+
>
|
|
952
|
+
<FlatList
|
|
953
|
+
keyboardShouldPersistTaps="always"
|
|
954
|
+
enableEmptySections
|
|
955
|
+
data={imagesList}
|
|
956
|
+
renderItem={({ item, index }) =>
|
|
957
|
+
this.renderImage(item, index, fieldId)
|
|
958
|
+
}
|
|
959
|
+
keyExtractor={(item, index) => index}
|
|
960
|
+
numColumns={3}
|
|
961
|
+
/>
|
|
962
|
+
</View>
|
|
963
|
+
);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
renderDocumentList(fieldId) {
|
|
967
|
+
const documentsList = this.getDocuments(fieldId);
|
|
968
|
+
return (
|
|
969
|
+
<View style={styles.documentListContainer}>
|
|
970
|
+
{documentsList.length > 0
|
|
971
|
+
? documentsList.map((document, index) =>
|
|
972
|
+
this.renderDocument(document, index, fieldId),
|
|
973
|
+
)
|
|
974
|
+
: null}
|
|
975
|
+
<Components.DocumentUploader
|
|
976
|
+
buttonTitle="Add Files"
|
|
977
|
+
allowedTypes={["application/pdf"]}
|
|
978
|
+
onUploadStarted={(uploadUri, uri, name, ext) =>
|
|
979
|
+
this.onUploadStartedDocument(uploadUri, uri, name, ext, fieldId)
|
|
980
|
+
}
|
|
981
|
+
onUploadProgress={(progress) =>
|
|
982
|
+
this.onUploadProgressDocument(progress, fieldId)
|
|
983
|
+
}
|
|
984
|
+
onUploadSuccess={(uri, uploadUri) =>
|
|
985
|
+
this.onUploadSuccessDocument(uri, uploadUri, fieldId)
|
|
986
|
+
}
|
|
987
|
+
onUploadFailed={(uploadUri) =>
|
|
988
|
+
this.onUploadFailedDocument(uploadUri, fieldId)
|
|
989
|
+
}
|
|
990
|
+
fileName="serviceDocument"
|
|
991
|
+
userId={this.props.uid}
|
|
992
|
+
disabled={false}
|
|
993
|
+
multiple
|
|
994
|
+
/>
|
|
995
|
+
</View>
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
renderDateField(field, fieldId, sectionStyle) {
|
|
1000
|
+
let displayText, placeHolder, icon, errorText;
|
|
1001
|
+
if (field.type === "date") {
|
|
1002
|
+
displayText = field.answer
|
|
1003
|
+
? moment(field.answer, "YYYY-MM-DD").format("DD MMM YYYY")
|
|
1004
|
+
: "";
|
|
1005
|
+
placeHolder = "dd mmm yyyy";
|
|
1006
|
+
icon = "calendar";
|
|
1007
|
+
errorText = "Not a valid date";
|
|
1008
|
+
} else {
|
|
1009
|
+
displayText = field.answer
|
|
1010
|
+
? moment(field.answer, "HH:mm").format("h:mm a")
|
|
1011
|
+
: "";
|
|
1012
|
+
placeHolder = "--:-- --";
|
|
1013
|
+
icon = "clock-o";
|
|
1014
|
+
errorText = "Not a valid time";
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
return (
|
|
1018
|
+
<Components.GenericInputSection
|
|
1019
|
+
key={fieldId}
|
|
1020
|
+
label={field.label}
|
|
1021
|
+
sectionStyle={sectionStyle}
|
|
1022
|
+
isValid={() => this.isFieldValid(field, fieldId)}
|
|
1023
|
+
required={field.mandatory}
|
|
1024
|
+
showError={this.state.showError}
|
|
1025
|
+
errorText={errorText}
|
|
1026
|
+
>
|
|
1027
|
+
<View style={styles.dateContainer}>
|
|
1028
|
+
<TouchableOpacity
|
|
1029
|
+
style={styles.dateFieldButton}
|
|
1030
|
+
onPress={() => this.onOpenDatePicker(field, fieldId)}
|
|
1031
|
+
>
|
|
1032
|
+
<View style={styles.dateFieldContainer}>
|
|
1033
|
+
<Text style={styles.dateText}>{displayText || placeHolder}</Text>
|
|
1034
|
+
<Icon
|
|
1035
|
+
type="font-awesome"
|
|
1036
|
+
name={icon}
|
|
1037
|
+
iconStyle={styles.dateIcon}
|
|
1038
|
+
/>
|
|
1039
|
+
</View>
|
|
1040
|
+
</TouchableOpacity>
|
|
1041
|
+
{displayText ? (
|
|
1042
|
+
<TouchableOpacity
|
|
1043
|
+
style={styles.dateClearButton}
|
|
1044
|
+
onPress={() => this.onClearDate(fieldId)}
|
|
1045
|
+
>
|
|
1046
|
+
<Icon
|
|
1047
|
+
type="font-awesome"
|
|
1048
|
+
name="times"
|
|
1049
|
+
iconStyle={styles.removeIcon}
|
|
1050
|
+
/>
|
|
1051
|
+
</TouchableOpacity>
|
|
1052
|
+
) : null}
|
|
1053
|
+
</View>
|
|
1054
|
+
</Components.GenericInputSection>
|
|
1055
|
+
);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
renderField(field, fieldId) {
|
|
1059
|
+
const sectionStyle = {
|
|
1060
|
+
marginTop: fieldId === 0 ? 24 : 0,
|
|
1061
|
+
marginBottom: 24,
|
|
1062
|
+
};
|
|
1063
|
+
switch (field.type) {
|
|
1064
|
+
case "yn":
|
|
1065
|
+
return (
|
|
1066
|
+
<Components.GenericInputSection
|
|
1067
|
+
key={fieldId}
|
|
1068
|
+
label={field.label}
|
|
1069
|
+
sectionStyle={sectionStyle}
|
|
1070
|
+
inputType="toggle"
|
|
1071
|
+
value={field.answer}
|
|
1072
|
+
onChange={(answer) => this.onChangeToggleAnswer(fieldId, answer)}
|
|
1073
|
+
isValid={() => this.isFieldValid(field, fieldId)}
|
|
1074
|
+
showError={this.state.showError}
|
|
1075
|
+
required={field.mandatory}
|
|
1076
|
+
/>
|
|
1077
|
+
);
|
|
1078
|
+
case "multichoice":
|
|
1079
|
+
return (
|
|
1080
|
+
<Components.GenericInputSection
|
|
1081
|
+
key={fieldId}
|
|
1082
|
+
label={field.label}
|
|
1083
|
+
sectionStyle={sectionStyle}
|
|
1084
|
+
inputType="radio"
|
|
1085
|
+
value={field.answer}
|
|
1086
|
+
onChange={(answer) => this.onChangeToggleAnswer(fieldId, answer)}
|
|
1087
|
+
options={field.values.map((o) => {
|
|
1088
|
+
return {
|
|
1089
|
+
Label: o,
|
|
1090
|
+
Value: o,
|
|
1091
|
+
};
|
|
1092
|
+
})}
|
|
1093
|
+
isValid={() => this.isFieldValid(field, fieldId)}
|
|
1094
|
+
showError={this.state.showError}
|
|
1095
|
+
required={field.mandatory}
|
|
1096
|
+
/>
|
|
1097
|
+
);
|
|
1098
|
+
case "checkbox":
|
|
1099
|
+
return (
|
|
1100
|
+
<Components.GenericInputSection
|
|
1101
|
+
key={fieldId}
|
|
1102
|
+
label={field.label}
|
|
1103
|
+
sectionStyle={sectionStyle}
|
|
1104
|
+
isValid={() => this.isFieldValid(field, fieldId)}
|
|
1105
|
+
showError={this.state.showError}
|
|
1106
|
+
required={field.mandatory}
|
|
1107
|
+
>
|
|
1108
|
+
{field.values.map((o, i) => {
|
|
1109
|
+
const isActive = field.answer && _.includes(field.answer, o);
|
|
1110
|
+
return (
|
|
1111
|
+
<TouchableOpacity
|
|
1112
|
+
onPress={() => this.onChangeCheckboxAnswer(fieldId, o)}
|
|
1113
|
+
key={i}
|
|
1114
|
+
style={styles.multiChoiceOption}
|
|
1115
|
+
hitSlop={{ top: 8, left: 8, bottom: 8, right: 8 }}
|
|
1116
|
+
>
|
|
1117
|
+
{isActive ? (
|
|
1118
|
+
<Components.TickIcon
|
|
1119
|
+
style={styles.tick}
|
|
1120
|
+
size={20}
|
|
1121
|
+
color={this.props.colourBrandingMain}
|
|
1122
|
+
/>
|
|
1123
|
+
) : (
|
|
1124
|
+
<View style={styles.unticked} />
|
|
1125
|
+
)}
|
|
1126
|
+
<Text style={styles.multiChoiceText}>{o}</Text>
|
|
1127
|
+
</TouchableOpacity>
|
|
1128
|
+
);
|
|
1129
|
+
})}
|
|
1130
|
+
</Components.GenericInputSection>
|
|
1131
|
+
);
|
|
1132
|
+
case "text":
|
|
1133
|
+
case "email":
|
|
1134
|
+
case "phone":
|
|
1135
|
+
return (
|
|
1136
|
+
<Components.GenericInputSection
|
|
1137
|
+
key={fieldId}
|
|
1138
|
+
label={field.label}
|
|
1139
|
+
placeholder={field.placeHolder}
|
|
1140
|
+
value={field.answer}
|
|
1141
|
+
onChangeText={(val) => this.onChangeAnswer(fieldId, val)}
|
|
1142
|
+
editable
|
|
1143
|
+
squaredCorners
|
|
1144
|
+
isValid={() => this.isFieldValid(field, fieldId)}
|
|
1145
|
+
showError={this.state.showError}
|
|
1146
|
+
errorText={field.type === "email" ? "Not a valid email" : undefined}
|
|
1147
|
+
required={field.mandatory}
|
|
1148
|
+
sectionStyle={sectionStyle}
|
|
1149
|
+
autoCapitalize="sentences"
|
|
1150
|
+
keyboardType={this.keyboardTypes[field.type]}
|
|
1151
|
+
/>
|
|
1152
|
+
);
|
|
1153
|
+
case "staticTitle":
|
|
1154
|
+
return (
|
|
1155
|
+
<Text
|
|
1156
|
+
key={fieldId}
|
|
1157
|
+
style={[
|
|
1158
|
+
styles.staticTitle,
|
|
1159
|
+
{ color: this.props.colourBrandingMain },
|
|
1160
|
+
sectionStyle,
|
|
1161
|
+
]}
|
|
1162
|
+
>
|
|
1163
|
+
{field.label}
|
|
1164
|
+
</Text>
|
|
1165
|
+
);
|
|
1166
|
+
case "staticText":
|
|
1167
|
+
return (
|
|
1168
|
+
<View key={fieldId} style={[styles.staticText, sectionStyle]}>
|
|
1169
|
+
{Helper.toParagraphed(field.label, styles.staticText)}
|
|
1170
|
+
</View>
|
|
1171
|
+
);
|
|
1172
|
+
case "date":
|
|
1173
|
+
case "time":
|
|
1174
|
+
return this.renderDateField(field, fieldId, sectionStyle);
|
|
1175
|
+
case "image":
|
|
1176
|
+
return (
|
|
1177
|
+
<Components.GenericInputSection
|
|
1178
|
+
key={fieldId}
|
|
1179
|
+
label={field.label}
|
|
1180
|
+
sectionStyle={sectionStyle}
|
|
1181
|
+
isValid={() => this.isFieldValid(field, fieldId)}
|
|
1182
|
+
required={field.mandatory}
|
|
1183
|
+
showError={this.state.showError}
|
|
1184
|
+
>
|
|
1185
|
+
{this.renderImageList(fieldId)}
|
|
1186
|
+
</Components.GenericInputSection>
|
|
1187
|
+
);
|
|
1188
|
+
case "document":
|
|
1189
|
+
return (
|
|
1190
|
+
<Components.GenericInputSection
|
|
1191
|
+
key={fieldId}
|
|
1192
|
+
label={field.label}
|
|
1193
|
+
sectionStyle={sectionStyle}
|
|
1194
|
+
isValid={() => this.isFieldValid(field, fieldId)}
|
|
1195
|
+
required={field.mandatory}
|
|
1196
|
+
showError={this.state.showError}
|
|
1197
|
+
>
|
|
1198
|
+
{this.renderDocumentList(fieldId)}
|
|
1199
|
+
</Components.GenericInputSection>
|
|
1200
|
+
);
|
|
1201
|
+
default:
|
|
1202
|
+
return null;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
renderCustomFields() {
|
|
1207
|
+
const { customFields } = this.state;
|
|
1208
|
+
if (!customFields || customFields.length === 0) return null;
|
|
1209
|
+
|
|
1210
|
+
return (
|
|
1211
|
+
<Components.FormCard style={{ marginTop: 16 }}>
|
|
1212
|
+
{customFields.map((field, i) => this.renderField(field, i))}
|
|
1213
|
+
</Components.FormCard>
|
|
1214
|
+
);
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
renderForm() {
|
|
1218
|
+
const { customFields, loadingTypes } = this.state;
|
|
1219
|
+
const hasCustomFields = customFields && customFields.length > 0;
|
|
1220
|
+
|
|
1221
|
+
if (loadingTypes) {
|
|
1222
|
+
return <Components.Spinner />;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
return (
|
|
1226
|
+
<View style={{ flex: 1 }}>
|
|
1227
|
+
<ScrollView
|
|
1228
|
+
keyboardShouldPersistTaps="always"
|
|
1229
|
+
style={{ flex: 1 }}
|
|
1230
|
+
ref={(ref) => (this.scrollContainer = ref)}
|
|
1231
|
+
>
|
|
1232
|
+
<View style={{ paddingBottom: 2 }}>
|
|
1233
|
+
<Components.LoadingIndicator visible={this.state.submitting} />
|
|
1234
|
+
{this.state.error && (
|
|
1235
|
+
<Text style={styles.errorText}>{this.state.error}</Text>
|
|
1236
|
+
)}
|
|
1237
|
+
<Components.FormCard style={{ marginTop: 16 }}>
|
|
1238
|
+
{/* PC-1255: User picker for on-behalf requests */}
|
|
1239
|
+
{this.state.canCreateOnBehalf && (
|
|
1240
|
+
<Components.FormCardSection
|
|
1241
|
+
label={"Select User"}
|
|
1242
|
+
textValue={this.state.selectedUser?.displayName}
|
|
1243
|
+
hasContent
|
|
1244
|
+
hasUnderline
|
|
1245
|
+
required
|
|
1246
|
+
errorText="Please select a user."
|
|
1247
|
+
showError={this.state.showError && !this.state.selectedUser}
|
|
1248
|
+
sectionStyle={{
|
|
1249
|
+
borderBottomWidth: 1,
|
|
1250
|
+
borderBottomColor: Colours.LINEGREY,
|
|
1251
|
+
}}
|
|
1252
|
+
>
|
|
1253
|
+
<TouchableOpacity onPress={this.onPressUser}>
|
|
1254
|
+
<View style={styles.userPickerContainer}>
|
|
1255
|
+
<View style={styles.profileContainer}>
|
|
1256
|
+
<Components.ProfilePic
|
|
1257
|
+
ProfilePic={this.state.selectedUser?.profilePic}
|
|
1258
|
+
Diameter={30}
|
|
1259
|
+
/>
|
|
1260
|
+
<Text style={styles.nameText}>
|
|
1261
|
+
{this.state.selectedUser?.displayName ||
|
|
1262
|
+
"Select User"}
|
|
1263
|
+
</Text>
|
|
1264
|
+
</View>
|
|
1265
|
+
<Icon
|
|
1266
|
+
name="angle-right"
|
|
1267
|
+
type="font-awesome"
|
|
1268
|
+
iconStyle={[
|
|
1269
|
+
styles.sectionTitle,
|
|
1270
|
+
{
|
|
1271
|
+
fontSize: 20,
|
|
1272
|
+
color: this.props.colourBrandingMain,
|
|
1273
|
+
},
|
|
1274
|
+
]}
|
|
1275
|
+
/>
|
|
1276
|
+
</View>
|
|
1277
|
+
</TouchableOpacity>
|
|
1278
|
+
</Components.FormCardSection>
|
|
1279
|
+
)}
|
|
1280
|
+
{/* PC-1255: Hide Name field when creating on behalf - name comes from selected user */}
|
|
1281
|
+
{!this.state.canCreateOnBehalf && (
|
|
1282
|
+
<Components.FormCardSection
|
|
1283
|
+
label={"Name"}
|
|
1284
|
+
placeholder={"Enter your name"}
|
|
1285
|
+
textValue={this.state.userName}
|
|
1286
|
+
onChangeText={(userName) => this.onChangeName(userName)}
|
|
1287
|
+
editable={
|
|
1288
|
+
this.props.userType === "KIOSK" &&
|
|
1289
|
+
this.state.submitting === false
|
|
1290
|
+
}
|
|
1291
|
+
isValid={() => {
|
|
1292
|
+
return this.state.userName.length > 1;
|
|
1293
|
+
}}
|
|
1294
|
+
required
|
|
1295
|
+
errorText="Please enter your name."
|
|
1296
|
+
showError={
|
|
1297
|
+
this.state.showError && this.state.userName.length < 2
|
|
1298
|
+
}
|
|
1299
|
+
hasUnderline
|
|
1300
|
+
/>
|
|
1301
|
+
)}
|
|
1302
|
+
<Components.FormCardSection
|
|
1303
|
+
label={"Contact number"}
|
|
1304
|
+
placeholder={"Enter phone number"}
|
|
1305
|
+
textValue={this.state.phone}
|
|
1306
|
+
onChangeText={(phone) => this.setState({ phone })}
|
|
1307
|
+
editable={this.state.submitting === false}
|
|
1308
|
+
hasUnderline
|
|
1309
|
+
keyboardType={"phone-pad"}
|
|
1310
|
+
/>
|
|
1311
|
+
<Components.FormCardSection
|
|
1312
|
+
label={"Address"}
|
|
1313
|
+
placeholder={"Enter your address"}
|
|
1314
|
+
textValue={this.state.roomNumber}
|
|
1315
|
+
onChangeText={(roomNumber) => this.setState({ roomNumber })}
|
|
1316
|
+
editable={this.state.submitting === false}
|
|
1317
|
+
hasUnderline
|
|
1318
|
+
isValid={() => {
|
|
1319
|
+
return (
|
|
1320
|
+
this.state.roomNumber && this.state.roomNumber.length > 1
|
|
1321
|
+
);
|
|
1322
|
+
}}
|
|
1323
|
+
required
|
|
1324
|
+
errorText="Please provide your address."
|
|
1325
|
+
showError={
|
|
1326
|
+
this.state.showError &&
|
|
1327
|
+
(!this.state.roomNumber || this.state.roomNumber.length < 2)
|
|
1328
|
+
}
|
|
1329
|
+
/>
|
|
1330
|
+
</Components.FormCard>
|
|
1331
|
+
<Components.FormCard
|
|
1332
|
+
style={{
|
|
1333
|
+
marginTop: 16,
|
|
1334
|
+
paddingHorizontal: 24,
|
|
1335
|
+
paddingVertical: 16,
|
|
1336
|
+
flexDirection: "row",
|
|
1337
|
+
justifyContent: "space-between",
|
|
1338
|
+
}}
|
|
1339
|
+
>
|
|
1340
|
+
<Text style={styles.sectionTitle}>{values.textJobType}</Text>
|
|
1341
|
+
<TouchableOpacity onPress={this.onPressType.bind(this)}>
|
|
1342
|
+
<View style={{ flexDirection: "row" }}>
|
|
1343
|
+
<Text
|
|
1344
|
+
style={[
|
|
1345
|
+
styles.sectionTitle,
|
|
1346
|
+
{ color: this.props.colourBrandingMain, marginRight: 16 },
|
|
1347
|
+
]}
|
|
1348
|
+
>
|
|
1349
|
+
{this.state.type}
|
|
1350
|
+
</Text>
|
|
1351
|
+
<Icon
|
|
1352
|
+
name="angle-right"
|
|
1353
|
+
type="font-awesome"
|
|
1354
|
+
iconStyle={[
|
|
1355
|
+
styles.sectionTitle,
|
|
1356
|
+
{ fontSize: 20, color: this.props.colourBrandingMain },
|
|
1357
|
+
]}
|
|
1358
|
+
/>
|
|
1359
|
+
</View>
|
|
1360
|
+
</TouchableOpacity>
|
|
1361
|
+
</Components.FormCard>
|
|
1362
|
+
{hasCustomFields ? (
|
|
1363
|
+
this.renderCustomFields()
|
|
1364
|
+
) : (
|
|
1365
|
+
<>
|
|
1366
|
+
<Components.FormCard style={{ marginTop: 16 }}>
|
|
1367
|
+
<Components.FormCardSection
|
|
1368
|
+
label={"Title"}
|
|
1369
|
+
placeholder={"Enter a title for your request"}
|
|
1370
|
+
textValue={this.state.title}
|
|
1371
|
+
onChangeText={(title) => this.setState({ title })}
|
|
1372
|
+
editable={this.state.submitting === false}
|
|
1373
|
+
hasUnderline
|
|
1374
|
+
isValid={() => {
|
|
1375
|
+
return this.state.title.length > 1;
|
|
1376
|
+
}}
|
|
1377
|
+
required
|
|
1378
|
+
errorText="Please provide a title."
|
|
1379
|
+
showError={
|
|
1380
|
+
this.state.showError && this.state.title.length < 2
|
|
1381
|
+
}
|
|
1382
|
+
autoCorrect
|
|
1383
|
+
multiline
|
|
1384
|
+
autoGrow
|
|
1385
|
+
/>
|
|
1386
|
+
<Components.FormCardSection
|
|
1387
|
+
label={"Description"}
|
|
1388
|
+
placeholder={"Describe your request here in detail"}
|
|
1389
|
+
textValue={this.state.description}
|
|
1390
|
+
onChangeText={(description) =>
|
|
1391
|
+
this.setState({ description })
|
|
1392
|
+
}
|
|
1393
|
+
editable={this.state.submitting === false}
|
|
1394
|
+
hasUnderline
|
|
1395
|
+
autoCorrect
|
|
1396
|
+
multiline
|
|
1397
|
+
autoGrow
|
|
1398
|
+
/>
|
|
1399
|
+
</Components.FormCard>
|
|
1400
|
+
<Components.FormCard
|
|
1401
|
+
style={{ marginTop: 16, paddingHorizontal: 24 }}
|
|
1402
|
+
>
|
|
1403
|
+
<View
|
|
1404
|
+
style={[
|
|
1405
|
+
{
|
|
1406
|
+
width: "100%",
|
|
1407
|
+
paddingVertical: 16,
|
|
1408
|
+
flexDirection: "row",
|
|
1409
|
+
justifyContent: "space-between",
|
|
1410
|
+
alignItems: "center",
|
|
1411
|
+
position: "relative",
|
|
1412
|
+
},
|
|
1413
|
+
this.state.isHome && {
|
|
1414
|
+
borderBottomWidth: 1,
|
|
1415
|
+
borderBottomColor: Colours.LINEGREY,
|
|
1416
|
+
},
|
|
1417
|
+
]}
|
|
1418
|
+
>
|
|
1419
|
+
<Text style={styles.sectionTitle}>
|
|
1420
|
+
{Config.env.strings.MAINTENANCE_HOME}
|
|
1421
|
+
</Text>
|
|
1422
|
+
<Switch
|
|
1423
|
+
value={this.state.isHome}
|
|
1424
|
+
disabled={this.state.submitting}
|
|
1425
|
+
onValueChange={(value) =>
|
|
1426
|
+
this.setState({ isHome: value })
|
|
1427
|
+
}
|
|
1428
|
+
trackColor={{
|
|
1429
|
+
false: "#ddd",
|
|
1430
|
+
true: this.props.colourBrandingMain,
|
|
1431
|
+
}}
|
|
1432
|
+
thumbColor={Platform.OS === "android" ? "#fff" : null}
|
|
1433
|
+
/>
|
|
1434
|
+
</View>
|
|
1435
|
+
{this.state.isHome && (
|
|
1436
|
+
<Components.FormCardSection
|
|
1437
|
+
label={"Available times"}
|
|
1438
|
+
placeholder={
|
|
1439
|
+
"Describe your available times here in detail."
|
|
1440
|
+
}
|
|
1441
|
+
textValue={this.state.times}
|
|
1442
|
+
onChangeText={(times) => this.setState({ times })}
|
|
1443
|
+
editable={this.state.submitting === false}
|
|
1444
|
+
hasUnderline
|
|
1445
|
+
isValid={() => {
|
|
1446
|
+
return this.state.times.length > 1;
|
|
1447
|
+
}}
|
|
1448
|
+
required
|
|
1449
|
+
errorText="Please provide available times."
|
|
1450
|
+
showError={
|
|
1451
|
+
this.state.showError &&
|
|
1452
|
+
this.state.isHome &&
|
|
1453
|
+
this.state.times.length < 2
|
|
1454
|
+
}
|
|
1455
|
+
minHeight={40}
|
|
1456
|
+
autoCorrect
|
|
1457
|
+
multiline
|
|
1458
|
+
autoGrow
|
|
1459
|
+
/>
|
|
1460
|
+
)}
|
|
1461
|
+
</Components.FormCard>
|
|
1462
|
+
{this.renderImageList()}
|
|
1463
|
+
</>
|
|
1464
|
+
)}
|
|
1465
|
+
</View>
|
|
1466
|
+
</ScrollView>
|
|
1467
|
+
</View>
|
|
1468
|
+
);
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
renderRegisterConfirmation() {
|
|
1472
|
+
return (
|
|
1473
|
+
<Components.ConfirmationPopup
|
|
1474
|
+
confirmText={`${values.textEntityName} submitted`}
|
|
1475
|
+
repeatText={"Submit another"}
|
|
1476
|
+
visible={this.state.confirmationToShow}
|
|
1477
|
+
onClose={this.onCloseConfirmationPopup.bind(this)}
|
|
1478
|
+
onPressAction={this.onConfirmationReset.bind(this)}
|
|
1479
|
+
/>
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
renderVideoPlayerPopup() {
|
|
1484
|
+
const { showFullscreenVideo, currentVideoUrl } = this.state;
|
|
1485
|
+
if (!currentVideoUrl) return;
|
|
1486
|
+
|
|
1487
|
+
return (
|
|
1488
|
+
<Components.VideoPopup
|
|
1489
|
+
uri={currentVideoUrl}
|
|
1490
|
+
visible={showFullscreenVideo}
|
|
1491
|
+
showFullscreenButton={false}
|
|
1492
|
+
onClose={this.toggleFullscreenVideo}
|
|
1493
|
+
/>
|
|
1494
|
+
);
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
renderNoType() {
|
|
1498
|
+
if (!this.state.noType) {
|
|
1499
|
+
return null;
|
|
1500
|
+
}
|
|
1501
|
+
return (
|
|
1502
|
+
<Components.WarningPopup
|
|
1503
|
+
confirmText={"No forms are available"}
|
|
1504
|
+
infoText={"Check back later for forms."}
|
|
1505
|
+
visible={this.state.noType}
|
|
1506
|
+
onClose={this.onPressBack.bind(this)}
|
|
1507
|
+
padHorizontal
|
|
1508
|
+
/>
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
render() {
|
|
1513
|
+
const { submitting, success, isDateTimePickerVisible, popUpType } =
|
|
1514
|
+
this.state;
|
|
1515
|
+
|
|
1516
|
+
return (
|
|
1517
|
+
<KeyboardAvoidingView
|
|
1518
|
+
behavior={Platform.OS === "ios" && "padding"}
|
|
1519
|
+
style={styles.viewContainer}
|
|
1520
|
+
>
|
|
1521
|
+
{this.renderImageUploader()}
|
|
1522
|
+
<View style={styles.container}>
|
|
1523
|
+
<Components.Header
|
|
1524
|
+
leftIcon="angle-left"
|
|
1525
|
+
onPressLeft={this.onPressBack.bind(this)}
|
|
1526
|
+
text={
|
|
1527
|
+
this.props.strings[`${values.featureKey}_textFeatureTitle`] ||
|
|
1528
|
+
values.textFeatureTitle
|
|
1529
|
+
}
|
|
1530
|
+
rightText={submitting || success ? null : "Done"}
|
|
1531
|
+
onPressRight={this.submitRequest.bind(this)}
|
|
1532
|
+
absoluteRight
|
|
1533
|
+
/>
|
|
1534
|
+
{this.renderForm()}
|
|
1535
|
+
</View>
|
|
1536
|
+
{this.renderRegisterConfirmation()}
|
|
1537
|
+
{this.renderVideoPlayerPopup()}
|
|
1538
|
+
{this.renderNoType()}
|
|
1539
|
+
<DateTimePicker
|
|
1540
|
+
isVisible={isDateTimePickerVisible}
|
|
1541
|
+
onConfirm={this.onDateSelected}
|
|
1542
|
+
onCancel={() => this.setState({ isDateTimePickerVisible: false })}
|
|
1543
|
+
mode={popUpType}
|
|
1544
|
+
headerTextIOS={`Pick a ${popUpType}`}
|
|
1545
|
+
/>
|
|
1546
|
+
</KeyboardAvoidingView>
|
|
1547
|
+
);
|
|
1548
|
+
}
|
|
1322
1549
|
}
|
|
1323
1550
|
|
|
1324
1551
|
const styles = {
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1552
|
+
viewContainer: {
|
|
1553
|
+
flex: 1,
|
|
1554
|
+
backgroundColor: "#fff",
|
|
1555
|
+
},
|
|
1556
|
+
container: {
|
|
1557
|
+
flex: 1,
|
|
1558
|
+
position: "relative",
|
|
1559
|
+
backgroundColor: "#f0f0f5",
|
|
1560
|
+
},
|
|
1561
|
+
errorText: {
|
|
1562
|
+
fontFamily: "sf-regular",
|
|
1563
|
+
color: Colours.COLOUR_TANGERINE,
|
|
1564
|
+
fontSize: 16,
|
|
1565
|
+
},
|
|
1566
|
+
requestSuccess: {
|
|
1567
|
+
fontFamily: "sf-regular",
|
|
1568
|
+
color: Colours.TEXT_DARK,
|
|
1569
|
+
fontSize: 17,
|
|
1570
|
+
textAlign: "center",
|
|
1571
|
+
},
|
|
1572
|
+
sectionTitle: {
|
|
1573
|
+
fontFamily: "sf-regular",
|
|
1574
|
+
fontSize: 17,
|
|
1575
|
+
color: Colours.TEXT_DARK,
|
|
1576
|
+
},
|
|
1577
|
+
imageListContainer: {
|
|
1578
|
+
marginTop: 8,
|
|
1579
|
+
padding: 8,
|
|
1580
|
+
flexDirection: "row",
|
|
1581
|
+
backgroundColor: Colours.BOXGREY,
|
|
1582
|
+
minHeight: 106,
|
|
1583
|
+
},
|
|
1584
|
+
imageListContainerEmpty: {
|
|
1585
|
+
justifyContent: "center",
|
|
1586
|
+
alignItems: "center",
|
|
1587
|
+
flexDirection: "column",
|
|
1588
|
+
},
|
|
1589
|
+
documentListContainer: {
|
|
1590
|
+
marginTop: 8,
|
|
1591
|
+
flexDirection: "column",
|
|
1592
|
+
alignItems: "flex-start",
|
|
1593
|
+
},
|
|
1594
|
+
imageContainer: {
|
|
1595
|
+
width: PHOTO_SIZE,
|
|
1596
|
+
height: PHOTO_SIZE,
|
|
1597
|
+
borderStyle: "dashed",
|
|
1598
|
+
justifyContent: "center",
|
|
1599
|
+
alignItems: "center",
|
|
1600
|
+
borderWidth: 1,
|
|
1601
|
+
borderColor: Colours.LINEGREY,
|
|
1602
|
+
borderRadius: 4,
|
|
1603
|
+
marginLeft: 8,
|
|
1604
|
+
},
|
|
1605
|
+
imageContainerNotEmpty: {
|
|
1606
|
+
borderWidth: 1,
|
|
1607
|
+
borderColor: Colours.LINEGREY,
|
|
1608
|
+
backgroundColor: "#fff",
|
|
1609
|
+
borderStyle: "dashed",
|
|
1610
|
+
},
|
|
1611
|
+
imageBackground: {
|
|
1612
|
+
flex: 1,
|
|
1613
|
+
height: "100%",
|
|
1614
|
+
width: "100%",
|
|
1615
|
+
borderRadius: 4,
|
|
1616
|
+
},
|
|
1617
|
+
imageCircle: {
|
|
1618
|
+
width: 90,
|
|
1619
|
+
height: 90,
|
|
1620
|
+
borderRadius: 45,
|
|
1621
|
+
backgroundColor: Colours.PINKISH_GREY,
|
|
1622
|
+
justifyContent: "center",
|
|
1623
|
+
},
|
|
1624
|
+
addImageIcon: {
|
|
1625
|
+
color: "#fff",
|
|
1626
|
+
fontSize: 32,
|
|
1627
|
+
},
|
|
1628
|
+
imagePlayContainer: {
|
|
1629
|
+
position: "absolute",
|
|
1630
|
+
top: 0,
|
|
1631
|
+
left: 0,
|
|
1632
|
+
right: 0,
|
|
1633
|
+
bottom: 0,
|
|
1634
|
+
alignItems: "center",
|
|
1635
|
+
justifyContent: "center",
|
|
1636
|
+
},
|
|
1637
|
+
imageControlIcon: {
|
|
1638
|
+
color: "#fff",
|
|
1639
|
+
fontSize: 20,
|
|
1640
|
+
textShadowColor: "rgba(0,0,0,0.3)",
|
|
1641
|
+
textShadowOffset: { width: 2, height: 2 },
|
|
1642
|
+
},
|
|
1643
|
+
removeImage: {
|
|
1644
|
+
position: "absolute",
|
|
1645
|
+
top: 0,
|
|
1646
|
+
right: 0,
|
|
1647
|
+
padding: 4,
|
|
1648
|
+
width: 40,
|
|
1649
|
+
height: 40,
|
|
1650
|
+
alignItems: "center",
|
|
1651
|
+
justifyContent: "center",
|
|
1652
|
+
},
|
|
1653
|
+
staticTitle: {
|
|
1654
|
+
fontSize: 20,
|
|
1655
|
+
fontFamily: "sf-semibold",
|
|
1656
|
+
color: Colours.TEXT_DARKEST,
|
|
1657
|
+
},
|
|
1658
|
+
staticText: {
|
|
1659
|
+
fontSize: 17,
|
|
1660
|
+
fontFamily: "sf-regular",
|
|
1661
|
+
color: Colours.TEXT_DARKEST,
|
|
1662
|
+
lineHeight: 24,
|
|
1663
|
+
},
|
|
1664
|
+
multiChoiceOption: {
|
|
1665
|
+
marginTop: 16,
|
|
1666
|
+
flexDirection: "row",
|
|
1667
|
+
alignItems: "center",
|
|
1668
|
+
minHeight: 20,
|
|
1669
|
+
},
|
|
1670
|
+
multiChoiceText: {
|
|
1671
|
+
flex: 1,
|
|
1672
|
+
fontFamily: "sf-medium",
|
|
1673
|
+
fontSize: 14,
|
|
1674
|
+
color: Colours.TEXT_DARK,
|
|
1675
|
+
},
|
|
1676
|
+
tick: {
|
|
1677
|
+
marginRight: 10,
|
|
1678
|
+
borderRadius: 4,
|
|
1679
|
+
},
|
|
1680
|
+
unticked: {
|
|
1681
|
+
marginRight: 10,
|
|
1682
|
+
width: 20,
|
|
1683
|
+
height: 20,
|
|
1684
|
+
borderColor: Colours.LINEGREY,
|
|
1685
|
+
borderWidth: 1,
|
|
1686
|
+
borderRadius: 4,
|
|
1687
|
+
},
|
|
1688
|
+
dateContainer: {
|
|
1689
|
+
flexDirection: "row",
|
|
1690
|
+
alignItems: "center",
|
|
1691
|
+
},
|
|
1692
|
+
dateFieldButton: {
|
|
1693
|
+
flex: 1,
|
|
1694
|
+
},
|
|
1695
|
+
dateFieldContainer: {
|
|
1696
|
+
flexDirection: "row",
|
|
1697
|
+
borderRadius: 2,
|
|
1698
|
+
backgroundColor: "#ebeff2",
|
|
1699
|
+
padding: 8,
|
|
1700
|
+
marginTop: 8,
|
|
1701
|
+
},
|
|
1702
|
+
dateText: {
|
|
1703
|
+
flex: 1,
|
|
1704
|
+
fontFamily: "sf-regular",
|
|
1705
|
+
fontSize: 16,
|
|
1706
|
+
color: "#65686D",
|
|
1707
|
+
},
|
|
1708
|
+
dateIcon: {
|
|
1709
|
+
fontSize: 18,
|
|
1710
|
+
color: Colours.TEXT_BLUEGREY,
|
|
1711
|
+
},
|
|
1712
|
+
dateClearButton: {
|
|
1713
|
+
paddingLeft: 12,
|
|
1714
|
+
},
|
|
1715
|
+
removeIcon: {
|
|
1716
|
+
fontSize: 26,
|
|
1717
|
+
color: Colours.TEXT_BLUEGREY,
|
|
1718
|
+
},
|
|
1719
|
+
documentContainer: {
|
|
1720
|
+
flexDirection: "row",
|
|
1721
|
+
alignItems: "center",
|
|
1722
|
+
justifyContent: "space-between",
|
|
1723
|
+
paddingVertical: 4,
|
|
1724
|
+
},
|
|
1725
|
+
documentTypeContainer: {
|
|
1726
|
+
width: 50,
|
|
1727
|
+
height: 60,
|
|
1728
|
+
justifyContent: "center",
|
|
1729
|
+
alignItems: "center",
|
|
1730
|
+
borderRadius: 5,
|
|
1731
|
+
marginRight: 8,
|
|
1732
|
+
},
|
|
1733
|
+
documentTypeText: {
|
|
1734
|
+
color: "#fff",
|
|
1735
|
+
fontFamily: "sf-semibold",
|
|
1736
|
+
textAlign: "center",
|
|
1737
|
+
},
|
|
1738
|
+
documentText: {
|
|
1739
|
+
flex: 1,
|
|
1740
|
+
fontFamily: "sf-semibold",
|
|
1741
|
+
fontSize: 16,
|
|
1742
|
+
color: "#65686D",
|
|
1743
|
+
},
|
|
1744
|
+
removeDocumentButton: {
|
|
1745
|
+
padding: 4,
|
|
1746
|
+
width: 40,
|
|
1747
|
+
height: 40,
|
|
1748
|
+
alignItems: "center",
|
|
1749
|
+
justifyContent: "center",
|
|
1750
|
+
marginLeft: 8,
|
|
1751
|
+
},
|
|
1752
|
+
removeDocumentIcon: {
|
|
1753
|
+
fontSize: 24,
|
|
1754
|
+
},
|
|
1755
|
+
// PC-1255: User picker styles
|
|
1756
|
+
userPickerContainer: {
|
|
1757
|
+
flexDirection: "row",
|
|
1758
|
+
justifyContent: "space-between",
|
|
1759
|
+
alignItems: "center",
|
|
1760
|
+
},
|
|
1761
|
+
profileContainer: {
|
|
1762
|
+
flexDirection: "row",
|
|
1763
|
+
alignItems: "center",
|
|
1764
|
+
},
|
|
1765
|
+
nameText: {
|
|
1766
|
+
fontFamily: "sf-medium",
|
|
1767
|
+
fontSize: 16,
|
|
1768
|
+
color: Colours.TEXT_DARK,
|
|
1769
|
+
marginLeft: 8,
|
|
1770
|
+
},
|
|
1544
1771
|
};
|
|
1545
1772
|
|
|
1546
|
-
const mapStateToProps = state => {
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1773
|
+
const mapStateToProps = (state) => {
|
|
1774
|
+
const { user, connection } = state;
|
|
1775
|
+
const { displayName, profilePic, uid, site, unit, phoneNumber, permissions } =
|
|
1776
|
+
user;
|
|
1777
|
+
return {
|
|
1778
|
+
connected: connection.connected,
|
|
1779
|
+
userType: user.type,
|
|
1780
|
+
displayName,
|
|
1781
|
+
profilePic,
|
|
1782
|
+
uid,
|
|
1783
|
+
site,
|
|
1784
|
+
unit,
|
|
1785
|
+
phoneNumber,
|
|
1786
|
+
permissions,
|
|
1787
|
+
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
|
1788
|
+
strings: state.strings?.config || {},
|
|
1789
|
+
};
|
|
1562
1790
|
};
|
|
1563
1791
|
|
|
1564
1792
|
export default connect(mapStateToProps, { jobAdded })(MaintenanceRequest);
|