diff --git a/src/incidents/list/ViewIncidentsTable.tsx b/src/incidents/list/ViewIncidentsTable.tsx
index c52f3f1de0..eecad38e6e 100644
--- a/src/incidents/list/ViewIncidentsTable.tsx
+++ b/src/incidents/list/ViewIncidentsTable.tsx
@@ -25,34 +25,42 @@ function ViewIncidentsTable(props: Props) {
// filter data
const exportData = [{}]
- let first = true
- if (data != null) {
- data.forEach((elm) => {
- const entry = {
- code: elm.code,
- date: format(new Date(elm.date), 'yyyy-MM-dd hh:mm a'),
- reportedBy: elm.reportedBy,
- reportedOn: format(new Date(elm.reportedOn), 'yyyy-MM-dd hh:mm a'),
- status: elm.status,
- }
- if (first) {
- exportData[0] = entry
- first = false
- } else {
- exportData.push(entry)
- }
- })
+
+ function populateExportData() {
+ let first = true
+ if (data != null) {
+ data.forEach((elm) => {
+ const entry = {
+ code: elm.code,
+ date: format(new Date(elm.date), 'yyyy-MM-dd hh:mm a'),
+ reportedBy: elm.reportedBy,
+ reportedOn: format(new Date(elm.reportedOn), 'yyyy-MM-dd hh:mm a'),
+ status: elm.status,
+ }
+ if (first) {
+ exportData[0] = entry
+ first = false
+ } else {
+ exportData.push(entry)
+ }
+ })
+ }
}
function downloadCSV() {
+ populateExportData()
+
const fields = Object.keys(exportData[0])
const opts = { fields }
const parser = new Parser(opts)
const csv = parser.parse(exportData)
- console.log(csv)
const incidentsText = t('incidents.label')
- const filename = incidentsText.concat('.csv')
+
+ const filename = incidentsText
+ .concat('-')
+ .concat(format(new Date(Date.now()), 'yyyy-MM-dd--hh-mma'))
+ .concat('.csv')
const text = csv
const element = document.createElement('a')
@@ -76,8 +84,20 @@ function ViewIncidentsTable(props: Props) {
},
]
+ const dropStyle = {
+ marginLeft: 'auto', // note the capital 'W' here
+ marginBottom: '4px', // 'ms' is the only lowercase vendor prefix
+ }
+
return (
<>
+