import containerConnect from 'Framework/ComponentContainer';
import { setVisible } from 'App/Reducers/UI/Actions';
import get from 'lodash/get';
import { Services } from 'App/ServiceLocator';

import FastConfiguration from '../../Components/FastConfiguration';
import FastConfigurationRow from '../../Components/FastConfigurationRow';
import FastConfigurationSelect from '../../Components/FastConfigurationSelect';
import Price from '../../Components/Price';

const mapStateToProps = ({ ui, api, configurator }) => {
    return {
        Component: FastConfiguration,
        PriceComponent: Price,
        FastConfigurationRow: FastConfigurationRow,
        FastConfigurationSelect: FastConfigurationSelect,

        show: !!ui.visibilityMap.fastConfiguration,
        options: configurator.options,
        optionclassifications: configurator.configuration.optionclassifications,
        calculation: configurator.calculation,
        isLoading: api.isFetching,
        channelSettings: get(configurator.configuration, 'information.channelSettings'),
        languageSettings: get(configurator.configuration, 'information.languageSettings'),
        configuration: configurator.configuration,
    };
};

const mapDispatchToProps = dispatch => ({
    onClose: () => dispatch(setVisible('fastConfiguration', false)),
    onDoneClick: () => dispatch(setVisible('fastConfiguration', false)),
    onChannelSelect: channel => Services.interaction.setChannel(channel),
});

export default containerConnect(mapStateToProps, mapDispatchToProps);
