@plusscommunities/pluss-maintenance-app 6.0.21-beta.0 → 6.0.22-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.
@@ -1,6 +1,12 @@
1
1
  import React, { Component } from "react";
2
2
  import _ from "lodash";
3
- import { TouchableOpacity, View, ScrollView, Text, TextInput } from "react-native";
3
+ import {
4
+ TouchableOpacity,
5
+ View,
6
+ ScrollView,
7
+ Text,
8
+ TextInput,
9
+ } from "react-native";
4
10
  import { connect } from "react-redux";
5
11
  import { Icon } from "react-native-elements";
6
12
  import { Services } from "../feature.config";
@@ -9,26 +15,29 @@ import { Components, Colours, Fonts } from "../core.config";
9
15
  class MaintenanceUserPicker extends Component {
10
16
  state = {
11
17
  currentUser: null,
12
- searchText: '',
13
- filteredUsers: []
18
+ searchText: "",
19
+ filteredUsers: [],
14
20
  };
15
21
 
16
22
  UNSAFE_componentWillMount() {
17
23
  this.setState({
18
24
  currentUser: this.props.currentUser,
19
- filteredUsers: this.props.users || []
25
+ filteredUsers: this.props.users || [],
20
26
  });
21
27
  }
22
28
 
23
29
  UNSAFE_componentWillReceiveProps(nextProps) {
24
30
  if (nextProps.users !== this.props.users) {
25
31
  this.setState({
26
- filteredUsers: this.getFilteredUsers(this.state.searchText, nextProps.users)
32
+ filteredUsers: this.getFilteredUsers(
33
+ this.state.searchText,
34
+ nextProps.users,
35
+ ),
27
36
  });
28
37
  }
29
38
  if (nextProps.currentUser !== this.props.currentUser) {
30
39
  this.setState({
31
- currentUser: nextProps.currentUser
40
+ currentUser: nextProps.currentUser,
32
41
  });
33
42
  }
34
43
  }
@@ -48,9 +57,9 @@ class MaintenanceUserPicker extends Component {
48
57
  onChangeSearch = (text) => {
49
58
  this.setState({
50
59
  searchText: text,
51
- filteredUsers: this.getFilteredUsers(text)
60
+ filteredUsers: this.getFilteredUsers(text),
52
61
  });
53
- }
62
+ };
54
63
 
55
64
  getFilteredUsers = (searchText, users) => {
56
65
  const usersList = users || this.props.users || [];
@@ -63,33 +72,35 @@ class MaintenanceUserPicker extends Component {
63
72
  return [];
64
73
  }
65
74
 
66
- return usersList.filter(user => {
67
- const displayName = user.displayName || '';
68
- const unit = user.unit || '';
75
+ return usersList.filter((user) => {
76
+ const displayName = user.displayName || "";
77
+ const unit = user.unit || "";
69
78
  const searchLower = searchText.toLowerCase();
70
79
 
71
- return displayName.toLowerCase().includes(searchLower) ||
72
- unit.toLowerCase().includes(searchLower);
80
+ return (
81
+ displayName.toLowerCase().includes(searchLower) ||
82
+ unit.toLowerCase().includes(searchLower)
83
+ );
73
84
  });
74
- }
85
+ };
75
86
 
76
87
  renderSearch = () => {
77
88
  return (
78
89
  <View style={styles.searchContainer}>
79
90
  <Fonts.PlIcon name="nav-search" style={styles.searchIcon} />
80
91
  <TextInput
81
- placeholder='Search by name or unit'
92
+ placeholder="Search by name or unit"
82
93
  autoCorrect={false}
83
- placeholderTextColor={'rgba(60, 60, 80, .1)'}
94
+ placeholderTextColor={"rgba(60, 60, 80, .1)"}
84
95
  onChangeText={this.onChangeSearch}
85
96
  value={this.state.searchText}
86
97
  style={styles.searchText}
87
- underlineColorAndroid={'rgba(0,0,0,0)'}
98
+ underlineColorAndroid={"rgba(0,0,0,0)"}
88
99
  returnKeyType="search"
89
100
  />
90
101
  {this.state.searchText.length > 0 && (
91
102
  <TouchableOpacity
92
- onPress={() => this.onChangeSearch('')}
103
+ onPress={() => this.onChangeSearch("")}
93
104
  style={styles.clearButton}
94
105
  >
95
106
  <Icon
@@ -101,7 +112,7 @@ class MaintenanceUserPicker extends Component {
101
112
  )}
102
113
  </View>
103
114
  );
104
- }
115
+ };
105
116
 
106
117
  renderMain() {
107
118
  if (_.isEmpty(this.props.users)) {
@@ -216,44 +227,44 @@ const styles = {
216
227
  marginLeft: 8,
217
228
  },
218
229
  searchContainer: {
219
- flexDirection: 'row',
220
- alignItems: 'center',
230
+ flexDirection: "row",
231
+ alignItems: "center",
221
232
  paddingHorizontal: 16,
222
233
  paddingVertical: 12,
223
- backgroundColor: '#fff',
234
+ backgroundColor: "#fff",
224
235
  borderBottomWidth: 1,
225
- borderBottomColor: '#f0f0f5'
236
+ borderBottomColor: "#f0f0f5",
226
237
  },
227
238
  searchIcon: {
228
239
  fontSize: 20,
229
240
  marginRight: 10,
230
- color: 'rgba(90, 90, 110, .5)'
241
+ color: "rgba(90, 90, 110, .5)",
231
242
  },
232
243
  searchText: {
233
244
  flex: 1,
234
245
  fontSize: 16,
235
- fontFamily: 'sf-regular',
236
- color: Colours.TEXT_DARK
246
+ fontFamily: "sf-regular",
247
+ color: Colours.TEXT_DARK,
237
248
  },
238
249
  clearButton: {
239
- padding: 8
250
+ padding: 8,
240
251
  },
241
252
  clearIcon: {
242
253
  fontSize: 18,
243
- color: 'rgba(90, 90, 110, .5)'
254
+ color: "rgba(90, 90, 110, .5)",
244
255
  },
245
256
  noResultsContainer: {
246
257
  flex: 1,
247
- alignItems: 'center',
248
- justifyContent: 'center',
249
- paddingVertical: 40
258
+ alignItems: "center",
259
+ justifyContent: "center",
260
+ paddingVertical: 40,
250
261
  },
251
262
  noResultsText: {
252
263
  fontSize: 16,
253
- fontFamily: 'sf-regular',
264
+ fontFamily: "sf-regular",
254
265
  color: Colours.TEXT_LIGHT,
255
- textAlign: 'center'
256
- }
266
+ textAlign: "center",
267
+ },
257
268
  };
258
269
 
259
270
  export default connect(null, {})(MaintenanceUserPicker);