forked from nsbradford/TalkFormAI
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62050c1
commit b48dc74
Showing
6 changed files
with
371 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,47 @@ | ||
|
||
interface Props { | ||
data: Array<Record<string, any>>; | ||
data: Array<Record<string, any>>; | ||
} | ||
|
||
const ResponsesTable: React.FC<Props> = ({ data }) => { | ||
if (!data || data.length === 0) return <div>No data available.</div>; | ||
|
||
// Assuming all lists have a similar structure, so we'll use the first list's first item for headers | ||
const sampleItem = data[0]; | ||
if (!sampleItem) return <div>{`${data.length} responses collected but all are empty`}</div>; | ||
|
||
const headers = Object.keys(sampleItem); | ||
|
||
return ( | ||
<div className="overflow-x-auto"> | ||
{data.map((list, listIndex) => ( | ||
<div key={listIndex} className="mb-8"> | ||
<table className="min-w-full bg-white table-auto"> | ||
<thead className="bg-gray-800 text-white"> | ||
<tr> | ||
{headers.map(header => ( | ||
<th key={header} className="px-4 py-2">{header}</th> | ||
if (!data || data.length === 0) return <div>No data available.</div>; | ||
|
||
// Assuming all lists have a similar structure, so we'll use the first list's first item for headers | ||
const sampleItem = data[0]; | ||
if (!sampleItem) | ||
return <div>{`${data.length} responses collected but all are empty`}</div>; | ||
|
||
const headers = Object.keys(sampleItem); | ||
|
||
return ( | ||
<div className="overflow-x-auto"> | ||
{data.map((list, listIndex) => ( | ||
<div key={listIndex} className="mb-8"> | ||
<table className="min-w-full bg-white table-auto"> | ||
<thead className="bg-gray-800 text-white"> | ||
<tr> | ||
{headers.map((header) => ( | ||
<th key={header} className="px-4 py-2"> | ||
{header} | ||
</th> | ||
))} | ||
</tr> | ||
</thead> | ||
<tbody className="text-gray-700"> | ||
{data.map((row, rowIndex) => ( | ||
<tr key={rowIndex}> | ||
{headers.map((header) => ( | ||
<td key={header} className="border px-4 py-2"> | ||
{row[header] || 'N/A'} | ||
</td> | ||
))} | ||
</tr> | ||
</thead> | ||
<tbody className="text-gray-700"> | ||
{data.map((row, rowIndex) => ( | ||
<tr key={rowIndex}> | ||
{headers.map(header => ( | ||
<td key={header} className="border px-4 py-2">{row[header] || 'N/A'}</td> | ||
))} | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
export default ResponsesTable; | ||
|
||
export default ResponsesTable; |
Oops, something went wrong.