import { useContext } from "react";
import CanvasContext from "../Context/canvasContext/CanvasContext";
import TextPanel from "./TextPanel";
import ColorPanel from "./ColorPanel";
import ShapePanel from "./ShapePanel";
import IconPanel from "./IconPanel";
import UploadPanel from "./UploadPanel";
import StrokePanel from "./StrokePanel";
import ShadowPanel from "./ShadowPanel";
import FlipPanel from "./FlipPanel";
import PositionPanel from "./PositionPanel";
import ImagePanel from "./ImagePanel";
import GroupObjectPanel from "./GroupObjectPanel";
import CanvasPanel from "./CanvasPanel";
import { ProjectPanel } from "./ProjectPanel";
import ImageLibrary from "./ImageLibrary";
import DesignPanel from "./DesignPanel";

const EditorPanel = () => {
  const { selectedPanel } = useContext(CanvasContext);

  const renderPanel = () => {
    switch (selectedPanel) {
      case "text":
        return <TextPanel />;
      case "shape":
        return <ShapePanel />;
      case "icon":
        return <IconPanel />;
      case "upload":
        return <UploadPanel />;
      case "color":
        return <ColorPanel />;
      case "stroke":
        return <StrokePanel />;
      case "shadow":
        return <ShadowPanel />;
      case "flip":
        return <FlipPanel />;
      case "position":
        return <PositionPanel />;
      case "image-insert":
        return <ImagePanel />;
      case "group-obj":
        return <GroupObjectPanel />;
      case "canvas":
        return <CanvasPanel />;
      case "project":
        return <ProjectPanel />;
      case "image":
        return <ImageLibrary />;
      case "design":
        return <DesignPanel />;
      default:
        return;
    }
  };

  return (
    <>
      {selectedPanel !== "" && (
        <div className="w-screen xl:w-80 lg:w-80 md:w-80 sm:w-80 h-[450px] bg-background rounded-xl shadow-lg mx-0 xl:mx-4 lg:mx-4 md:mx-4 sm:mx-4  my-auto overflow-y-scroll scrollbar-hide">
          {renderPanel()}
        </div>
      )}
    </>
  );
};

export default EditorPanel;
