2022-05-17 15:31:45 +00:00
|
|
|
import fromUnixTime from 'date-fns/fromUnixTime';
|
|
|
|
import format from 'date-fns/format';
|
|
|
|
|
2021-10-06 18:23:51 +00:00
|
|
|
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();
|
|
|
|
};
|
2022-05-17 15:31:45 +00:00
|
|
|
|
|
|
|
export const generateFileName = ({ type, to }) =>
|
|
|
|
`${type}-report-${format(fromUnixTime(to), 'dd-MM-yyyy')}.csv`;
|