import { FC } from "react";
import {
  FiCode,
  FiFileText,
  FiEye,
  FiKey,
  FiUsers,
  FiSettings,
} from "react-icons/fi";

export type View =
  | "editor"
  | "files"
  | "preview"
  | "apikeys"
  | "agents"
  | "system";

type Props = {
  view: View;
  onSelect: (v: View) => void;
};

const Sidebar: FC<Props> = ({ view, onSelect }) => (
  <div className="flex flex-col bg-gray-900 p-2 border-r border-gray-800 space-y-2">
    <SidebarButton 
      icon={<FiCode size={22} />} 
      isActive={view === "editor"} 
      onClick={() => onSelect("editor")}
      label="Editor"
    />
    <SidebarButton 
      icon={<FiFileText size={22} />} 
      isActive={view === "files"} 
      onClick={() => onSelect("files")}
      label="Arquivos"
    />
    <SidebarButton 
      icon={<FiEye size={22} />} 
      isActive={view === "preview"} 
      onClick={() => onSelect("preview")}
      label="Preview"
    />
    <SidebarButton 
      icon={<FiKey size={22} />} 
      isActive={view === "apikeys"} 
      onClick={() => onSelect("apikeys")}
      label="API Keys"
    />
    <SidebarButton 
      icon={<FiUsers size={22} />} 
      isActive={view === "agents"} 
      onClick={() => onSelect("agents")}
      label="Agentes"
    />
    <SidebarButton 
      icon={<FiSettings size={22} />} 
      isActive={view === "system"} 
      onClick={() => onSelect("system")}
      label="Sistema"
    />
  </div>
);

interface SidebarButtonProps {
  icon: React.ReactNode;
  isActive: boolean;
  onClick: () => void;
  label: string;
}

const SidebarButton: FC<SidebarButtonProps> = ({ icon, isActive, onClick, label }) => (
  <button
    onClick={onClick}
    className={`flex items-center justify-center w-10 h-10 rounded transition-all ${
      isActive 
        ? "bg-indigo-600 text-white" 
        : "text-gray-400 hover:bg-gray-800 hover:text-gray-200"
    }`}
    title={label}
  >
    {icon}
  </button>
);

export default Sidebar;
