import React from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { setEmailOptions } from "../../redux/email/email.actions";
import T, {
  Subject
} from "../../emails/templates/appointment-confirmation/appointment-confirmation.template";
import { EMAIL_APPOINTMENT_CONFIRMATION } from "../../emails/templates/appointment-confirmation/appointment-confirmation.query";

const mapStateToProps = createStructuredSelector({
  //currentUser: selectCurrentUser
});
const mapDispatchToProps = dispatch => ({
  setEmailOptions: e => dispatch(setEmailOptions(e))
});
export default connect(
  mapStateToProps,
  mapDispatchToProps
)(function Test({ setEmailOptions }) {
  return (
    <button
      onClick={() =>
        setEmailOptions({
          messageOptions: {
            from: { name: "Kavia Autobody", address: "noreply@bodyshop.app" },
            to: "patrickwf@gmail.com",
            replyTo: "snaptsoft@gmail.com",
            subject: Subject
          },
          template: T,
          queryConfig: [
            EMAIL_APPOINTMENT_CONFIRMATION,
            { variables: { id: "91bb31dd-ea87-4cfc-bbe2-2ec754dcb861" } }
          ]
        })
      }
    >
      Set email config.
    </button>
  );
});
