Skip to content

Commit 4ae7875

Browse files
authored
Merge pull request #1238 from merico-dev/1237-wrong-encoding-in-csv-files-from-download-data
1237 wrong encoding in csv files from download data
2 parents 715308d + 2703bb8 commit 4ae7875

File tree

6 files changed

+23
-10
lines changed

6 files changed

+23
-10
lines changed

api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/api",
3-
"version": "10.45.1",
3+
"version": "10.45.2",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

dashboard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/dashboard",
3-
"version": "10.45.1",
3+
"version": "10.45.2",
44
"license": "Apache-2.0",
55
"publishConfig": {
66
"access": "public",

dashboard/src/utils/download.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AsyncParser } from '@json2csv/whatwg';
2+
import { notifications } from '@mantine/notifications';
23
import { saveAs } from 'file-saver';
34
import JSZip from 'jszip';
45

@@ -23,12 +24,24 @@ export async function downloadDataAsCSV(id: string, data: TQueryData) {
2324

2425
export function downloadDataListAsZip(idDataList: Array<{ id: string; data: TQueryData }>) {
2526
const zip = new JSZip();
26-
idDataList.forEach(({ id, data }) => {
27-
zip.file(`${id}.csv`, makeCSV(data));
28-
});
29-
zip.generateAsync({ type: 'blob' }).then((content) => {
30-
saveAs(content, 'dashboard_data.zip');
27+
const promises = idDataList.map(async ({ id, data }) => {
28+
const csv = await makeCSV(data);
29+
zip.file(`${id}.csv`, csv);
3130
});
31+
Promise.all(promises)
32+
.then(() => {
33+
zip.generateAsync({ type: 'blob' }).then((content) => {
34+
saveAs(content, 'dashboard_data.zip');
35+
});
36+
})
37+
.catch((err) => {
38+
console.error(err);
39+
notifications.show({
40+
color: 'red',
41+
title: 'Failed to download data',
42+
message: err.message,
43+
});
44+
});
3245
}
3346

3447
export function downloadJSON(name: string, json: string) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/root",
3-
"version": "10.45.1",
3+
"version": "10.45.2",
44
"private": true,
55
"workspaces": [
66
"api",

settings-form/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/settings-form",
3-
"version": "10.45.1",
3+
"version": "10.45.2",
44
"license": "Apache-2.0",
55
"publishConfig": {
66
"access": "public",

website/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@devtable/website",
33
"private": true,
44
"license": "Apache-2.0",
5-
"version": "10.45.1",
5+
"version": "10.45.2",
66
"scripts": {
77
"dev": "vite",
88
"preview": "vite preview"

0 commit comments

Comments
 (0)