You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
846 B
13 lines
846 B
import { denormalize } from 'src/utils/normalization'
|
|
import { AppState, Group, User, EntityType, GroupLog, Invitation } from 'src/types'
|
|
|
|
export const getGroups = (state: AppState) => denormalize(state.groups.items, EntityType.Group, state.entities) as Group[]
|
|
export const getLogs = (state: AppState) => denormalize(state.groups.admin.logs.items, EntityType.Log, state.entities) as GroupLog[]
|
|
export const getInvitations = (state: AppState) => denormalize(state.groups.admin.invitations.items, EntityType.Invitation, state.entities) as Invitation[]
|
|
|
|
export const getGroupMembers = (state: AppState, group: string) => {
|
|
const users = state.entities[EntityType.User]
|
|
if (!users) return []
|
|
|
|
return denormalize(Object.values(users).filter(user => user.group === group).map(user => user.id), EntityType.User, state.entities) as User[]
|
|
}
|