Skip to content

Commit a3a299a

Browse files
committed
LFG-184: search either by name department or phone
1 parent 1356433 commit a3a299a

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

app/screens/contact/styles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const style = StyleSheet.create({
109109
position: 'absolute',
110110
zIndex: 100,
111111
width: getWidth(),
112-
height: getHeight(),
112+
height: getHeight() - 120,
113113
backgroundColor: 'white'
114114
}
115115

app/utils/dataNormalization.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,22 @@ export const getMyInformation = (employeesList, email) => {
117117
//-------------------search----------
118118

119119
export const searchEmployeesOfName = (employeesList, characters) => {
120+
var chars = characters.toLowerCase()
120121
return employeesList.filter((employee) => {
121-
var name = employee.firstName + " " + employee.lastName;
122-
if (name.search(characters) !== -1) { //This method returns -1 if no match is found.
123-
// console.log('employee---', employee)
124-
return employee
122+
var name = (employee.firstName + " " + employee.lastName).toLowerCase();
123+
var department = employee.department.name.toLowerCase();
124+
var mobilePhone = employee.contact.mobilePhone;
125+
console.log(name, department, chars)
126+
if (parseInt(chars.substring(0, 1))) {
127+
// first character number
128+
if ((mobilePhone.search(chars)) !== -1) { //This method returns -1 if no match is found.
129+
return employee
130+
}
131+
} else {
132+
if ((name.search(chars) !== -1) || (department.search(chars)) !== -1) { //This method returns -1 if no match is found.
133+
// console.log('employee---', employee)
134+
return employee
135+
}
125136
}
126137
})
127138
}

0 commit comments

Comments
 (0)