import containerConnect from 'Framework/ComponentContainer';
import { setVisible } from 'App/Reducers/UI/Actions';

const mapStateToProps = ({ ui, configurator }) => ({
    show: !!ui.visibilityMap.shareConfiguration,
    workInProgress: !!ui.backgroundWorkMap.shareConfiguration,
    errorMessage: ui.error && ui.error.message,
    code: configurator.configuration.code || false,
    shareUrl: configurator.configuration.shareUrl || false,
    previewImageURL: configurator.configuration.previewImageURL || false,
    configuration: configurator.configuration,
    loadLoginInfoInProgress: !!ui.backgroundWorkMap.loadLoginInfo,
});

const mapDispatchToProps = dispatch => ({
    onClose: () => dispatch(setVisible('shareConfiguration', false)),
    onOkClick: () => dispatch(setVisible('shareConfiguration', false)),
});

export default containerConnect(mapStateToProps, mapDispatchToProps);
