diff --git a/src/components/ExportDialog/ExportDialog.container.js b/src/components/ExportDialog/ExportDialog.container.js index 9e83459f4..523bbe83f 100644 --- a/src/components/ExportDialog/ExportDialog.container.js +++ b/src/components/ExportDialog/ExportDialog.container.js @@ -7,9 +7,9 @@ import { toggleExportDialog } from 'state/ui/actions' import { getTimestamp } from 'state/wallets/selectors' import { getTimeFrame } from 'state/timeRange/selectors' import { getIsExportDialogOpen } from 'state/ui/selectors' -import { exportCsv, prepareExport } from 'state/query/actions' +import { exportReport, prepareExport } from 'state/query/actions' import { getFullTime, getTimezone } from 'state/base/selectors' -import { getExportEmail, getIsCsvExporting } from 'state/query/selectors' +import { getExportEmail, getIsReportExporting } from 'state/query/selectors' import ExportDialog from './ExportDialog' @@ -20,11 +20,11 @@ const mapStateToProps = state => ({ timestamp: getTimestamp(state), getFullTime: getFullTime(state), isOpen: getIsExportDialogOpen(state), - isExporting: getIsCsvExporting(state), + isExporting: getIsReportExporting(state), }) const mapDispatchToProps = { - exportCsv, + exportReport, prepareExport, toggleDialog: toggleExportDialog, } diff --git a/src/components/ExportDialog/ExportDialog.js b/src/components/ExportDialog/ExportDialog.js index b5b003408..9efc90a6b 100644 --- a/src/components/ExportDialog/ExportDialog.js +++ b/src/components/ExportDialog/ExportDialog.js @@ -31,7 +31,7 @@ class ExportDialog extends PureComponent { end: PropTypes.number, email: PropTypes.string, toggleDialog: PropTypes.func.isRequired, - exportCsv: PropTypes.func.isRequired, + exportReport: PropTypes.func.isRequired, location: PropTypes.shape({ pathname: PropTypes.string.isRequired, }).isRequired, @@ -78,7 +78,7 @@ class ExportDialog extends PureComponent { } startExport = () => { - const { exportCsv, location } = this.props + const { exportReport, location } = this.props const { currentTargets } = this.state tracker.trackEvent('Export') const target = getTarget(location.pathname) @@ -86,7 +86,7 @@ class ExportDialog extends PureComponent { ? currentTargets : [queryConstants.MENU_POSITIONS_AUDIT] - exportCsv(targets) + exportReport(targets) } toggleTarget = (target) => { diff --git a/src/state/query/actions.js b/src/state/query/actions.js index a30a658dd..b7f17f55f 100644 --- a/src/state/query/actions.js +++ b/src/state/query/actions.js @@ -1,18 +1,18 @@ import types from './constants' /** - * Create an action to export CSV. + * Create an action to export report. * @param {string[]} targets array of export types */ -export function exportCsv(targets) { +export function exportReport(targets) { return { - type: types.EXPORT_CSV, + type: types.EXPORT_REPORT, payload: targets, } } /** - * Create an action to set path to local export CSV folder. + * Create an action to set path to local export folder. * @param {string} path to local export folder */ export function setLocalExportPath(path) { @@ -23,12 +23,12 @@ export function setLocalExportPath(path) { } /** - * Create an action to set remote CSV URN. + * Create an action to set remote report URN. * @param {string} urn to generated report. */ export function setRemoteUrn(urn) { return { - type: types.SET_REMOTE_CSV_URN, + type: types.SET_REMOTE_REPORT_URN, payload: urn, } } @@ -53,9 +53,9 @@ export function setExportEmail(email) { } } -export function setIsCsvExporting(isExporting) { +export function setIsReportExporting(isExporting) { return { - type: types.SET_IS_CSV_EXPORTING, + type: types.SET_IS_REPORT_EXPORTING, payload: isExporting, } } @@ -68,11 +68,11 @@ export function setIsPdfRequired(isPdfRequired) { } export default { - exportCsv, + exportReport, setRemoteUrn, prepareExport, setExportEmail, setIsPdfRequired, - setIsCsvExporting, + setIsReportExporting, setLocalExportPath, } diff --git a/src/state/query/constants.js b/src/state/query/constants.js index ee03bb414..1825684c1 100644 --- a/src/state/query/constants.js +++ b/src/state/query/constants.js @@ -37,10 +37,10 @@ export default { TIME_TYPE_LOCALTIME: 'local', DEFAULT_QUERY_LIMIT: 500, DEFAULT_RANGE: '2w', - EXPORT_CSV: 'BITFINEX/EXPORT/CSV', - 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', + EXPORT_REPORT: 'BITFINEX/EXPORT/REPORT', + SET_LOCAL_EXPORT_PATH: 'BITFINEX/EXPORT/REPORT_FOLDER_PATH', + SET_REMOTE_REPORT_URN: 'BITFINEX/EXPORT/REPORT_REMOTE_URN', + SET_IS_REPORT_EXPORTING: 'BITFINEX/EXPORT/IS_REPORT_EXPORTING', SET_IS_PDF_REQUIRED: 'BITFINEX/EXPORT/IS_PDF_REQUIRED', PREPARE_EXPORT: 'BITFINEX/EXPORT/PREPARE', SET_EXPORT_EMAIL: 'BITFINEX/EMAIL/EXPORT', diff --git a/src/state/query/reducer.js b/src/state/query/reducer.js index 0224a5ff6..3e12f537b 100644 --- a/src/state/query/reducer.js +++ b/src/state/query/reducer.js @@ -6,7 +6,7 @@ const initialState = { exportEmail: '', localExportPath: null, remoteUrn: null, - isCsvExporting: false, + isReportExporting: false, isPDFRequired: true, } @@ -23,15 +23,15 @@ export function queryReducer(state = initialState, action) { ...state, localExportPath: payload || null, } - case types.SET_REMOTE_CSV_URN: + case types.SET_REMOTE_REPORT_URN: return { ...state, remoteUrn: payload || null, } - case types.SET_IS_CSV_EXPORTING: + case types.SET_IS_REPORT_EXPORTING: return { ...state, - isCsvExporting: payload, + isReportExporting: payload, } case types.SET_IS_PDF_REQUIRED: return { diff --git a/src/state/query/saga.js b/src/state/query/saga.js index d6d08acd6..a4d6f34f2 100644 --- a/src/state/query/saga.js +++ b/src/state/query/saga.js @@ -103,33 +103,7 @@ const { MENU_WIN_LOSS, } = types -/** - { - "auth": { - "apiKey": "fake", - "apiSecret": "fake" - }, - "method": "getMultipleCsv", - "params": { - "email": "fake@email.fake", - "multiExport": [ - { - "method": "getTradesCsv", - "symbol": "tBTCUSD", - "end": 1546765168000 - }, - { - "method": "getLedgersCsv", - "symbol": "BTC", - "end": 1546765168000, - "timezone": "America/Los_Angeles" - } - ] - } -} -*/ - -const getMultipleCsv = params => makeFetchCall('getMultipleFile', params) +const getMultipleFile = params => makeFetchCall('getMultipleFile', params) function getSelector(target) { switch (target) { @@ -309,36 +283,36 @@ function* getOptions({ target }) { switch (target) { case MENU_ACCOUNT_BALANCE: - options.method = 'getBalanceHistoryCsv' + options.method = 'getBalanceHistoryFile' break case MENU_AFFILIATES_EARNINGS: - options.method = 'getLedgersCsv' + options.method = 'getLedgersFile' options.category = LEDGERS_CATEGORIES.AFFILIATE_REBATE break case MENU_CANDLES: - options.method = 'getCandlesCsv' + options.method = 'getCandlesFile' break case MENU_CHANGE_LOGS: - options.method = 'getChangeLogsCsv' + options.method = 'getChangeLogsFile' break case MENU_DERIVATIVES: - options.method = 'getStatusMessagesCsv' + options.method = 'getStatusMessagesFile' break case MENU_FCREDIT: - options.method = 'getFundingCreditHistoryCsv' + options.method = 'getFundingCreditHistoryFile' break case MENU_FLOAN: - options.method = 'getFundingLoanHistoryCsv' + options.method = 'getFundingLoanHistoryFile' break case MENU_FOFFER: - options.method = 'getFundingOfferHistoryCsv' + options.method = 'getFundingOfferHistoryFile' break case MENU_FPAYMENT: - options.method = 'getLedgersCsv' + options.method = 'getLedgersFile' options.category = LEDGERS_CATEGORIES.FUNDING_PAYMENT break case MENU_INVOICES: - options.method = 'getPayInvoiceListCsv' + options.method = 'getPayInvoiceListFile' break case MENU_LEDGERS: options.method = 'getLedgersFile' @@ -346,77 +320,77 @@ function* getOptions({ target }) { options.category = yield select(getLedgersCategory) break case MENU_LOAN_REPORT: - options.method = 'getPerformingLoanCsv' + options.method = 'getPerformingLoanFile' break case MENU_LOGINS: - options.method = 'getLoginsCsv' + options.method = 'getLoginsFile' break case MENU_ORDERS: - options.method = 'getOrdersCsv' + options.method = 'getOrdersFile' break case MENU_ORDER_TRADES: - options.method = 'getOrderTradesCsv' + options.method = 'getOrderTradesFile' break case MENU_SPAYMENTS: - options.method = 'getLedgersCsv' + options.method = 'getLedgersFile' options.category = LEDGERS_CATEGORIES.STAKING_PAYMENT break case MENU_TICKERS: - options.method = 'getTickersHistoryCsv' + options.method = 'getTickersHistoryFile' break case MENU_TRADES: - options.method = 'getTradesCsv' + options.method = 'getTradesFile' break case MENU_MOVEMENTS: - options.method = 'getMovementsCsv' + options.method = 'getMovementsFile' break case MENU_POSITIONS: - options.method = 'getPositionsHistoryCsv' + options.method = 'getPositionsHistoryFile' break case MENU_POSITIONS_ACTIVE: - options.method = 'getActivePositionsCsv' + options.method = 'getActivePositionsFile' break case MENU_POSITIONS_AUDIT: - options.method = 'getPositionsAuditCsv' + options.method = 'getPositionsAuditFile' break case MENU_PUBLIC_FUNDING: - options.method = 'getPublicTradesCsv' + options.method = 'getPublicTradesFile' break case MENU_PUBLIC_TRADES: - options.method = 'getPublicTradesCsv' + options.method = 'getPublicTradesFile' break case MENU_SNAPSHOTS: - options.method = 'getFullSnapshotReportCsv' + options.method = 'getFullSnapshotReportFile' break case MENU_TAX_REPORT: options.method = 'getFullTaxReportFile' break case MENU_TRADED_VOLUME: - options.method = 'getTradedVolumeCsv' + options.method = 'getTradedVolumeFile' break case MENU_FEES_REPORT: - options.method = 'getTotalFeesReportCsv' + options.method = 'getTotalFeesReportFile' break case MENU_WALLETS: - options.method = 'getWalletsCsv' + options.method = 'getWalletsFile' break case MENU_WEIGHTED_AVERAGES: - options.method = 'getWeightedAveragesReportCsv' + options.method = 'getWeightedAveragesReportFile' break case MENU_WIN_LOSS: options.method = isVsAccountBalanceSelected - ? 'getWinLossVSAccountBalanceCsv' - : 'getWinLossCsv' + ? 'getWinLossVSAccountBalanceFile' + : 'getWinLossFile' break default: - options.method = 'getLedgersCsv' + options.method = 'getLedgersFile' break } return options } -function* exportCSV({ payload: targets }) { +function* exportReport({ payload: targets }) { try { const exportEmail = yield select(getExportEmail) const multiExport = [] @@ -448,15 +422,15 @@ function* exportCSV({ payload: targets }) { } if (showFrameworkMode) { - yield put(actions.setIsCsvExporting(true)) + yield put(actions.setIsReportExporting(true)) } - const { result, error } = yield call(getMultipleCsv, params) + const { result, error } = yield call(getMultipleFile, params) if (result) { - const { localCsvFolderPath, remoteCsvUrn = null } = result - yield put(actions.setRemoteUrn(remoteCsvUrn)) - yield put(actions.setLocalExportPath(localCsvFolderPath)) + const { localReportFolderPath, remoteReportUrn = null } = result + yield put(actions.setRemoteUrn(remoteReportUrn)) + yield put(actions.setLocalExportPath(localReportFolderPath)) if (!showFrameworkMode) { yield put(toggleExportDialog()) yield put(toggleExportSuccessDialog()) @@ -465,7 +439,7 @@ function* exportCSV({ payload: targets }) { if (error) { if (showFrameworkMode) { - yield put(actions.setIsCsvExporting(false)) + yield put(actions.setIsReportExporting(false)) } yield put(updateErrorStatus({ id: 'status.fail', @@ -475,7 +449,7 @@ function* exportCSV({ payload: targets }) { } } catch (fail) { if (showFrameworkMode) { - yield put(actions.setIsCsvExporting(false)) + yield put(actions.setIsReportExporting(false)) } yield put(updateErrorStatus({ id: 'status.request.error', @@ -510,5 +484,5 @@ function* prepareExport() { export default function* exportSaga() { yield takeLatest(types.PREPARE_EXPORT, prepareExport) - yield takeLatest(types.EXPORT_CSV, exportCSV) + yield takeLatest(types.EXPORT_REPORT, exportReport) } diff --git a/src/state/query/selectors.js b/src/state/query/selectors.js index ae1a35d4f..3090741f8 100644 --- a/src/state/query/selectors.js +++ b/src/state/query/selectors.js @@ -3,14 +3,14 @@ export const getQuery = state => state.query 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 getIsReportExporting = state => getQuery(state)?.isReportExporting ?? false export const getIsPdfExportRequired = state => getQuery(state)?.isPDFRequired ?? false export default { getQuery, getRemoteUrn, getExportEmail, - getIsCsvExporting, + getIsReportExporting, getLocalExportPath, getIsPdfExportRequired, } diff --git a/src/state/ws/constants.js b/src/state/ws/constants.js index bf8edaf96..ed6e01a8c 100644 --- a/src/state/ws/constants.js +++ b/src/state/ws/constants.js @@ -4,7 +4,7 @@ export default { WS_NET_ERROR: 'ws_emitENetError', WS_NET_RESUMED: 'ws_emitENetResumed', WS_BFX_TOKEN_AUTH_REQUIRED: 'ws_emitBfxUnamePwdAuthRequire', - WS_CSV_GENERATION_COMPLETED: 'ws_emitCsvGenerationCompletedToOne', + WS_REPORT_GENERATION_COMPLETED: 'ws_emitReportFileGenerationCompletedToOne', WS_MAINTENANCE_TURNED_ON: 'ws_emitMaintenanceTurnedOn', WS_MAINTENANCE_TURNED_OFF: 'ws_emitMaintenanceTurnedOff', } diff --git a/src/state/ws/saga.js b/src/state/ws/saga.js index 9df56c7be..7b6c0baf0 100644 --- a/src/state/ws/saga.js +++ b/src/state/ws/saga.js @@ -3,7 +3,7 @@ import { call, put, takeLatest } from 'redux-saga/effects' import { initSync } from 'state/sync/saga' import { authExpired } from 'state/auth/actions' import { updateSyncStatus } from 'state/sync/actions' -import { setIsCsvExporting } from 'state/query/actions' +import { setIsReportExporting } from 'state/query/actions' import { updateStatus, updateWarningStatus } from 'state/status/actions' import { toggleExportDialog, @@ -34,8 +34,8 @@ function* handleTokenAuthRequired() { yield put(authExpired()) } -function* handleCsvGenerationCompleted() { - yield put(setIsCsvExporting(false)) +function* handleReportGenerationCompleted() { + yield put(setIsReportExporting(false)) yield put(toggleExportDialog()) yield put(toggleExportSuccessDialog()) } @@ -55,5 +55,5 @@ export default function* wsSaga() { yield takeLatest(types.WS_BFX_TOKEN_AUTH_REQUIRED, handleTokenAuthRequired) yield takeLatest(types.WS_MAINTENANCE_TURNED_ON, handleMaintenanceTurnedOn) yield takeLatest(types.WS_MAINTENANCE_TURNED_OFF, handleMaintenanceTurnedOff) - yield takeLatest(types.WS_CSV_GENERATION_COMPLETED, handleCsvGenerationCompleted) + yield takeLatest(types.WS_REPORT_GENERATION_COMPLETED, handleReportGenerationCompleted) }