@@ -2,7 +2,7 @@ import { Button } from '@/components/ui/button';
22import { useEffect , useRef , useState } from 'react' ;
33import { pythonCode } from '@/assets/synthetic-data' ;
44import { usePython } from '@/components/pyodide/use-python' ;
5- import { Share } from 'lucide-react' ;
5+ import { Share , ChevronDown } from 'lucide-react' ;
66import { csvReader } from '@/components/CSVReader' ;
77import { cn } from '@/lib/utils' ;
88import ComponentMapper from '@/components/componentMapper' ;
@@ -20,6 +20,7 @@ import {
2020} from '@/components/ui/dropdown-menu' ;
2121import { downloadFile } from '@/lib/download-file' ;
2222import { SyntheticDataParameters } from '@/components/synthetic-data-interfaces/SyntheticDataParameters' ;
23+ import { exportToCSV } from '@/lib/utils' ;
2324
2425const PAGE_STYLE = `
2526 @page {
@@ -132,6 +133,12 @@ export default function SyntheticDataGeneration() {
132133 } ) ;
133134 } ;
134135
136+ const handleExport = ( syntheticData : object [ ] ) => {
137+ if ( syntheticData . length > 0 ) {
138+ exportToCSV ( syntheticData , 'synthetic_data' ) ;
139+ }
140+ } ;
141+
135142 return (
136143 < main ref = { contentRef } className = "gap-4 p-4 flex flex-col" >
137144 { ! lang && < LanguageSwitcher /> }
@@ -161,6 +168,7 @@ export default function SyntheticDataGeneration() {
161168 className = "p-4 text-sm"
162169 >
163170 { t ( 'downloadButton' ) }
171+ < ChevronDown className = "relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180" />
164172 </ Button >
165173 </ DropdownMenuTrigger >
166174 < DropdownMenuContent align = "end" >
@@ -171,25 +179,38 @@ export default function SyntheticDataGeneration() {
171179 { t ( 'syntheticData.exportToPDF' ) }
172180 </ DropdownMenuItem >
173181 { clusterInfo && (
174- < DropdownMenuItem
175- onClick = { ( ) => {
176- downloadFile (
177- JSON . stringify (
178- {
179- fileName : data . fileName ,
180- ...clusterInfo ,
181- } ,
182- null ,
183- 2
184- ) ,
185- `${ data . fileName . replace ( '.csv' , '' ) || 'cluster-info' } -${ clusterInfo . date . toISOString ( ) } .json` ,
186- 'application/json'
187- ) ;
188- } }
189- >
190- < Share className = "size-3.5 mr-2" />
191- { t ( 'syntheticData.exportToJSON' ) }
192- </ DropdownMenuItem >
182+ < >
183+ < DropdownMenuItem
184+ onClick = { ( ) => {
185+ downloadFile (
186+ JSON . stringify (
187+ {
188+ fileName :
189+ data . fileName ,
190+ ...clusterInfo ,
191+ } ,
192+ null ,
193+ 2
194+ ) ,
195+ `${ data . fileName . replace ( '.csv' , '' ) || 'cluster-info' } -${ clusterInfo . date . toISOString ( ) } .json` ,
196+ 'application/json'
197+ ) ;
198+ } }
199+ >
200+ < Share className = "size-3.5 mr-2" />
201+ { t ( 'syntheticData.exportToJSON' ) }
202+ </ DropdownMenuItem >
203+ < DropdownMenuItem
204+ onClick = { ( ) => {
205+ handleExport (
206+ clusterInfo . syntheticData as object [ ]
207+ ) ;
208+ } }
209+ >
210+ < Share className = "size-3.5 mr-2" />
211+ { t ( 'syntheticData.exportToCSV' ) }
212+ </ DropdownMenuItem >
213+ </ >
193214 ) }
194215 </ DropdownMenuContent >
195216 </ DropdownMenu >
0 commit comments