refactoring
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user