Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 20 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { createSelector } from "reselect"; |
||
2 | import { RootState } from "../store"; |
||
3 | import { User } from "../../models/types"; |
||
4 | import { hasKey } from "../../helpers/queries"; |
||
5 | |||
6 | const getUsersById = (state: RootState): { [id: number]: User } => |
||
7 | state.user.usersById; |
||
8 | |||
9 | export const getUsers = createSelector(getUsersById, (usersById): User[] => |
||
10 | Object.values(usersById), |
||
11 | ); |
||
12 | |||
13 | export const getUserById = ( |
||
14 | state: RootState, |
||
15 | { userId }: { userId: number }, |
||
16 | ): User | null => { |
||
17 | const usersById = getUsersById(state); |
||
18 | return hasKey(usersById, userId) ? usersById[userId] : null; |
||
19 | }; |
||
20 |