From 5dcc1dd24cda32880a28ec9ea5ccaa3726aeffed Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 8 Feb 2024 11:52:37 +0200 Subject: [PATCH 01/26] Add is pdf requred const --- src/state/query/constants.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/state/query/constants.js b/src/state/query/constants.js index cef19ab31..ee03bb414 100644 --- a/src/state/query/constants.js +++ b/src/state/query/constants.js @@ -41,6 +41,7 @@ export default { SET_LOCAL_EXPORT_PATH: 'BITFINEX/EXPORT/CSV_FOLDER_PATH', SET_REMOTE_CSV_URN: 'BITFINEX/EXPORT/CSV_REMOTE_URN', SET_IS_CSV_EXPORTING: 'BITFINEX/EXPORT/IS_CSV_EXPORTING', + SET_IS_PDF_REQUIRED: 'BITFINEX/EXPORT/IS_PDF_REQUIRED', PREPARE_EXPORT: 'BITFINEX/EXPORT/PREPARE', SET_EXPORT_EMAIL: 'BITFINEX/EMAIL/EXPORT', FILTER_ID: 'id', From 0851da8b8eaffaae3faae4750cbc0cd9e5b1fc4b Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 8 Feb 2024 11:54:50 +0200 Subject: [PATCH 02/26] Implement export to pdf status setter --- src/state/query/actions.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/state/query/actions.js b/src/state/query/actions.js index 4f002c0f9..a30a658dd 100644 --- a/src/state/query/actions.js +++ b/src/state/query/actions.js @@ -60,11 +60,19 @@ export function setIsCsvExporting(isExporting) { } } +export function setIsPdfRequired(isPdfRequired) { + return { + type: types.SET_IS_PDF_REQUIRED, + payload: isPdfRequired, + } +} + export default { exportCsv, setRemoteUrn, prepareExport, setExportEmail, + setIsPdfRequired, setIsCsvExporting, setLocalExportPath, } From bd4b4df5fdd7aa0fbf2600f37970d42f2a290704 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 8 Feb 2024 11:56:16 +0200 Subject: [PATCH 03/26] Actualize query reducers handling cases, update init state --- src/state/query/reducer.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/state/query/reducer.js b/src/state/query/reducer.js index bed1841e1..04d12703c 100644 --- a/src/state/query/reducer.js +++ b/src/state/query/reducer.js @@ -7,6 +7,7 @@ const initialState = { localExportPath: null, remoteUrn: null, isCsvExporting: false, + isPDFRequired: false, } export function queryReducer(state = initialState, action) { @@ -32,6 +33,11 @@ export function queryReducer(state = initialState, action) { ...state, isCsvExporting: payload, } + case types.SET_IS_PDF_REQUIRED: + return { + ...state, + isPDFRequired: payload, + } case authTypes.LOGOUT: return initialState default: From f39defb3b85e4cbe1f1c7e41cf596fb97faa8a6f Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 8 Feb 2024 12:09:12 +0200 Subject: [PATCH 04/26] Actualize movements entries props shape --- .../TaxReport/Result/Result.props.js | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/components/TaxReport/Result/Result.props.js b/src/components/TaxReport/Result/Result.props.js index 8b9d6c30c..452ff99ca 100644 --- a/src/components/TaxReport/Result/Result.props.js +++ b/src/components/TaxReport/Result/Result.props.js @@ -14,13 +14,19 @@ const POSITIONS_ENTRIES_PROPS = PropTypes.shape({ }) const MOVEMENTS_ENTRIES_PROPS = PropTypes.shape({ - id: PropTypes.number.isRequired, - currency: PropTypes.string.isRequired, - mtsStarted: PropTypes.number.isRequired, - mtsUpdated: PropTypes.number.isRequired, - status: PropTypes.string.isRequired, - amount: PropTypes.number.isRequired, + amount: PropTypes.number, + amountUsd: PropTypes.number, + currency: PropTypes.string, + currencyName: PropTypes.string, destinationAddress: PropTypes.string, + fees: PropTypes.number, + id: PropTypes.number, + mtsStarted: PropTypes.number, + mtsUpdated: PropTypes.number, + note: PropTypes.string, + status: PropTypes.string, + subUserId: PropTypes.number, + transactionId: PropTypes.string, }) export const propTypes = { @@ -33,7 +39,7 @@ export const propTypes = { positionsTotalPlUsd: PropTypes.number, totalResult: PropTypes.number, }), - movements: PropTypes.arrayOf(MOVEMENTS_ENTRIES_PROPS).isRequired, + movements: PropTypes.arrayOf(MOVEMENTS_ENTRIES_PROPS), movementsTotalAmount: PropTypes.number, endingPeriodBalances: PropTypes.shape({ walletsTotalBalanceUsd: PropTypes.number, From bed77c9d8955d8881f173f1e7ef78fcec7089798 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 8 Feb 2024 12:36:33 +0200 Subject: [PATCH 05/26] Add getIsPdfExportRequired selector --- src/state/query/selectors.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/state/query/selectors.js b/src/state/query/selectors.js index 370262ad1..ae1a35d4f 100644 --- a/src/state/query/selectors.js +++ b/src/state/query/selectors.js @@ -4,6 +4,7 @@ export const getRemoteUrn = state => getQuery(state).remoteUrn export const getExportEmail = state => getQuery(state).exportEmail export const getLocalExportPath = state => getQuery(state).localExportPath export const getIsCsvExporting = state => getQuery(state)?.isCsvExporting ?? false +export const getIsPdfExportRequired = state => getQuery(state)?.isPDFRequired ?? false export default { getQuery, @@ -11,4 +12,5 @@ export default { getExportEmail, getIsCsvExporting, getLocalExportPath, + getIsPdfExportRequired, } From 3174237b7ebd6ce24c32c20fe1b632e752541f8c Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 8 Feb 2024 13:34:00 +0200 Subject: [PATCH 06/26] Implement isTaxReport checker --- src/components/ExportDialog/ExportDialog.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/ExportDialog/ExportDialog.js b/src/components/ExportDialog/ExportDialog.js index 65e7c0d1e..ae0b3a674 100644 --- a/src/components/ExportDialog/ExportDialog.js +++ b/src/components/ExportDialog/ExportDialog.js @@ -123,6 +123,7 @@ class ExportDialog extends PureComponent { if (!isOpen) { return null } + const isTaxReport = currentTargets.includes(queryConstants.MENU_TAX_REPORT) const showLoader = showFrameworkMode && isExporting const target = getTarget(location.pathname) const isWallets = location && location.pathname && target === queryConstants.MENU_WALLETS @@ -182,8 +183,16 @@ class ExportDialog extends PureComponent {
- {t('preferences.milliseconds')} - +
+ {t('preferences.milliseconds')} + +
+ {isTaxReport && ( +
+ {t('download.exportAsPdf')} + +
+ )}
From 15bf52782cd0d390e195fb7b619cd05910d2f00b Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 8 Feb 2024 13:34:58 +0200 Subject: [PATCH 07/26] Actualize export keys/descriptions --- public/locales/en/translations.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index 09c7f42e8..4afaa5d21 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -287,7 +287,8 @@ "email": "Generating your CSV report, we'll send it to you via email as soon as it's ready..." }, "success": "Success", - "targets": "Data to Export" + "targets": "Data to Export", + "exportAsPdf": "Export as PDF" }, "fcredit": { "title": "Funding Credits (Used)", From 87b114e5b00419ab991aedfab2fed90da0ae8458 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 8 Feb 2024 13:38:31 +0200 Subject: [PATCH 08/26] Unify export dialog title --- public/locales/en/translations.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index 4afaa5d21..973b43fe3 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -274,7 +274,7 @@ }, "download": { "query": "Prepare Export", - "title": "Export CSV", + "title": "Export", "prepare": "Bitfinex will prepare your data during", "send": "and send to {{email}}.", "store": "and store to your local folder.", From 120c41df325375739171ce1996626a5d8868636f Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 8 Feb 2024 13:40:30 +0200 Subject: [PATCH 09/26] Actualize local status description --- public/locales/en/translations.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index 973b43fe3..617fe04b3 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -283,7 +283,7 @@ "okay": "Okay", "remoteStorage": "Remote storage", "status": { - "local": "Export csv generated, files are saved in: ", + "local": "Export generated, files are saved in: ", "email": "Generating your CSV report, we'll send it to you via email as soon as it's ready..." }, "success": "Success", From 2bcdb5c70f7335aa8573f2b8ab2d63e51b1fa8e9 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 9 Feb 2024 14:30:55 +0200 Subject: [PATCH 10/26] Actualize query sagas flow for tax report exporting case --- src/state/query/reducer.js | 2 +- src/state/query/saga.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/state/query/reducer.js b/src/state/query/reducer.js index 04d12703c..0224a5ff6 100644 --- a/src/state/query/reducer.js +++ b/src/state/query/reducer.js @@ -7,7 +7,7 @@ const initialState = { localExportPath: null, remoteUrn: null, isCsvExporting: false, - isPDFRequired: false, + isPDFRequired: true, } export function queryReducer(state = initialState, action) { diff --git a/src/state/query/saga.js b/src/state/query/saga.js index 0d8a69d7a..d50604d89 100644 --- a/src/state/query/saga.js +++ b/src/state/query/saga.js @@ -60,7 +60,7 @@ import config from 'config' import actions from './actions' import types from './constants' -import { getExportEmail } from './selectors' +import { getExportEmail, getIsPdfExportRequired } from './selectors' import { getQueryLimit, NO_TIME_FRAME_TARGETS, @@ -250,6 +250,7 @@ function* getOptions({ target }) { const isVSPrevDayBalance = showFrameworkMode ? yield select(getIsVSPrevDayBalance) : '' const isUnrealizedProfitExcluded = showFrameworkMode ? yield select(getIsUnrealizedProfitExcluded) : '' const isVsAccountBalanceSelected = showFrameworkMode ? yield select(getIsVsAccountBalanceSelected) : '' + const isPdfExportRequired = showFrameworkMode ? yield select(getIsPdfExportRequired) : false switch (target) { case MENU_ACCOUNT_BALANCE: @@ -288,6 +289,8 @@ function* getOptions({ target }) { options.symbol = formatSymbol(target, sign.targetSymbols) break case MENU_TAX_REPORT: + options.isPDFRequired = isPdfExportRequired + break case MENU_LOGINS: case MENU_CHANGE_LOGS: break From e5c8acac6c6cb19024170e2de8c78f92116267f4 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 9 Feb 2024 16:27:53 +0200 Subject: [PATCH 11/26] [wip]Export to pdf switcher --- src/components/ExportDialog/ExportDialog.js | 3 +- src/ui/ExportToPdf/ExportToPdf.container.js | 18 +++++++++++ src/ui/ExportToPdf/ExportToPdf.js | 35 +++++++++++++++++++++ src/ui/ExportToPdf/ExportToPdf.props.js | 11 +++++++ src/ui/ExportToPdf/index.js | 3 ++ 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 src/ui/ExportToPdf/ExportToPdf.container.js create mode 100644 src/ui/ExportToPdf/ExportToPdf.js create mode 100644 src/ui/ExportToPdf/ExportToPdf.props.js create mode 100644 src/ui/ExportToPdf/index.js diff --git a/src/components/ExportDialog/ExportDialog.js b/src/components/ExportDialog/ExportDialog.js index ae0b3a674..81e467519 100644 --- a/src/components/ExportDialog/ExportDialog.js +++ b/src/components/ExportDialog/ExportDialog.js @@ -13,6 +13,7 @@ import config from 'config' import { tracker } from 'utils/trackers' import { formatDate } from 'state/utils' import { getTarget } from 'state/query/utils' +import ExportToPdf from 'ui/ExportToPdf' import ShowMilliseconds from 'ui/ShowMilliseconds' import queryConstants from 'state/query/constants' import DateFormatSelector from 'ui/DateFormatSelector' @@ -190,7 +191,7 @@ class ExportDialog extends PureComponent { {isTaxReport && (
{t('download.exportAsPdf')} - +
)}
diff --git a/src/ui/ExportToPdf/ExportToPdf.container.js b/src/ui/ExportToPdf/ExportToPdf.container.js new file mode 100644 index 000000000..9eab82b3b --- /dev/null +++ b/src/ui/ExportToPdf/ExportToPdf.container.js @@ -0,0 +1,18 @@ +import { connect } from 'react-redux' + +import { showMilliseconds } from 'state/base/actions' +import { getShowMilliseconds } from 'state/base/selectors' + +import ShowMilliseconds from './ExportToPdf' + +const mapStateToProps = state => ({ + milliseconds: getShowMilliseconds(state), +}) + +const mapDispatchToProps = { + showMilliseconds, +} + +const ShowMillisecondsContainer = connect(mapStateToProps, mapDispatchToProps)(ShowMilliseconds) + +export default ShowMillisecondsContainer diff --git a/src/ui/ExportToPdf/ExportToPdf.js b/src/ui/ExportToPdf/ExportToPdf.js new file mode 100644 index 000000000..5279f554a --- /dev/null +++ b/src/ui/ExportToPdf/ExportToPdf.js @@ -0,0 +1,35 @@ +import React, { PureComponent } from 'react' +import { Checkbox } from '@blueprintjs/core' + +import { tracker } from 'utils/trackers' + +import { propTypes, defaultProps } from './ExportToPdf.props' + +class ShowMilliseconds extends PureComponent { + handleChange = () => { + const { + milliseconds, + showMilliseconds, + } = this.props + tracker.trackEvent('Display Milliseconds') + showMilliseconds(!milliseconds) + } + + render() { + const { + milliseconds, + } = this.props + return ( + + ) + } +} + +ShowMilliseconds.propTypes = propTypes +ShowMilliseconds.defaultProps = defaultProps + +export default ShowMilliseconds diff --git a/src/ui/ExportToPdf/ExportToPdf.props.js b/src/ui/ExportToPdf/ExportToPdf.props.js new file mode 100644 index 000000000..8a1c7a290 --- /dev/null +++ b/src/ui/ExportToPdf/ExportToPdf.props.js @@ -0,0 +1,11 @@ +import PropTypes from 'prop-types' + +export const propTypes = { + milliseconds: PropTypes.bool, + showMilliseconds: PropTypes.func, +} + +export const defaultProps = { + milliseconds: false, + showMilliseconds: () => {}, +} diff --git a/src/ui/ExportToPdf/index.js b/src/ui/ExportToPdf/index.js new file mode 100644 index 000000000..464b395fc --- /dev/null +++ b/src/ui/ExportToPdf/index.js @@ -0,0 +1,3 @@ +import ExportToPdf from './ExportToPdf.container' + +export default ExportToPdf From 5ee5891a56c2e1a386e143d0f44fe0fcf6f0efa3 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 9 Feb 2024 16:34:05 +0200 Subject: [PATCH 12/26] Cleanup --- src/ui/ExportToPdf/ExportToPdf.js | 39 +++++++++---------------- src/ui/ExportToPdf/ExportToPdf.props.js | 11 ------- src/ui/ExportToPdf/index.js | 4 +-- 3 files changed, 15 insertions(+), 39 deletions(-) delete mode 100644 src/ui/ExportToPdf/ExportToPdf.props.js diff --git a/src/ui/ExportToPdf/ExportToPdf.js b/src/ui/ExportToPdf/ExportToPdf.js index 5279f554a..983a78b6a 100644 --- a/src/ui/ExportToPdf/ExportToPdf.js +++ b/src/ui/ExportToPdf/ExportToPdf.js @@ -1,35 +1,24 @@ -import React, { PureComponent } from 'react' +import React from 'react' import { Checkbox } from '@blueprintjs/core' import { tracker } from 'utils/trackers' -import { propTypes, defaultProps } from './ExportToPdf.props' - -class ShowMilliseconds extends PureComponent { - handleChange = () => { - const { - milliseconds, - showMilliseconds, - } = this.props +const ExportToPdf = ({ + milliseconds, + showMilliseconds, +}) => { + const handleChange = () => { tracker.trackEvent('Display Milliseconds') showMilliseconds(!milliseconds) } - render() { - const { - milliseconds, - } = this.props - return ( - - ) - } + return ( + + ) } -ShowMilliseconds.propTypes = propTypes -ShowMilliseconds.defaultProps = defaultProps - -export default ShowMilliseconds +export default ExportToPdf diff --git a/src/ui/ExportToPdf/ExportToPdf.props.js b/src/ui/ExportToPdf/ExportToPdf.props.js deleted file mode 100644 index 8a1c7a290..000000000 --- a/src/ui/ExportToPdf/ExportToPdf.props.js +++ /dev/null @@ -1,11 +0,0 @@ -import PropTypes from 'prop-types' - -export const propTypes = { - milliseconds: PropTypes.bool, - showMilliseconds: PropTypes.func, -} - -export const defaultProps = { - milliseconds: false, - showMilliseconds: () => {}, -} diff --git a/src/ui/ExportToPdf/index.js b/src/ui/ExportToPdf/index.js index 464b395fc..92f7f3b04 100644 --- a/src/ui/ExportToPdf/index.js +++ b/src/ui/ExportToPdf/index.js @@ -1,3 +1 @@ -import ExportToPdf from './ExportToPdf.container' - -export default ExportToPdf +export { default } from './ExportToPdf.container' From 6136fef822dc7a7f040bf9ad9a9751e48a9d8e04 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 9 Feb 2024 16:41:12 +0200 Subject: [PATCH 13/26] Adjust pdf switcher positioning --- src/components/ExportDialog/ExportDialog.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/ExportDialog/ExportDialog.js b/src/components/ExportDialog/ExportDialog.js index 81e467519..89a266301 100644 --- a/src/components/ExportDialog/ExportDialog.js +++ b/src/components/ExportDialog/ExportDialog.js @@ -184,16 +184,16 @@ class ExportDialog extends PureComponent {
-
- {t('preferences.milliseconds')} - -
{isTaxReport && (
{t('download.exportAsPdf')}
)} +
+ {t('preferences.milliseconds')} + +
From c8c69b77ade1e72bd64e393f4010e5dd4956e2bd Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 9 Feb 2024 16:46:44 +0200 Subject: [PATCH 14/26] Implement swicthing pdf flow --- src/ui/ExportToPdf/ExportToPdf.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ui/ExportToPdf/ExportToPdf.js b/src/ui/ExportToPdf/ExportToPdf.js index 983a78b6a..2a8491ae7 100644 --- a/src/ui/ExportToPdf/ExportToPdf.js +++ b/src/ui/ExportToPdf/ExportToPdf.js @@ -1,22 +1,25 @@ import React from 'react' +import { useDispatch, useSelector } from 'react-redux' import { Checkbox } from '@blueprintjs/core' import { tracker } from 'utils/trackers' +import { setIsPdfRequired } from 'state/query/actions' +import { getIsPdfExportRequired } from 'state/query/selectors' + +const ExportToPdf = () => { + const dispatch = useDispatch() + const isPdfExportRequired = useSelector(getIsPdfExportRequired) -const ExportToPdf = ({ - milliseconds, - showMilliseconds, -}) => { const handleChange = () => { - tracker.trackEvent('Display Milliseconds') - showMilliseconds(!milliseconds) + tracker.trackEvent('Export as PDF') + dispatch(setIsPdfRequired(!isPdfExportRequired)) } return ( ) } From a29ce40a4f646ed5de7a7d8b4ae65bddb462576d Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 9 Feb 2024 16:48:22 +0200 Subject: [PATCH 15/26] Actualize export, cleanup --- src/ui/ExportToPdf/ExportToPdf.container.js | 18 ------------------ src/ui/ExportToPdf/index.js | 2 +- 2 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 src/ui/ExportToPdf/ExportToPdf.container.js diff --git a/src/ui/ExportToPdf/ExportToPdf.container.js b/src/ui/ExportToPdf/ExportToPdf.container.js deleted file mode 100644 index 9eab82b3b..000000000 --- a/src/ui/ExportToPdf/ExportToPdf.container.js +++ /dev/null @@ -1,18 +0,0 @@ -import { connect } from 'react-redux' - -import { showMilliseconds } from 'state/base/actions' -import { getShowMilliseconds } from 'state/base/selectors' - -import ShowMilliseconds from './ExportToPdf' - -const mapStateToProps = state => ({ - milliseconds: getShowMilliseconds(state), -}) - -const mapDispatchToProps = { - showMilliseconds, -} - -const ShowMillisecondsContainer = connect(mapStateToProps, mapDispatchToProps)(ShowMilliseconds) - -export default ShowMillisecondsContainer diff --git a/src/ui/ExportToPdf/index.js b/src/ui/ExportToPdf/index.js index 92f7f3b04..dd35f4c7d 100644 --- a/src/ui/ExportToPdf/index.js +++ b/src/ui/ExportToPdf/index.js @@ -1 +1 @@ -export { default } from './ExportToPdf.container' +export { default } from './ExportToPdf' From b53095d5191e0a7fa87d7e958b0ecc287e1854d3 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 9 Feb 2024 16:56:31 +0200 Subject: [PATCH 16/26] Optimize pdf export switcher --- src/ui/ExportToPdf/ExportToPdf.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/ExportToPdf/ExportToPdf.js b/src/ui/ExportToPdf/ExportToPdf.js index 2a8491ae7..ab8ec6447 100644 --- a/src/ui/ExportToPdf/ExportToPdf.js +++ b/src/ui/ExportToPdf/ExportToPdf.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useCallback } from 'react' import { useDispatch, useSelector } from 'react-redux' import { Checkbox } from '@blueprintjs/core' @@ -10,10 +10,10 @@ const ExportToPdf = () => { const dispatch = useDispatch() const isPdfExportRequired = useSelector(getIsPdfExportRequired) - const handleChange = () => { + const handleChange = useCallback(() => { tracker.trackEvent('Export as PDF') dispatch(setIsPdfRequired(!isPdfExportRequired)) - } + }, [dispatch, tracker, isPdfExportRequired]) return ( Date: Mon, 12 Feb 2024 13:22:39 +0200 Subject: [PATCH 17/26] Actualize export methods names --- src/state/query/saga.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/state/query/saga.js b/src/state/query/saga.js index d50604d89..86b478692 100644 --- a/src/state/query/saga.js +++ b/src/state/query/saga.js @@ -129,7 +129,7 @@ const { } */ -const getMultipleCsv = params => makeFetchCall('getMultipleCsv', params) +const getMultipleCsv = params => makeFetchCall('getMultipleFile', params) function getSelector(target) { switch (target) { @@ -388,7 +388,7 @@ function* getOptions({ target }) { options.method = 'getFullSnapshotReportCsv' break case MENU_TAX_REPORT: - options.method = 'getFullTaxReportCsv' + options.method = 'getFullTaxReportFile' break case MENU_TRADED_VOLUME: options.method = 'getTradedVolumeCsv' From 71c1b6f5af362fad70be82acb82fd888b2639985 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 12 Feb 2024 13:59:21 +0200 Subject: [PATCH 18/26] Lint fix --- src/components/TaxReport/Result/Result.props.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TaxReport/Result/Result.props.js b/src/components/TaxReport/Result/Result.props.js index 452ff99ca..fe274b3a4 100644 --- a/src/components/TaxReport/Result/Result.props.js +++ b/src/components/TaxReport/Result/Result.props.js @@ -39,7 +39,7 @@ export const propTypes = { positionsTotalPlUsd: PropTypes.number, totalResult: PropTypes.number, }), - movements: PropTypes.arrayOf(MOVEMENTS_ENTRIES_PROPS), + movements: PropTypes.arrayOf(MOVEMENTS_ENTRIES_PROPS).isRequired, movementsTotalAmount: PropTypes.number, endingPeriodBalances: PropTypes.shape({ walletsTotalBalanceUsd: PropTypes.number, From 61142ed704e5c5f38f30f2e9769bb3ab84c6de74 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 13 Feb 2024 13:50:36 +0200 Subject: [PATCH 19/26] Implement export dialog helpers --- src/components/ExportDialog/ExportDialog.helpers.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/components/ExportDialog/ExportDialog.helpers.js diff --git a/src/components/ExportDialog/ExportDialog.helpers.js b/src/components/ExportDialog/ExportDialog.helpers.js new file mode 100644 index 000000000..af38e748d --- /dev/null +++ b/src/components/ExportDialog/ExportDialog.helpers.js @@ -0,0 +1,10 @@ +import queryConstants from 'state/query/constants' + +const EXPORT_TO_PDF_WHITELIST = [ + queryConstants.MENU_LEDGERS, + queryConstants.MENU_TAX_REPORT, +] + +export const getShowPdfSwitcher = (targets) => ( + EXPORT_TO_PDF_WHITELIST.some(target => targets.includes(target)) +) From c1b5c4bd715fafc1ab5d1d70dc0bbf9a691a2d3a Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 13 Feb 2024 13:51:30 +0200 Subject: [PATCH 20/26] Enhance pdf switcher availability checking flow --- src/components/ExportDialog/ExportDialog.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ExportDialog/ExportDialog.js b/src/components/ExportDialog/ExportDialog.js index 89a266301..b5b003408 100644 --- a/src/components/ExportDialog/ExportDialog.js +++ b/src/components/ExportDialog/ExportDialog.js @@ -18,6 +18,7 @@ import ShowMilliseconds from 'ui/ShowMilliseconds' import queryConstants from 'state/query/constants' import DateFormatSelector from 'ui/DateFormatSelector' +import { getShowPdfSwitcher } from './ExportDialog.helpers' import ExportTargetsSelector from './ExportDialog.TargetsSelector' const { showFrameworkMode } = config @@ -124,7 +125,7 @@ class ExportDialog extends PureComponent { if (!isOpen) { return null } - const isTaxReport = currentTargets.includes(queryConstants.MENU_TAX_REPORT) + const showPdfSwitcher = getShowPdfSwitcher(currentTargets) const showLoader = showFrameworkMode && isExporting const target = getTarget(location.pathname) const isWallets = location && location.pathname && target === queryConstants.MENU_WALLETS @@ -184,7 +185,7 @@ class ExportDialog extends PureComponent {
- {isTaxReport && ( + {showPdfSwitcher && (
{t('download.exportAsPdf')} From 4aecc173dee1ff91da8663c04aea0161828b4f2e Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 13 Feb 2024 14:03:55 +0200 Subject: [PATCH 21/26] Improve getShowPdfSwitcher checking flow --- src/components/ExportDialog/ExportDialog.helpers.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ExportDialog/ExportDialog.helpers.js b/src/components/ExportDialog/ExportDialog.helpers.js index af38e748d..a55f545d9 100644 --- a/src/components/ExportDialog/ExportDialog.helpers.js +++ b/src/components/ExportDialog/ExportDialog.helpers.js @@ -1,10 +1,13 @@ +import config from 'config' import queryConstants from 'state/query/constants' +const { showFrameworkMode } = config + const EXPORT_TO_PDF_WHITELIST = [ queryConstants.MENU_LEDGERS, queryConstants.MENU_TAX_REPORT, ] export const getShowPdfSwitcher = (targets) => ( - EXPORT_TO_PDF_WHITELIST.some(target => targets.includes(target)) + showFrameworkMode && EXPORT_TO_PDF_WHITELIST.some(target => targets.includes(target)) ) From 6a800ebf4c63366b6050a4e4a1fb5925175d1591 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 13 Feb 2024 14:07:22 +0200 Subject: [PATCH 22/26] Actualize ledgers get export method --- src/state/query/saga.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state/query/saga.js b/src/state/query/saga.js index 86b478692..337e85383 100644 --- a/src/state/query/saga.js +++ b/src/state/query/saga.js @@ -341,7 +341,7 @@ function* getOptions({ target }) { options.method = 'getPayInvoiceListCsv' break case MENU_LEDGERS: - options.method = 'getLedgersCsv' + options.method = 'getLedgersFile' options.category = yield select(getLedgersCategory) break case MENU_LOAN_REPORT: From 0cbbd158020f99c324e0a4290f5df77ec890fcfb Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 13 Feb 2024 14:21:18 +0200 Subject: [PATCH 23/26] Update getOptions saga config for ledgers case --- src/state/query/saga.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/state/query/saga.js b/src/state/query/saga.js index 337e85383..d6d08acd6 100644 --- a/src/state/query/saga.js +++ b/src/state/query/saga.js @@ -342,6 +342,7 @@ function* getOptions({ target }) { break case MENU_LEDGERS: options.method = 'getLedgersFile' + options.isPDFRequired = isPdfExportRequired options.category = yield select(getLedgersCategory) break case MENU_LOAN_REPORT: From 9e988cc771e66df0e402da3a0654c200de6fb0f4 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 19 Feb 2024 12:17:29 +0200 Subject: [PATCH 24/26] Actualize result prop-types, improve linting --- src/components/TaxReport/Result/Result.js | 70 ++++++++++++++++++++++- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/src/components/TaxReport/Result/Result.js b/src/components/TaxReport/Result/Result.js index 91795ac25..7f4754d28 100644 --- a/src/components/TaxReport/Result/Result.js +++ b/src/components/TaxReport/Result/Result.js @@ -1,4 +1,5 @@ import React, { PureComponent } from 'react' +import PropTypes from 'prop-types' import _isNumber from 'lodash/isNumber' import NoData from 'ui/NoData' @@ -10,13 +11,78 @@ import { checkFetch, checkInit } from 'state/utils' import { getFrameworkPositionsColumns } from 'utils/columns' import getMovementsColumns from 'components/Movements/Movements.columns' -import { propTypes } from './Result.props' import getBalancesColumns from './Balances.columns' import TAX_REPORT_SECTIONS from '../TaxReport.sections' const TYPE = queryConstants.MENU_TAX_REPORT class Result extends PureComponent { + static propTypes = { + data: PropTypes.shape({ + startingPositionsSnapshot: PropTypes.arrayOf( + PropTypes.shape({ + amount: PropTypes.number, + basePrice: PropTypes.number, + liquidationPrice: PropTypes.number, + marginFunding: PropTypes.number, + marginFundingType: PropTypes.number, + mtsUpdate: PropTypes.number, + pair: PropTypes.string.isRequired, + pl: PropTypes.number, + plPerc: PropTypes.number, + }), + ).isRequired, + endingPositionsSnapshot: PropTypes.arrayOf( + PropTypes.shape({ + amount: PropTypes.number, + basePrice: PropTypes.number, + liquidationPrice: PropTypes.number, + marginFunding: PropTypes.number, + marginFundingType: PropTypes.number, + mtsUpdate: PropTypes.number, + pair: PropTypes.string.isRequired, + pl: PropTypes.number, + plPerc: PropTypes.number, + }), + ).isRequired, + finalState: PropTypes.shape({ + startingPeriodBalances: PropTypes.shape({ + walletsTotalBalanceUsd: PropTypes.number, + positionsTotalPlUsd: PropTypes.number, + totalResult: PropTypes.number, + }), + movements: PropTypes.arrayOf(PropTypes.shape({ + amount: PropTypes.number, + amountUsd: PropTypes.number, + currency: PropTypes.string, + currencyName: PropTypes.string, + destinationAddress: PropTypes.string, + fees: PropTypes.number, + id: PropTypes.number, + mtsStarted: PropTypes.number, + mtsUpdated: PropTypes.number, + note: PropTypes.string, + status: PropTypes.string, + subUserId: PropTypes.number, + transactionId: PropTypes.string, + })).isRequired, + movementsTotalAmount: PropTypes.number, + endingPeriodBalances: PropTypes.shape({ + walletsTotalBalanceUsd: PropTypes.number, + positionsTotalPlUsd: PropTypes.number, + totalResult: PropTypes.number, + }), + totalResult: PropTypes.number, + }).isRequired, + }).isRequired, + pageLoading: PropTypes.bool.isRequired, + dataReceived: PropTypes.bool.isRequired, + getFullTime: PropTypes.func.isRequired, + timeOffset: PropTypes.string.isRequired, + refresh: PropTypes.func.isRequired, + t: PropTypes.func.isRequired, + } + componentDidMount() { checkInit(this.props, TYPE) } @@ -218,6 +284,4 @@ class Result extends PureComponent { } } -Result.propTypes = propTypes - export default Result From dface5e87b07cfbfe8be1cbc534fe35063cce1f5 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 19 Feb 2024 12:18:14 +0200 Subject: [PATCH 25/26] Cleanup --- .../TaxReport/Result/Result.props.js | 59 ------------------- 1 file changed, 59 deletions(-) delete mode 100644 src/components/TaxReport/Result/Result.props.js diff --git a/src/components/TaxReport/Result/Result.props.js b/src/components/TaxReport/Result/Result.props.js deleted file mode 100644 index fe274b3a4..000000000 --- a/src/components/TaxReport/Result/Result.props.js +++ /dev/null @@ -1,59 +0,0 @@ -/* eslint-disable import/prefer-default-export */ -import PropTypes from 'prop-types' - -const POSITIONS_ENTRIES_PROPS = PropTypes.shape({ - amount: PropTypes.number, - basePrice: PropTypes.number, - liquidationPrice: PropTypes.number, - marginFunding: PropTypes.number, - marginFundingType: PropTypes.number, - mtsUpdate: PropTypes.number, - pair: PropTypes.string.isRequired, - pl: PropTypes.number, - plPerc: PropTypes.number, -}) - -const MOVEMENTS_ENTRIES_PROPS = PropTypes.shape({ - amount: PropTypes.number, - amountUsd: PropTypes.number, - currency: PropTypes.string, - currencyName: PropTypes.string, - destinationAddress: PropTypes.string, - fees: PropTypes.number, - id: PropTypes.number, - mtsStarted: PropTypes.number, - mtsUpdated: PropTypes.number, - note: PropTypes.string, - status: PropTypes.string, - subUserId: PropTypes.number, - transactionId: PropTypes.string, -}) - -export const propTypes = { - data: PropTypes.shape({ - startingPositionsSnapshot: PropTypes.arrayOf(POSITIONS_ENTRIES_PROPS).isRequired, - endingPositionsSnapshot: PropTypes.arrayOf(POSITIONS_ENTRIES_PROPS).isRequired, - finalState: PropTypes.shape({ - startingPeriodBalances: PropTypes.shape({ - walletsTotalBalanceUsd: PropTypes.number, - positionsTotalPlUsd: PropTypes.number, - totalResult: PropTypes.number, - }), - movements: PropTypes.arrayOf(MOVEMENTS_ENTRIES_PROPS).isRequired, - movementsTotalAmount: PropTypes.number, - endingPeriodBalances: PropTypes.shape({ - walletsTotalBalanceUsd: PropTypes.number, - positionsTotalPlUsd: PropTypes.number, - totalResult: PropTypes.number, - }), - totalResult: PropTypes.number, - }).isRequired, - }).isRequired, - pageLoading: PropTypes.bool.isRequired, - dataReceived: PropTypes.bool.isRequired, - getFullTime: PropTypes.func.isRequired, - timeOffset: PropTypes.string.isRequired, - fetchData: PropTypes.func.isRequired, - refresh: PropTypes.func.isRequired, - t: PropTypes.func.isRequired, -} From a71ab069d93f11b9d6c857a0be169162d642daee Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 19 Feb 2024 12:31:55 +0200 Subject: [PATCH 26/26] Lint fix --- src/components/TaxReport/Result/Result.js | 132 +++++++++++----------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/src/components/TaxReport/Result/Result.js b/src/components/TaxReport/Result/Result.js index 7f4754d28..016169906 100644 --- a/src/components/TaxReport/Result/Result.js +++ b/src/components/TaxReport/Result/Result.js @@ -17,72 +17,6 @@ import TAX_REPORT_SECTIONS from '../TaxReport.sections' const TYPE = queryConstants.MENU_TAX_REPORT class Result extends PureComponent { - static propTypes = { - data: PropTypes.shape({ - startingPositionsSnapshot: PropTypes.arrayOf( - PropTypes.shape({ - amount: PropTypes.number, - basePrice: PropTypes.number, - liquidationPrice: PropTypes.number, - marginFunding: PropTypes.number, - marginFundingType: PropTypes.number, - mtsUpdate: PropTypes.number, - pair: PropTypes.string.isRequired, - pl: PropTypes.number, - plPerc: PropTypes.number, - }), - ).isRequired, - endingPositionsSnapshot: PropTypes.arrayOf( - PropTypes.shape({ - amount: PropTypes.number, - basePrice: PropTypes.number, - liquidationPrice: PropTypes.number, - marginFunding: PropTypes.number, - marginFundingType: PropTypes.number, - mtsUpdate: PropTypes.number, - pair: PropTypes.string.isRequired, - pl: PropTypes.number, - plPerc: PropTypes.number, - }), - ).isRequired, - finalState: PropTypes.shape({ - startingPeriodBalances: PropTypes.shape({ - walletsTotalBalanceUsd: PropTypes.number, - positionsTotalPlUsd: PropTypes.number, - totalResult: PropTypes.number, - }), - movements: PropTypes.arrayOf(PropTypes.shape({ - amount: PropTypes.number, - amountUsd: PropTypes.number, - currency: PropTypes.string, - currencyName: PropTypes.string, - destinationAddress: PropTypes.string, - fees: PropTypes.number, - id: PropTypes.number, - mtsStarted: PropTypes.number, - mtsUpdated: PropTypes.number, - note: PropTypes.string, - status: PropTypes.string, - subUserId: PropTypes.number, - transactionId: PropTypes.string, - })).isRequired, - movementsTotalAmount: PropTypes.number, - endingPeriodBalances: PropTypes.shape({ - walletsTotalBalanceUsd: PropTypes.number, - positionsTotalPlUsd: PropTypes.number, - totalResult: PropTypes.number, - }), - totalResult: PropTypes.number, - }).isRequired, - }).isRequired, - pageLoading: PropTypes.bool.isRequired, - dataReceived: PropTypes.bool.isRequired, - getFullTime: PropTypes.func.isRequired, - timeOffset: PropTypes.string.isRequired, - refresh: PropTypes.func.isRequired, - t: PropTypes.func.isRequired, - } - componentDidMount() { checkInit(this.props, TYPE) } @@ -284,4 +218,70 @@ class Result extends PureComponent { } } +Result.propTypes = { + data: PropTypes.shape({ + startingPositionsSnapshot: PropTypes.arrayOf( + PropTypes.shape({ + amount: PropTypes.number, + basePrice: PropTypes.number, + liquidationPrice: PropTypes.number, + marginFunding: PropTypes.number, + marginFundingType: PropTypes.number, + mtsUpdate: PropTypes.number, + pair: PropTypes.string.isRequired, + pl: PropTypes.number, + plPerc: PropTypes.number, + }), + ).isRequired, + endingPositionsSnapshot: PropTypes.arrayOf( + PropTypes.shape({ + amount: PropTypes.number, + basePrice: PropTypes.number, + liquidationPrice: PropTypes.number, + marginFunding: PropTypes.number, + marginFundingType: PropTypes.number, + mtsUpdate: PropTypes.number, + pair: PropTypes.string.isRequired, + pl: PropTypes.number, + plPerc: PropTypes.number, + }), + ).isRequired, + finalState: PropTypes.shape({ + startingPeriodBalances: PropTypes.shape({ + walletsTotalBalanceUsd: PropTypes.number, + positionsTotalPlUsd: PropTypes.number, + totalResult: PropTypes.number, + }), + movements: PropTypes.arrayOf(PropTypes.shape({ + amount: PropTypes.number, + amountUsd: PropTypes.number, + currency: PropTypes.string, + currencyName: PropTypes.string, + destinationAddress: PropTypes.string, + fees: PropTypes.number, + id: PropTypes.number, + mtsStarted: PropTypes.number, + mtsUpdated: PropTypes.number, + note: PropTypes.string, + status: PropTypes.string, + subUserId: PropTypes.number, + transactionId: PropTypes.string, + })).isRequired, + movementsTotalAmount: PropTypes.number, + endingPeriodBalances: PropTypes.shape({ + walletsTotalBalanceUsd: PropTypes.number, + positionsTotalPlUsd: PropTypes.number, + totalResult: PropTypes.number, + }), + totalResult: PropTypes.number, + }).isRequired, + }).isRequired, + pageLoading: PropTypes.bool.isRequired, + dataReceived: PropTypes.bool.isRequired, + getFullTime: PropTypes.func.isRequired, + timeOffset: PropTypes.string.isRequired, + refresh: PropTypes.func.isRequired, + t: PropTypes.func.isRequired, +} + export default Result