'use client'
import { ReactNode } from "react";

type TableGenOptions = {
    editButton:boolean;
    deleteButton:boolean;
}

type Props = {
    headings:Array<string>;
    children:ReactNode;
    options?:TableGenOptions
}

export default function EntityManagementTable(props:Props){
    const options = props.options ?  props.options : {editButton: true, deleteButton: true}
    console.log(props.headings)
    return <>
    <table className="table overflow-scroll">
        <thead>
            <tr>
                {[...props.headings,options.editButton ? 'Edit' : null, options.deleteButton ? 'Delete' : null].map((h)=>
                h ? <th key={h} scope="col">{h}</th> : ''
                )}
            </tr>
        </thead>
        <tbody>
            {props.children}
        </tbody>
    </table>
    </>
}