import microOn from "images/icons/MicroOn.svg";
import microOff from "images/icons/MicroOff.svg";

import { useState, useEffect } from "react";
import { useTranslation } from "react-i18next";

import { Button } from "components/shared/Button/Button";

export const MicroButton: React.FC<any> = ({
  onClick,
  isActive,
  isSidebarWide,
}) => {
  const { t } = useTranslation();
  const [button, setButton] = useState({
    icon: microOn,
    active: "mute-control-btn",
    inactive: "mute-control-btn-disable",
    type: "microphone",
  });

  useEffect(() => {
    setButton({ ...button, icon: isActive ? microOn : microOff });
  }, [isActive]);

  function handleClick() {
    onClick();
  }

  return (
    <div  style={{pointerEvents: "none"}} tabIndex={-1} onClick={handleClick} className="toolbar-button-area">
      <Button
        isSidebarWide={isSidebarWide}
        button={button}
        active={isActive}
      ></Button>
    </div>
  );
};
