import React from "react";
import { CellType } from "../types";
import ActionCell from "./Components/ActionCell";

const cellComponents: Record<CellType, React.ComponentType<any>> = {
  [CellType.ACTIONCELL]: ActionCell,
};

const GridCellFactory = ({ cellProps, handleClick, cellType }: any): JSX.Element | null => {
  const CellComponent = cellComponents[cellType as CellType];
  return CellComponent ? (
    <CellComponent handleClick={handleClick} cellProps={cellProps} />
  ) : null;
};

export default GridCellFactory;
