refactoring

This commit is contained in:
2024-06-25 08:18:54 +02:00
parent 717b41384c
commit 395234f919
2 changed files with 37 additions and 29 deletions

View File

@@ -1,18 +1,26 @@
'use client'
import { ReactNode } from "react";
type TableGenOptions = {
editButton:boolean;
deleteButton:boolean;
}
type Props = {
headings:Array<string>;
children:ReactNode;
options?:TableGenOptions
}
export default function TableGen(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,'Edit', 'Delete'].map((h)=>
<th key={h} scope="col">{h}</th>
{[...props.headings,options.editButton ? 'Edit' : null, options.deleteButton ? 'Delete' : null].map((h)=>
h ? <th key={h} scope="col">{h}</th> : ''
)}
</tr>
</thead>