Skip to content

Commit 29ba3f2

Browse files
committed
update WalletStatementPage to use new baseURL
1 parent c111f2d commit 29ba3f2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/pages/wallet/WalletStatementPage.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@ import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOffli
77
import HeaderWithBackButton from '@components/HeaderWithBackButton';
88
import ScreenWrapper from '@components/ScreenWrapper';
99
import WalletStatementModal from '@components/WalletStatementModal';
10+
import type {EnvironmentValue} from '@components/withEnvironment';
11+
import useEnvironment from '@hooks/useEnvironment';
1012
import useLocalize from '@hooks/useLocalize';
1113
import useNetwork from '@hooks/useNetwork';
1214
import usePrevious from '@hooks/usePrevious';
1315
import useThemePreference from '@hooks/useThemePreference';
1416
import DateUtils from '@libs/DateUtils';
17+
import {getOldDotURLFromEnvironment} from '@libs/Environment/Environment';
1518
import fileDownload from '@libs/fileDownload';
1619
import Navigation from '@libs/Navigation/Navigation';
20+
import {addTrailingForwardSlash} from '@libs/Url';
1721
import type {WalletStatementNavigatorParamList} from '@navigation/types';
1822
import * as User from '@userActions/User';
19-
import CONFIG from '@src/CONFIG';
2023
import CONST from '@src/CONST';
2124
import ONYXKEYS from '@src/ONYXKEYS';
2225
import type SCREENS from '@src/SCREENS';
@@ -31,8 +34,11 @@ function WalletStatementPage({route}: WalletStatementPageProps) {
3134
const prevIsWalletStatementGenerating = usePrevious(isWalletStatementGenerating);
3235
const [isDownloading, setIsDownloading] = useState(isWalletStatementGenerating);
3336
const {translate, preferredLocale} = useLocalize();
37+
const {environment} = useEnvironment();
3438
const {isOffline} = useNetwork();
3539

40+
const baseURL = addTrailingForwardSlash(getOldDotURLFromEnvironment(environment));
41+
3642
useEffect(() => {
3743
const currentYearMonth = format(new Date(), CONST.DATE.YEAR_MONTH_FORMAT);
3844
if (!yearMonth || yearMonth.length !== 6 || yearMonth > currentYearMonth) {
@@ -55,13 +61,13 @@ function WalletStatementPage({route}: WalletStatementPageProps) {
5561
// We already have a file URL for this statement, so we can download it immediately
5662
const downloadFileName = `Expensify_Statement_${yearMonth}.pdf`;
5763
const fileName = walletStatement[yearMonth];
58-
const pdfURL = `${CONFIG.EXPENSIFY.EXPENSIFY_URL}secure?secureType=pdfreport&filename=${fileName}&downloadName=${downloadFileName}`;
64+
const pdfURL = `${baseURL}secure?secureType=pdfreport&filename=${fileName}&downloadName=${downloadFileName}`;
5965
fileDownload(pdfURL, downloadFileName).finally(() => setIsDownloading(false));
6066
return;
6167
}
6268

6369
User.generateStatementPDF(yearMonth);
64-
}, [isWalletStatementGenerating, walletStatement, yearMonth]);
70+
}, [baseURL, isWalletStatementGenerating, walletStatement, yearMonth]);
6571

6672
// eslint-disable-next-line rulesdir/prefer-early-return
6773
useEffect(() => {
@@ -79,7 +85,7 @@ function WalletStatementPage({route}: WalletStatementPageProps) {
7985
const month = yearMonth?.substring(4) || getMonth(new Date());
8086
const monthName = format(new Date(Number(year), Number(month) - 1), CONST.DATE.MONTH_FORMAT);
8187
const title = translate('statementPage.title', {year, monthName});
82-
const url = `${CONFIG.EXPENSIFY.EXPENSIFY_URL}statement.php?period=${yearMonth}${themePreference === CONST.THEME.DARK ? '&isDarkMode=true' : ''}`;
88+
const url = `${baseURL}statement.php?period=${yearMonth}${themePreference === CONST.THEME.DARK ? '&isDarkMode=true' : ''}`;
8389

8490
return (
8591
<ScreenWrapper

0 commit comments

Comments
 (0)