[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.
 
 

18 lines
697 B

import { denormalize } from 'normalizr'
import { createSelector } from 'reselect'
import { userSchema } from 'src/store/schemas'
import { getEntityStore } from './entities'
import { AppState, User } from 'src/types'
export const getChecked = (state: AppState) => state.authentication.checked
export const getAuthenticated = (state: AppState) => state.authentication.authenticated
export const getAuthenticatedUserId = (state: AppState) => state.authentication.userId
export const getAuthenticatedUser = createSelector(
[getEntityStore, getAuthenticatedUserId],
(entities, userId) => {
if (!userId) return
return denormalize(userId, userSchema, entities) as User
}
)