import { PlusCircleOutlined } from "@ant-design/icons";
import { Dropdown, Menu } from "antd";
import React from "react";
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 menu = (
    <Menu>
      {bodyshop.md_messaging_presets.map((i, idx) => (
        <Menu.Item onClick={() => setMessage(i.text)} key={idx}>
          {i.label}
        </Menu.Item>
      ))}
    </Menu>
  );

  return (
    <div className={className}>
      <Dropdown trigger={["click"]} overlay={menu}>
        <PlusCircleOutlined />
      </Dropdown>
    </div>
  );
}
export default connect(
  mapStateToProps,
  mapDispatchToProps
)(ChatPresetsComponent);
