Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature : Csv Export #2273

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
presets: ["module:@react-native/babel-preset"],
plugins: [
["@babel/plugin-proposal-decorators", { legacy: true }],
'react-native-reanimated/plugin'
]
}
presets: ['module:@react-native/babel-preset'],
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
'react-native-reanimated/plugin',
['@babel/plugin-transform-export-namespace-from']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have we added that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am curious about this too

]
};
9 changes: 8 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,13 @@
"views.ActivityFilter.isFailed": "Failed payments",
"views.ActivityFilter.standardInvoices": "Standard invoices",
"views.ActivityFilter.ampInvoices": "AMP invoices",
"views.ActivityToCsv.title": "Download Activity",
"views.ActivityToCsv.csvDownloaded": "CSV file has been downloaded",
"views.ActivityToCsv.csvDownloadFailed": "Failed to save CSV file:",
"views.ActivityToCsv.csvDownloadSuccess": "Success",
"views.ActivityToCsv.textInputPlaceholder": "File name (optional)",
"views.ActivityToCsv.downloadButton": "Download CSV",
"views.ActivityToCsv.closeButton": "Close",
"views.Routing.RoutingEvent.sourceChannel": "Source Channel",
"views.Routing.RoutingEvent.destinationChannel": "Destination Channel",
"views.Olympians.title": "Olympians",
Expand Down Expand Up @@ -1232,4 +1239,4 @@
"views.PendingHTLCs.expirationHeight": "Expiration height",
"views.PendingHTLCs.recommendationIOS": "It's recommended to leave ZEUS running while there are pending HTLCs to prevent force closes.",
"views.PendingHTLCs.recommendationAndroid": "It's recommended to enable Persistent LND or leave ZEUS running while there are pending HTLCs to prevent force closes."
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
"@babel/plugin-proposal-optional-chaining": "7.21.0",
"@babel/plugin-transform-arrow-functions": "7.22.5",
"@babel/plugin-transform-export-namespace-from": "7.24.7",
"@babel/plugin-transform-shorthand-properties": "7.22.5",
"@babel/plugin-transform-template-literals": "7.22.5",
"@babel/preset-env": "7.22.9",
Expand Down
65 changes: 55 additions & 10 deletions views/Activity/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
Text,
TouchableOpacity,
View,
StyleSheet
StyleSheet,
Alert
} from 'react-native';
import { Button, Icon, ListItem } from 'react-native-elements';
import { inject, observer } from 'mobx-react';
Expand All @@ -31,6 +32,7 @@ import { SATS_PER_BTC } from '../../stores/UnitsStore';

import Filter from '../../assets/images/SVG/Filter On.svg';
import Invoice from '../../models/Invoice';
import JsonToCsv from './ActivityToCsv';

interface ActivityProps {
navigation: StackNavigationProp<any, any>;
Expand All @@ -55,7 +57,8 @@ export default class Activity extends React.PureComponent<
invoicesListener: any;

state = {
selectedPaymentForOrder: null
selectedPaymentForOrder: null,
isCsvModalVisible: false
};

async UNSAFE_componentWillMount() {
Expand Down Expand Up @@ -132,6 +135,21 @@ export default class Activity extends React.PureComponent<
return 'secondaryText';
};

handleDownloadPress = () => {
const { ActivityStore } = this.props;
const { startDate, endDate } = ActivityStore.filters;
const { filteredActivity } = ActivityStore;

if (!startDate || !endDate) {
Alert.alert('Error', 'Please select Start and End date.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs localization

} else {
this.setState({
isCsvModalVisible: true,
filteredData: filteredActivity
});
}
};

render() {
const {
navigation,
Expand All @@ -141,7 +159,7 @@ export default class Activity extends React.PureComponent<
SettingsStore,
route
} = this.props;
const { selectedPaymentForOrder } = this.state;
const { selectedPaymentForOrder, isCsvModalVisible } = this.state;

const { loading, filteredActivity, getActivityAndFilter } =
ActivityStore;
Expand Down Expand Up @@ -225,6 +243,21 @@ export default class Activity extends React.PureComponent<
</TouchableOpacity>
);

const DownloadButton = () => (
<TouchableOpacity
onPress={this.handleDownloadPress}
accessibilityLabel={localeString('views.ActivityToCsv.title')}
>
<Icon
name="download"
type="feather"
color={themeColor('text')}
underlayColor="transparent"
size={33}
/>
</TouchableOpacity>
);

return (
<Screen>
<Header
Expand All @@ -237,16 +270,28 @@ export default class Activity extends React.PureComponent<
}
}}
rightComponent={
order ? (
selectedPaymentForOrder ? (
<MarkPaymentButton />
) : null
) : (
<FilterButton />
)
<View style={{ flexDirection: 'row' }}>
{order ? (
selectedPaymentForOrder ? (
<MarkPaymentButton />
) : null
) : (
<FilterButton />
)}
<DownloadButton />
</View>
}
navigation={navigation}
/>

<JsonToCsv
filteredActivity={filteredActivity}
closeModal={() =>
this.setState({ isCsvModalVisible: false })
}
isVisible={isCsvModalVisible}
/>

{loading ? (
<View style={{ padding: 50 }}>
<LoadingIndicator />
Expand Down
Loading
Loading