import type { SidebarItemProps } from './types';
import { SIDEBAR_ITEM_TYPES } from '../constants';
import { SidebarItemSeparator } from './sidebarItemSeparator';
import { SidebarItemTitle } from './sidebarItemTitle';
import { SidebarItemBase } from './sidebarItemBase';

const sidebarComponentsMap = {
  [SIDEBAR_ITEM_TYPES.SEPARATOR]: SidebarItemSeparator,
  [SIDEBAR_ITEM_TYPES.TITLE]: SidebarItemTitle
};

export const SidebarItem = (props: SidebarItemProps) => {
  const { type } = props;

  if (type && sidebarComponentsMap[type]) {
    return sidebarComponentsMap[type](props);
  }

  return <SidebarItemBase {...props} />;
};
