selectors.ts 431 B

123456789101112
  1. import { UsersState } from 'app/types';
  2. export const getUsers = (state: UsersState) => {
  3. const regex = new RegExp(state.searchQuery, 'i');
  4. return state.users.filter((user) => {
  5. return regex.test(user.login) || regex.test(user.email) || regex.test(user.name);
  6. });
  7. };
  8. export const getUsersSearchQuery = (state: UsersState) => state.searchQuery;
  9. export const getUsersSearchPage = (state: UsersState) => state.searchPage;