fix csv export (#466)

* style: cleanup formatting

* fix: prevent issues with csv export

* chore: update test snapshots
This commit is contained in:
Carlos Valente
2023-07-23 15:06:25 +02:00
committed by GitHub
parent 3603b836f6
commit bb1eb2838f
4 changed files with 13 additions and 8 deletions
@@ -76,12 +76,18 @@ export default function CuesheetWrapper() {
const sheetData = makeTable(headerData, rundown, userFields);
const csvContent = makeCSV(sheetData);
const encodedUri = encodeURI(csvContent);
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.setAttribute('href', encodedUri);
link.setAttribute('href', url);
link.setAttribute('download', 'ontime export.csv');
document.body.appendChild(link);
link.click();
// Clean up the URL.createObjectURL to release resources
URL.revokeObjectURL(url);
},
[rundown, userFields],
);