import './App.css'; import React, { type ReactElement, useState } from 'react'; import { saveAs } from 'file-saver'; import { type PgErdDiagramInfo } from '../../src/pgerd.types'; import { convertPgerdToDrawIo } from '../../src/converter'; function App(): ReactElement { const [file, setFile] = useState(null); const convertDiagram = (evt: ProgressEvent): void => { const content: string = evt.target?.result as string; const pgerdDiagramJson: PgErdDiagramInfo = JSON.parse(content); const drawIoXml = convertPgerdToDrawIo(pgerdDiagramJson); const blob = new Blob([drawIoXml], { type: 'text/xml;charset=utf-8' }); saveAs(blob, (file?.name ?? 'diagram') + '.xml.drawio'); }; const handleConvertButtonClicked = (): void => { if (file === null) { window.alert('No file was selected'); return; } const fileReader = new FileReader(); fileReader.onloadend = convertDiagram; fileReader.readAsText(file); }; return (

Select the .pgerd file to convert

{ setFile(evt.target.files?.[0] ?? null); }} />
); } export default App;