import { AnyAction } from 'redux' ; import { ThunkDispatch } from 'redux-thunk' ; import { connect } from 'react-redux' ; import { Geometry , Position } from 'geojson' ; import { DrawFeatureControl , ReduxDispatchProps , ReduxStateProps , OwnProps , } from './draw_feature_control' ; import { addNewFeatureToIndex , deleteFeatureFromIndex , updateEditShape } from '../../../../actions' ; import { MapStoreState } from '../../../../reducers/store' ; import { getEditState , getLayerById } from '../../../../selectors/map_selectors' ; import { getDrawMode } from '../../../../selectors/ui_selectors' ; function mapStateToProps ( state ) { const editState = getEditState ( state ) ; const editLayer = editState ? getLayerById ( editState . layerId , state ) : undefined ; return { drawShape : editState ? editState . drawShape : undefined , drawMode : getDrawMode ( state ) , editLayer , } ; } function mapDispatchToProps ( dispatch ) { return { addNewFeatureToIndex ( geometry ) { dispatch ( addNewFeatureToIndex ( geometry ) ) ; } , deleteFeatureFromIndex ( featureId ) { dispatch ( deleteFeatureFromIndex ( featureId ) ) ; } , disableDrawState ( ) { dispatch ( updateEditShape ( null ) ) ; } , } ; } const connected = connect < ReduxStateProps , ReduxDispatchProps , OwnProps , MapStoreState > ( mapStateToProps , mapDispatchToProps ) ( DrawFeatureControl ) ; export { connected as DrawFeatureControl } ;