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.
17 lines
686 B
17 lines
686 B
import { createSelector } from 'reselect'
|
|
|
|
import { getEntityStore } from './entities'
|
|
import { denormalize } from 'src/utils/normalization'
|
|
import { AppState, User, EntityType } 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], EntityType.User, entities)[0] as User
|
|
}
|
|
)
|