import { PlusCircleOutlined } from "@ant-design/icons";
import { Dropdown } from "antd";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { setMessage } from "../../redux/messaging/messaging.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";

const mapStateToProps = createStructuredSelector({
  //currentUser: selectCurrentUser
  bodyshop: selectBodyshop
});
const mapDispatchToProps = (dispatch) => ({
  //setUserLanguage: language => dispatch(setUserLanguage(language))
  setMessage: (message) => dispatch(setMessage(message))
});

export function ChatPresetsComponent({ bodyshop, setMessage, className }) {
  const items = bodyshop.md_messaging_presets.map((i, idx) => ({
    key: idx,
    label: i.label,
    onClick: () => setMessage(i.text)
  }));

  return (
    <div className={className}>
      <Dropdown trigger={["click"]} menu={{ items }}>
        <PlusCircleOutlined />
      </Dropdown>
    </div>
  );
}

export default connect(mapStateToProps, mapDispatchToProps)(ChatPresetsComponent);
