import { handleActions } from 'utils/store' ; import { defaultWorkspaceId } from 'utils/config' ; const KEY_ACTIVE_WORKSPACE_ID = 'workspaces.activeWorkspaceId' ; const reducers = { [ KEY_ACTIVE_WORKSPACE_ID ] : handleActions < typeof KEY_ACTIVE_WORKSPACE_ID > ( { SET_ACTIVE_WORKSPACE : ( _ , { payload : { id } } ) => id , ADD_NEW_WORKSPACE : ( state , { payload : { id } } ) => state === null ? id : state , } , defaultWorkspaceId ) , } ; export default reducers ; export const getActiveWorkspaceId = ( state ) => state [ KEY_ACTIVE_WORKSPACE_ID ] ;