
import { FC } from "react"
import { useTranslation } from "react-i18next"
import BorderIcon from "@/assets/border.svg"
import { PanelLabel } from "@/page/App/components/InspectPanel/components/Label"
import { searchDSLByDisplayName } from "@/redux/currentApp/components/componentsSelector"
import ColorPickerSetter from "../ColorPickerSetter"
import MeasureCheckInput from "../InputSetter/MeasureCheckInput"
import { BaseInputSetterProps } from "../InputSetter/interface"
import { containerStyle, headerContainerStyle } from "./style"
import IconHotSpot from "@/utils/IconHotSpot"
// import { ReactComponent as MinusIcon } from "@assets/MinusIcon.svg"
// import { ReactComponent as PlusIcon } from "@assets/PlusIcon.svg"
import { globalColor } from "@/utils/colorBuilder"
import { useStore } from "react-redux"
import { RootState } from "@/store"
const BorderSetter: FC<BaseInputSetterProps> = (props) => {
  const aaaStore = useStore()
  const { handleUpdateMultiAttrDSL, widgetDisplayName } = props

  const currentWidget = searchDSLByDisplayName(widgetDisplayName,aaaStore.getState() as RootState)

  const borderWidth = currentWidget?.props?.borderWidth
  const borderColor = currentWidget?.props?.borderColor

  const hasBorder = !!borderWidth && !!borderColor

  const { t } = useTranslation()

  const handleClickAddBorder = () => {
    handleUpdateMultiAttrDSL?.({
      borderWidth: "1px",
      borderColor: globalColor("white-01"),
    })
  }

  const handleClickDeleteBorder = () => {
    handleUpdateMultiAttrDSL?.({
      borderWidth: undefined,
      borderColor: undefined,
    })
  }

  return (
    <div css={containerStyle}>
      <div css={headerContainerStyle}>
        <PanelLabel labelName={t("editor.inspect.setter_label.border")} />
        {hasBorder ? (
          <IconHotSpot onClick={handleClickDeleteBorder}>
            {/* <MinusIcon /> */}
            null
          </IconHotSpot>
        ) : (
          <IconHotSpot onClick={handleClickAddBorder}>
            {/* <PlusIcon /> */}
            null
          </IconHotSpot>
        )}
      </div>
      {hasBorder && (
        <>
        comneted
           <ColorPickerSetter
            labelName={t("editor.inspect.setter_group.color")}
            value={borderColor}
            attrName="borderColor"
            handleUpdateMultiAttrDSL={handleUpdateMultiAttrDSL}
          />
          <MeasureCheckInput
            labelName={t("editor.inspect.setter_label.border_width")}
            value={borderWidth}
            attrName="borderWidth"
            handleUpdateMultiAttrDSL={handleUpdateMultiAttrDSL}
            icon={<BorderIcon />}
          /> 
        </>
      )}
    </div>
  )
}

export default BorderSetter
