import { AnyAction } from 'redux' ; import { ThunkDispatch } from 'redux-thunk' ; import { connect } from 'react-redux' ; import { LayerControl } from './layer_control' ; import { FLYOUT_STATE } from '../../../reducers/ui' ; import { setSelectedLayer , updateFlyout , setIsLayerTOCOpen , setDrawMode } from '../../../actions' ; import { getIsReadOnly , getIsLayerTOCOpen , getFlyoutDisplay , } from '../../../selectors/ui_selectors' ; import { getLayerList } from '../../../selectors/map_selectors' ; import { MapStoreState } from '../../../reducers/store' ; import { DRAW_MODE } from '../../../../common/constants' ; function mapStateToProps ( state ) { return { isReadOnly : getIsReadOnly ( state ) , isLayerTOCOpen : getIsLayerTOCOpen ( state ) , layerList : getLayerList ( state ) , isFlyoutOpen : getFlyoutDisplay ( state ) !== FLYOUT_STATE . NONE , } ; } function mapDispatchToProps ( dispatch ) { return { showAddLayerWizard : async ( ) => { await dispatch ( setSelectedLayer ( null ) ) ; dispatch ( updateFlyout ( FLYOUT_STATE . ADD_LAYER_WIZARD ) ) ; dispatch ( setDrawMode ( DRAW_MODE . NONE ) ) ; } , closeLayerTOC : ( ) => { dispatch ( setIsLayerTOCOpen ( false ) ) ; } , openLayerTOC : ( ) => { dispatch ( setIsLayerTOCOpen ( true ) ) ; } , } ; } const connected = connect ( mapStateToProps , mapDispatchToProps ) ( LayerControl ) ; export { connected as LayerControl } ;