File tree Expand file tree Collapse file tree 1 file changed +38
-8
lines changed
app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/resources/components Expand file tree Collapse file tree 1 file changed +38
-8
lines changed Original file line number Diff line number Diff line change 1- import React from 'react'
1+ import { DataTable } from 'opub-ui' ;
22
3- interface EditProps {
4- isPreview :boolean
3+ interface EditProps {
4+ isPreview : boolean ;
5+ previewData : {
6+ columns : string [ ] ;
7+ rows : any [ ] ;
8+ } ;
59}
610
7- const PreviewData = ( { isPreview} : EditProps ) => {
11+ const PreviewData = ( { isPreview, previewData } : EditProps ) => {
12+ const previewColumns =
13+ previewData ?. columns ?. map ( ( column : string ) => ( {
14+ accessorKey : column ,
15+ header : column ,
16+ cell : ( { cell } : any ) => {
17+ const value = cell . getValue ( ) ;
18+ return < span > { value !== null ? value . toString ( ) : 'N/A' } </ span > ;
19+ } ,
20+ } ) ) || [ ] ;
21+
22+ // Transform rows data to match column structure
23+ const previewRows =
24+ previewData ?. rows ?. map ( ( row : any [ ] ) => {
25+ const rowData : Record < string , any > = { } ;
26+ previewData . columns . forEach ( ( column : string , index : number ) => {
27+ rowData [ column ] = row [ index ] ;
28+ } ) ;
29+ return rowData ;
30+ } ) || [ ] ;
831 return (
9- < div > PreviewData</ div >
10- )
11- }
32+ < div className = "md:max-w-[75vh] lg:max-w-[96vh]" >
33+ < DataTable
34+ columns = { previewColumns }
35+ hideFooter
36+ hideSelection
37+ rows = { previewRows }
38+ />
39+ </ div >
40+ ) ;
41+ } ;
1242
13- export default PreviewData
43+ export default PreviewData ;
You can’t perform that action at this time.
0 commit comments