Move export file name to constant
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
export const EXPORT_FILE_NAME = 'data.csv'
|
||||||
@@ -10,6 +10,7 @@ import alertError from '../alert-error'
|
|||||||
|
|
||||||
import settings from '../../../i18n/en/settings'
|
import settings from '../../../i18n/en/settings'
|
||||||
import { shared as sharedLabels } from '../../../i18n/en/labels'
|
import { shared as sharedLabels } from '../../../i18n/en/labels'
|
||||||
|
import { EXPORT_FILE_NAME } from './constants'
|
||||||
|
|
||||||
export default class DeleteData extends Component {
|
export default class DeleteData extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -46,7 +47,7 @@ export default class DeleteData extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteExportedFile = async () => {
|
deleteExportedFile = async () => {
|
||||||
const path = RNFS.DocumentDirectoryPath + '/data.csv'
|
const path = `${RNFS.DocumentDirectoryPath}/${EXPORT_FILE_NAME}`
|
||||||
const isFileExist = await RNFS.exists(path)
|
const isFileExist = await RNFS.exists(path)
|
||||||
if (isFileExist) {
|
if (isFileExist) {
|
||||||
await RNFS.unlink(path)
|
await RNFS.unlink(path)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { getCycleDaysSortedByDate } from '../../../db'
|
|||||||
import getDataAsCsvDataUri from '../../../lib/import-export/export-to-csv'
|
import getDataAsCsvDataUri from '../../../lib/import-export/export-to-csv'
|
||||||
import alertError from '../alert-error'
|
import alertError from '../alert-error'
|
||||||
import settings from '../../../i18n/en/settings'
|
import settings from '../../../i18n/en/settings'
|
||||||
|
import { EXPORT_FILE_NAME } from './constants'
|
||||||
import RNFS from 'react-native-fs'
|
import RNFS from 'react-native-fs'
|
||||||
|
|
||||||
export default async function exportData() {
|
export default async function exportData() {
|
||||||
@@ -24,7 +25,7 @@ export default async function exportData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const path = RNFS.DocumentDirectoryPath + '/data.csv'
|
const path = `${RNFS.DocumentDirectoryPath}/${EXPORT_FILE_NAME}`
|
||||||
await RNFS.writeFile(path, data)
|
await RNFS.writeFile(path, data)
|
||||||
|
|
||||||
await Share.open({
|
await Share.open({
|
||||||
|
|||||||
Reference in New Issue
Block a user