import * as React from "react"; import _ from "lodash"; import reducers from "./reducers"; import { ButtonProps, PluginProps } from "./types"; import { ComponentTypes } from "../types"; import { EditorMode } from "@sc/modules/v2/Editor/types"; import Icon from "../Icon"; import { V1ObjectWrapper, convertProperties } from "../V1ObjectWrapper"; /** * A button */ export const Button: React.FC = (settings) => { const { caption1, caption2, caption1style, caption2style, style, properties, hoverStyle, icon, iconSource, iconStyle, onClick, href = "", mode = EditorMode.LIVE, // dispatch, // cKey, // fieldValues, updateComponentSettings, getComponentSettings, actions = [], } = settings; const [isHovering, setIsHovering] = React.useState(false); const handleButtonClick = () => { console.log("Testing", actions); // const { actions } = settings; // console.log({ actions }); if (actions) { const doTheseActions = actions.filter((itm) => itm.behavior === "click"); doTheseActions.forEach((action) => reducers([], { ...action, settings, // settings: { ...settings, cKey, fieldValues }, updateComponentSettings, getComponentSettings, }) ); } }; const btn = ( ); // if (href.length) return {btn}; return btn; }; const ButtonPlugin: React.FC = ({ settings, updateComponentSettings, getComponentSettings, }) => { const properties = convertProperties(settings.properties); return (