1- import { Button } from '@/components/ui/button' ;
21import { useEffect , useRef , useState } from 'react' ;
32import { pythonCode } from '@/assets/synthetic-data' ;
43import { usePython } from '@/components/pyodide/use-python' ;
5- import { Share , ChevronDown } from 'lucide-react' ;
64import { csvReader } from '@/components/CSVReader' ;
75import { cn } from '@/lib/utils' ;
86import ComponentMapper from '@/components/componentMapper' ;
@@ -12,15 +10,9 @@ import SyntheticDataSettings from '@/components/SyntheticDataSettings';
1210import { SyntheticDataInfo } from '@/components/synthetic-data-interfaces/cluster-export' ;
1311import LanguageSwitcher from '@/components/ui/languageSwitcher' ;
1412import { useTranslation } from 'react-i18next' ;
15- import {
16- DropdownMenu ,
17- DropdownMenuContent ,
18- DropdownMenuItem ,
19- DropdownMenuTrigger ,
20- } from '@/components/ui/dropdown-menu' ;
21- import { downloadFile } from '@/lib/download-file' ;
2213import { SyntheticDataParameters } from '@/components/synthetic-data-interfaces/SyntheticDataParameters' ;
2314import { exportToCSV } from '@/lib/utils' ;
15+ import { ExportButton } from '@/components/synthetic-data/export-button' ;
2416
2517const PAGE_STYLE = `
2618 @page {
@@ -163,62 +155,12 @@ export default function SyntheticDataGeneration() {
163155 ) }
164156 >
165157 { initialised && data . data . length > 0 && result . length > 0 && (
166- < div className = "ml-auto flex flex-row gap-2 hideonprint" >
167- < DropdownMenu >
168- < DropdownMenuTrigger asChild >
169- < Button
170- variant = "outline"
171- size = "sm"
172- className = "p-4 text-sm"
173- >
174- { t ( 'downloadButton' ) }
175- < ChevronDown className = "relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180" />
176- </ Button >
177- </ DropdownMenuTrigger >
178- < DropdownMenuContent align = "end" >
179- < DropdownMenuItem
180- onClick = { ( ) => reactToPrintFn ( ) }
181- >
182- < Share className = "size-3.5 mr-2" />
183- { t ( 'syntheticData.exportToPDF' ) }
184- </ DropdownMenuItem >
185- { clusterInfo && (
186- < >
187- < DropdownMenuItem
188- onClick = { ( ) => {
189- downloadFile (
190- JSON . stringify (
191- {
192- fileName :
193- data . fileName ,
194- ...clusterInfo ,
195- } ,
196- null ,
197- 2
198- ) ,
199- `${ data . fileName . replace ( '.csv' , '' ) || 'cluster-info' } -${ clusterInfo . date . toISOString ( ) } .json` ,
200- 'application/json'
201- ) ;
202- } }
203- >
204- < Share className = "size-3.5 mr-2" />
205- { t ( 'syntheticData.exportToJSON' ) }
206- </ DropdownMenuItem >
207- < DropdownMenuItem
208- onClick = { ( ) => {
209- handleExport (
210- clusterInfo . syntheticData as object [ ]
211- ) ;
212- } }
213- >
214- < Share className = "size-3.5 mr-2" />
215- { t ( 'syntheticData.exportToCSV' ) }
216- </ DropdownMenuItem >
217- </ >
218- ) }
219- </ DropdownMenuContent >
220- </ DropdownMenu >
221- </ div >
158+ < ExportButton
159+ clusterInfo = { clusterInfo }
160+ data = { data }
161+ handleExport = { handleExport }
162+ reactToPrintFn = { reactToPrintFn }
163+ />
222164 ) }
223165
224166 { result . length > 0 ? (
@@ -232,6 +174,15 @@ export default function SyntheticDataGeneration() {
232174 < div className = "flex-1" />
233175 </ >
234176 ) }
177+
178+ { initialised && data . data . length > 0 && result . length > 0 && (
179+ < ExportButton
180+ clusterInfo = { clusterInfo }
181+ data = { data }
182+ handleExport = { handleExport }
183+ reactToPrintFn = { reactToPrintFn }
184+ />
185+ ) }
235186 </ div >
236187 </ main >
237188 ) ;
0 commit comments