chore: Add an option to download CSAT Reports (#4694)

This commit is contained in:
Pranav Raj S
2022-05-17 21:01:45 +05:30
committed by GitHub
parent 361ffbab82
commit 47f04ee3fe
16 changed files with 189 additions and 28 deletions

View File

@@ -0,0 +1,12 @@
import fromUnixTime from 'date-fns/fromUnixTime';
import format from 'date-fns/format';
export const downloadCsvFile = (fileName, fileContent) => {
const link = document.createElement('a');
link.download = fileName;
link.href = `data:text/csv;charset=utf-8,` + encodeURI(fileContent);
link.click();
};
export const generateFileName = ({ type, to }) =>
`${type}-report-${format(fromUnixTime(to), 'dd-MM-yyyy')}.csv`;