fix: Update report method to fix issues with special characters (#4697)

This commit is contained in:
Pranav Raj S
2022-05-18 12:15:30 +05:30
committed by GitHub
parent 47f04ee3fe
commit 20565d09c0
8 changed files with 51 additions and 79 deletions

View File

@@ -1,11 +1,16 @@
import fromUnixTime from 'date-fns/fromUnixTime';
import format from 'date-fns/format';
export const downloadCsvFile = (fileName, fileContent) => {
export const downloadCsvFile = (fileName, content) => {
const contentType = 'data:text/csv;charset=utf-8;';
const blob = new Blob([content], { type: contentType });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.download = fileName;
link.href = `data:text/csv;charset=utf-8,` + encodeURI(fileContent);
link.setAttribute('download', fileName);
link.setAttribute('href', url);
link.click();
return link;
};
export const generateFileName = ({ type, to }) =>