import React from 'react';
import { connect } from 'redux-bundler-react';
import classnames from "classnames";
class ModalWindow extends React.Component {
  render(){
    const { modalChildren, modalOptions } = this.props;

    if(!modalChildren || !modalChildren.length) return null;
    
    const smSize = modalOptions.smSize;
    const contentClass = classnames({
      "cm-modal-content": true,
      "cm-modal-lg": smSize ? false : true,
      "cm-modal-sm": smSize ? true : false,
    });
    return (
      <div className="cm-modal show">
        <div className="cm-modal-dialog">
          <div className={contentClass}>
            {
              modalChildren.map((component, i) => {
                const Comp = component;
                return <Comp key={i} {...modalOptions} />
              })
            }
          </div>
        </div>
      </div>
    )
  }
}
export default connect(
  'selectModalChildren',
  'selectModalOptions',
  ModalWindow
);