mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 20:18:08 +00:00
chore: Add an option to download CSAT Reports (#4694)
This commit is contained in:
12
app/javascript/dashboard/helper/downloadHelper.js
Normal file
12
app/javascript/dashboard/helper/downloadHelper.js
Normal 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`;
|
||||
Reference in New Issue
Block a user