Skip to content

Commit

Permalink
Merge pull request #9 from iVladyuser/accounts
Browse files Browse the repository at this point in the history
update selectFilteredContacts
  • Loading branch information
iVladyuser authored Dec 3, 2023
2 parents 1cf548a + 26bb100 commit e44e58e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/redux/contacts/contactsSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ export const selectContactsFilterTerm = state => state.filter.filterTerm;
export const selectFilteredContacts = createSelector(
[selectContacts, selectContactsFilterTerm],
(contacts, filterTerm) =>
contacts.filter(
contact =>
contact.name.toLowerCase().includes(filterTerm.toLowerCase().trim()) ||
contact.number.toString().includes(filterTerm.toLowerCase().trim())
)
contacts.filter(contact => {
const name = contact.name || ''; // перевірка, чи не є undefined чи null
const number = contact.number || ''; // перевірка, чи не є undefined чи null

return (
name.toLowerCase().includes(filterTerm.toLowerCase().trim()) ||
number.toString().includes(filterTerm.toLowerCase().trim())
);
})
);

0 comments on commit e44e58e

Please sign in to comment.