import { isPlanExpired } from '@devhub/core' ; import { EMPTY_OBJ } from '../../utils/constants' ; import { RootState } from '../types' ; import { githubAppTokenSelector , githubTokenSelector } from './github/auth' ; const s = ( state ) => state . auth || EMPTY_OBJ ; export const authErrorSelector = ( state ) => s ( state ) . error ; export const isDeletingAccountSelector = ( state ) => s ( state ) . isDeletingAccount ; export const isLoggingInSelector = ( state ) => s ( state ) . isLoggingIn ; export const isLoggedSelector = ( state ) => appTokenSelector ( state ) && ( githubAppTokenSelector ( state ) || githubTokenSelector ( state ) ) ? ! ! ( s ( state ) . user && s ( state ) . user ! . _id ) : false ; export const appTokenSelector = ( state ) => s ( state ) . appToken || undefined ; export const currentUserSelector = ( state ) => { const user = s ( state ) . user ; if ( ! isLoggedSelector ( state ) ) return undefined ; return user ; } ; export const currentUserPlanSelector = ( state ) => { const user = currentUserSelector ( state ) ; return ( user && user . plan ) || undefined ; } ; export const isPlanExpiredSelector = ( state ) : boolean => { const plan = currentUserPlanSelector ( state ) ; return isPlanExpired ( plan ) ; } ; export const currentUserIdSelector = ( state ) => { const user = currentUserSelector ( state ) ; return ( user && user . _id ) || undefined ; } ;