diff --git a/src/pages/wallet/WalletStatementPage.tsx b/src/pages/wallet/WalletStatementPage.tsx index 948225191097a..0fbde460bbf63 100644 --- a/src/pages/wallet/WalletStatementPage.tsx +++ b/src/pages/wallet/WalletStatementPage.tsx @@ -11,6 +11,8 @@ import useNetwork from '@hooks/useNetwork'; import useOnyx from '@hooks/useOnyx'; import usePrevious from '@hooks/usePrevious'; import useThemePreference from '@hooks/useThemePreference'; +import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL'; +import * as Browser from '@libs/Browser'; import {getOldDotURLFromEnvironment} from '@libs/Environment/Environment'; import fileDownload from '@libs/fileDownload'; import Navigation from '@libs/Navigation/Navigation'; @@ -18,6 +20,7 @@ import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavig import addTrailingForwardSlash from '@libs/UrlUtils'; import type {WalletStatementNavigatorParamList} from '@navigation/types'; import {generateStatementPDF} from '@userActions/User'; +import {emailSelector} from '@selectors/Session'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type SCREENS from '@src/SCREENS'; @@ -26,6 +29,7 @@ type WalletStatementPageProps = PlatformStackScreenProps setIsDownloading(false)); + const pdfURL = `${baseURL}secure?secureType=pdfreport&filename=${encodeURIComponent(fileName)}&downloadName=${encodeURIComponent(downloadFileName)}&email=${encodeURIComponent( + currentUserLogin, + )}`; + const pdfURLWithAuth = addEncryptedAuthTokenToURL(pdfURL, true); + fileDownload(translate, pdfURLWithAuth, downloadFileName, '', Browser.isMobileSafari()).finally(() => setIsDownloading(false)); return; } generateStatementPDF(yearMonth); - }, [baseURL, isWalletStatementGenerating, translate, walletStatement, yearMonth]); + }, [baseURL, currentUserLogin, isWalletStatementGenerating, translate, walletStatement, yearMonth]); // eslint-disable-next-line rulesdir/prefer-early-return useEffect(() => {