import { useMode } from "../stores/useMode";
import { Button, Tooltip } from "antd";
import { AIIcon } from "../icons/AIIcon";
import { MODES } from "../config";
import { ApproveIcon } from "../icons/ApproveIcon";
import { WorkingIcon } from "../icons/WorkingIcon";

export const ModeSelector = () => {
  const { mode, setMode, isImportMode } = useMode();

  const handleClick = (selectedMode) => {
    setMode(selectedMode);
  };

  const getType = (currentMode) => {
    if (currentMode === mode) return "primary";

    return "default";
  };

  return (
    <>
      <Tooltip title="Отбор локаций для работы">
        <Button
          icon={<AIIcon />}
          type={getType(MODES.PENDING)}
          onClick={() => handleClick(MODES.PENDING)}
          className="flex items-center justify-center"
          size="large"
        />
      </Tooltip>

      <Tooltip title="Управление статусами локаций">
        <Button
          icon={<ApproveIcon />}
          type={getType(MODES.ON_APPROVAL)}
          onClick={() => handleClick(MODES.ON_APPROVAL)}
          className="flex items-center justify-center"
          size="large"
        />
      </Tooltip>

      <Tooltip title="Мониторинг работающих постаматов" className="text-center">
        <Button
          icon={<WorkingIcon />}
          type={getType(MODES.WORKING)}
          onClick={() => handleClick(MODES.WORKING)}
          className="flex items-center justify-center"
          size="large"
          disabled={isImportMode}
        />
      </Tooltip>
    </>
  );
};
