import {useMaterialReactTable} from "material-react-table";
import DataTable_Paper from "./table/Paper";

const isTableInstanceProp = (props) => props.table !== undefined;

const DataTable_Main = (props) => {
    let table;

    if (isTableInstanceProp(props)) {
        table = props.table;
    } else {
        // eslint-disable-next-line react-hooks/rules-of-hooks
        table = useMaterialReactTable(props);
    }

    return <DataTable_Paper table={table} columns={props.columns}/>;
};

export default DataTable_Main;
