import React from "react";
import { connect } from "redux-bundler-react";

const FavoritesToggle = (props) => {
  const { doToggleLayerFavoritesAdd, layer } = props;
  const btnTxt = layer.favorite ? "Remove From Favorites" : "Add to Favorites";

  return (
    <div>
      <button
        onClick={() => {
          doToggleLayerFavoritesAdd(layer, !layer.favorite);
        }}
        type="button"
        className="cm-btn cm-btn-xs cm-btn-default"
        title={btnTxt}
      >
        {btnTxt}
      </button>
    </div>
  );
};
export default connect("doToggleLayerFavoritesAdd", FavoritesToggle);
