Fixes the 2 csv files being created on export, in Downloads
This commit is contained in:
@@ -1,19 +1,8 @@
|
||||
import objectPath from 'object-path'
|
||||
import { Base64 } from 'js-base64'
|
||||
import { getCycleDaysSortedByDate } from '../../db'
|
||||
import getColumnNamesForCsv from './get-csv-column-names'
|
||||
|
||||
export default function makeDataURI() {
|
||||
const cycleDaysSortedByDate = getCycleDaysSortedByDate()
|
||||
if (!cycleDaysSortedByDate.length) return null
|
||||
|
||||
const csv = transformToCsv(cycleDaysSortedByDate)
|
||||
const encoded = Base64.encodeURI(csv)
|
||||
// this is the MIME type android/libcore/MimeUtils expects, so we oblige
|
||||
return `data:text/comma-separated-values;base64,${encoded}`
|
||||
}
|
||||
|
||||
function transformToCsv(cycleDays) {
|
||||
export default function transformToCsv(cycleDays) {
|
||||
const columnNames = getColumnNamesForCsv()
|
||||
const rows = cycleDays
|
||||
.map(day => {
|
||||
@@ -23,7 +12,6 @@ function transformToCsv(cycleDays) {
|
||||
})
|
||||
})
|
||||
.map(row => row.join(','))
|
||||
|
||||
rows.unshift(columnNames.join(','))
|
||||
return rows.join('\n')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user