import {bindActionCreators} from 'redux'
import connectForm from '../connect-form'
import OptionExerciseForm from './component'
import {exerciseOption, getSecurity} from 'store/actions'
import {makeGetExchange} from 'store/selectors'

const mapStateToProps = (state, props) => {
    const getExchange = makeGetExchange(props.underlyingSecurity.id)

    return {
        underlyingExchange: getExchange(state),
    }
}

const mapDispatchToProps = (dispatch) => {
    return bindActionCreators(
        {
            exerciseOption,
            getSecurity,
        },
        dispatch
    )
}

export default connectForm(
    OptionExerciseForm,
    mapStateToProps,
    mapDispatchToProps
)
