diff --git a/components/labels.js b/components/labels.js new file mode 100644 index 0000000000000000000000000000000000000000..cd361c8499803cd2d6cd83d1d961a710891646c7 --- /dev/null +++ b/components/labels.js @@ -0,0 +1,10 @@ +export const settings = { + errors: { + noData: 'There is no data to export', + couldNotConvert: 'Could not convert data to CSV', + problemSharing: 'There was a problem sharing the data export file' + }, + exportTitle: 'My Drip data export', + exportSubject: 'My Drip data export', + buttonLabel: 'Export data' +} \ No newline at end of file diff --git a/components/settings.js b/components/settings.js index 13ac3204c34e29fb943a1ef254d37f6f2650364f..9bc6c81465c8f2f85a8d0bdcd46fc0c65529a7d8 100644 --- a/components/settings.js +++ b/components/settings.js @@ -9,6 +9,7 @@ import { import Share from 'react-native-share' import getDataAsCsvDataUri from '../lib/export-to-csv' import styles from '../styles/index' +import { settings as labels } from './labels' export default class Settings extends Component { constructor(props) { @@ -31,27 +32,27 @@ export default class Settings extends Component { try { data = getDataAsCsvDataUri() if (!data) { - return Alert.alert('There is no data to export') + return Alert.alert(labels.errors.noData) } } catch (err) { console.error(err) - return Alert.alert('Could not convert data to CSV') + return Alert.alert(labels.errors.couldNotConvert) } try { await Share.open({ - title: 'My Drip data export', + title: labels.exportTitle, url: data, - subject: 'My Drip data export', + subject: labels.exportSubject, type: 'text/csv', showAppsToView: true }) } catch (err) { console.error(err) - return Alert.alert('There was a problem sharing the data export file') + return Alert.alert(labels.errors.problemSharing) } }} - title="Export data"> + title={labels.buttonLabel}> </Button> </View> </View>