import { createSelector } from 'reselect' ; import { AppState } from '@/store' ; import { DatabaseState } from './database.state' ; import { adminKeyLocalStorageKeyName } from './database.constants' ; import { Client } from 'faunadb' ; const selectDatabase = ( state ) : DatabaseState => state . database ; export const selectAdminKey = ( ) : string | null => localStorage . getItem ( adminKeyLocalStorageKeyName ) ; export const selectClient = createSelector ( selectDatabase , ( databaseState ) : Client | { } => databaseState . client ) ; export const selectIsClientSet = createSelector ( selectClient , ( client ) : boolean => Object . keys ( client ) . length !== 0 ) ; export const selectIsFirstTimeOnDevice = createSelector ( selectAdminKey , ( adminKey ) : boolean => { return ! Boolean ( adminKey ) ; } ) ;