[ABANDONED] React/Redux front end for the Flexor social network.
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.
 
 

21 lines
899 B

import { denormalize } from 'normalizr'
import { createSelector } from 'reselect'
import filter from 'lodash/filter'
import { groupSchema, userSchema, logSchema } from '../store/schemas'
import { getEntityStore } from './entities'
import { AppState, Group, User, EntityType, GroupLog } from 'src/types'
export const getGroupIds = (state: AppState) => state.directory.groups
export const getGroups = createSelector(
[getEntityStore, getGroupIds],
(entities, groups) => denormalize(groups, [groupSchema], entities) as Group[]
)
export const getGroupMembers = (state: AppState, group: string) => {
const users = state.entities[EntityType.User]
return denormalize(filter(users, user => user.group === group), [userSchema], state.entities) as User[]
}
export const getLogs = (state: AppState) => denormalize(state.entities[EntityType.Log], [logSchema], state.entities) as GroupLog[]