import { ProfileState } from '@client/profile/profileReducer' ; import { IStoreState } from '@client/store' ; import { Scope } from '@client/utils/authUtils' ; const getPartialState = ( store ) : ProfileState => store . profile ; function getKey < K extends keyof ProfileState > ( store , key ) { return getPartialState ( store ) [ key ] ; } export const getAuthenticated = ( store ) : ProfileState [ 'authenticated' ] => getKey ( store , 'authenticated' ) ; export const getTokenPayload = ( store ) : ProfileState [ 'tokenPayload' ] => getKey ( store , 'tokenPayload' ) ; export const getScope = ( store ) : Scope | null => { const tokenPayload = getTokenPayload ( store ) ; return tokenPayload && tokenPayload . scope ; } ; export const getUserDetails = ( store ) : ProfileState [ 'userDetails' ] => getKey ( store , 'userDetails' ) ;