diff --git a/locales/en.json b/locales/en.json index 7b14560e..eaeb0914 100644 --- a/locales/en.json +++ b/locales/en.json @@ -147,15 +147,34 @@ "exportFormat": "Format", "exportFrom": "From", "exportInfoText": "Your wallet statement will be downloaded in CSV format.", + "exportInvalidDateInterval": "Invalid date interval", "exportLoadingText": "This can take some minutes", - "exportHelper": "You can only export periods up to one year ago", + "exportHelper": "You can only export periods up to one year ago.", "exportHintDate": "Invalid date", "exportHintRange": "Invalid date", "exportStatement": "Account statement", "exportSuccessful": "Account statement successfully downloaded!", "exportTimeSpan": "Time-span", "exportTo": "To", - "exportWallet": "Wallet" + "exportWallet": "Wallet", + "fileUBIPaymentNote": "UBI payout", + "fileUBIName": "CirclesUBI", + "fileTitle": "Circles Wallet Statement", + "fileWalletName": "Wallet name", + "fileWalletSafeAddress": "Wallet safe address", + "filePeriodStartDate": "Period start date", + "filePeriodEndDate": "Period end date", + "fileBalanceOnEndDate": "Balance on end date", + "fileDemurrage": "Demurrage during selected period", + "fileSumTransactions": "Sum of transaction", + "fileBalanceOnStartDate": "Balance on start date", + "fileTransactionsTitle": "Transactions within period", + "fileTxDate": "Date", + "fileTxUsername": "To or from username", + "fileTxSafeAddress": "To or from safe address", + "fileTxPaymentNote": "Payment note", + "fileTxAmount": "Amount in circles", + "fileNamePrefix": "Circles_Statement" }, "Finder": { "bodyFilterDirect": "Directly trusted", diff --git a/src/components/ActivityStreamWithTabs.js b/src/components/ActivityStreamWithTabs.js index 49e2c9f5..ec3a8f07 100644 --- a/src/components/ActivityStreamWithTabs.js +++ b/src/components/ActivityStreamWithTabs.js @@ -16,7 +16,6 @@ import DialogExportStatement from '~/components/DialogExportStatement'; import Popover from '~/components/Popover'; import TabNavigation from '~/components/TabNavigation'; import TabNavigationAction from '~/components/TabNavigationAction'; -import { useIsOrganization } from '~/hooks/username'; import core from '~/services/core'; import translate from '~/services/locale'; import { @@ -118,9 +117,7 @@ const ActivityStreamWithTabs = ({ basePath = ACTIVITIES_PATH }) => { const [filterTitle, setFilterTitle] = useState(filterItems[0].title); const [anchorEl, setAnchorEl] = useState(null); const { categories, lastSeenAt } = useSelector((state) => state.activity); - const safeAddress = useSelector((state) => state.safe.currentAccount); const news = useSelector((state) => state.activity.news); - const { isOrganization } = useIsOrganization(safeAddress); // Get only new Activities and segregate them by category let newActivities = CATEGORIES.reduceRight((newActivities, category) => { @@ -316,23 +313,19 @@ const ActivityStreamWithTabs = ({ basePath = ACTIVITIES_PATH }) => { })} - {selectedCategory === ActivityFilterTypes.TRANSFERS && - isOrganization && ( - <> - - - {translate('ExportStatement.exportBtnText')} - - - - - )} + {selectedCategory === ActivityFilterTypes.TRANSFERS && ( + <> + + + {translate('ExportStatement.exportBtnText')} + + + + + )} {activity && ( { return [ - 'Circles Wallet Statement', + `${translate('ExportStatement.fileTitle')}`, '', - `Wallet_name; ${walletName}`, - `Wallet_safe_address; ${safeAddress}`, - `Period_start_date; ${startDate}`, - `Period_end_date; ${endDate}`, + `${translate('ExportStatement.fileWalletName')}; ${walletName}`, + `${translate('ExportStatement.fileWalletSafeAddress')}; ${safeAddress}`, + `${translate('ExportStatement.filePeriodStartDate')}; ${startDate}`, + `${translate('ExportStatement.filePeriodEndDate')}; ${endDate}`, '', - `Balance_on_end_date; ${endBalance}`, - `Demurrage_during_selected_period; ${demurrage}`, - `Sum_of_transaction; ${sumOfTransactions}`, - `Balance_on_start_date; ${startBalance}`, + `${translate('ExportStatement.fileBalanceOnEndDate')}; ${endBalance}`, + `${translate('ExportStatement.fileDemurrage')}; ${demurrage}`, + `${translate('ExportStatement.fileSumTransactions')}; ${sumOfTransactions}`, + `${translate('ExportStatement.fileBalanceOnStartDate')}; ${startBalance}`, '', - 'Transactions_within_period', - `Date; To_or_from_username; To_or_from_safe_address; Payment_note; Amount_in_circles`, + `${translate('ExportStatement.fileTransactionsTitle')}`, + `${translate('ExportStatement.fileTxDate')};${translate( + 'ExportStatement.fileTxUsername', + )};${translate('ExportStatement.fileTxSafeAddress')};${translate( + 'ExportStatement.fileTxPaymentNote', + )};${translate('ExportStatement.fileTxAmount')}`, ...csvTransactions, ].join('\n'); }; @@ -110,10 +116,16 @@ const formatTransactions = async (transactions, safeAddress) => { // construct csv transaction return transactionData.map((data, index) => { - data.name = namesBySafe[data.otherSafe] - ? namesBySafe[data.otherSafe].username - : '-'; - data.paymentNote = `"${notes[index].replaceAll('"', '""')}"`; + if (data.otherSafe === ZERO_ADDRESS) { + // UBI transaction + data.name = translate('ExportStatement.fileUBIName'); + data.paymentNote = translate('ExportStatement.fileUBIPaymentNote'); + } else { + data.name = namesBySafe[data.otherSafe] + ? namesBySafe[data.otherSafe].username + : '-'; + data.paymentNote = `"${notes[index].replaceAll('"', '""')}"`; + } return `${data.date};${data.name};${data.otherSafe};${data.paymentNote};${data.amount}`; }); @@ -196,7 +208,7 @@ export async function downloadCsvStatement( ) { // Verify date order if (startDate > endDate) { - throw new Error('Invalid date interval'); + throw new Error(translate('ExportStatement.exportInvalidDateInterval')); } // Transactions @@ -243,7 +255,9 @@ export async function downloadCsvStatement( const dateString = [formatDate(startDate), formatDate(endDate)] .join('_-_') .replace('.', '-'); - const filename = `Circles_Statement_${walletName}_${dateString}.csv`; + const filename = `${translate( + 'ExportStatement.fileNamePrefix', + )}_${walletName}_${dateString}.csv`; // Download fileDownload(csvString, filename);