refactoring

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

View File

@ -28,9 +28,9 @@ function ProjectManager(){
async function getViewMap(): Promise<Map<string, JSX.Element>> {
return new Map([
['home', <Home></Home>],
['man-post', <PostView></PostView>],
['man-proj', <ProjectView></ProjectView>]
['home', <Home key={0}></Home>],
['man-post', <PostView key={1}></PostView>],
['man-proj', <ProjectView key={2}></ProjectView>]
]);
}

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>