@@ -7,16 +7,18 @@ import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOffli
7
7
import HeaderWithBackButton from '@components/HeaderWithBackButton' ;
8
8
import ScreenWrapper from '@components/ScreenWrapper' ;
9
9
import WalletStatementModal from '@components/WalletStatementModal' ;
10
+ import useEnvironment from '@hooks/useEnvironment' ;
10
11
import useLocalize from '@hooks/useLocalize' ;
11
12
import useNetwork from '@hooks/useNetwork' ;
12
13
import usePrevious from '@hooks/usePrevious' ;
13
14
import useThemePreference from '@hooks/useThemePreference' ;
14
15
import DateUtils from '@libs/DateUtils' ;
16
+ import { getOldDotURLFromEnvironment } from '@libs/Environment/Environment' ;
15
17
import fileDownload from '@libs/fileDownload' ;
16
18
import Navigation from '@libs/Navigation/Navigation' ;
19
+ import { addTrailingForwardSlash } from '@libs/Url' ;
17
20
import type { WalletStatementNavigatorParamList } from '@navigation/types' ;
18
21
import * as User from '@userActions/User' ;
19
- import CONFIG from '@src/CONFIG' ;
20
22
import CONST from '@src/CONST' ;
21
23
import ONYXKEYS from '@src/ONYXKEYS' ;
22
24
import type SCREENS from '@src/SCREENS' ;
@@ -31,8 +33,11 @@ function WalletStatementPage({route}: WalletStatementPageProps) {
31
33
const prevIsWalletStatementGenerating = usePrevious ( isWalletStatementGenerating ) ;
32
34
const [ isDownloading , setIsDownloading ] = useState ( isWalletStatementGenerating ) ;
33
35
const { translate, preferredLocale} = useLocalize ( ) ;
36
+ const { environment} = useEnvironment ( ) ;
34
37
const { isOffline} = useNetwork ( ) ;
35
38
39
+ const baseURL = addTrailingForwardSlash ( getOldDotURLFromEnvironment ( environment ) ) ;
40
+
36
41
useEffect ( ( ) => {
37
42
const currentYearMonth = format ( new Date ( ) , CONST . DATE . YEAR_MONTH_FORMAT ) ;
38
43
if ( ! yearMonth || yearMonth . length !== 6 || yearMonth > currentYearMonth ) {
@@ -55,13 +60,13 @@ function WalletStatementPage({route}: WalletStatementPageProps) {
55
60
// We already have a file URL for this statement, so we can download it immediately
56
61
const downloadFileName = `Expensify_Statement_${ yearMonth } .pdf` ;
57
62
const fileName = walletStatement [ yearMonth ] ;
58
- const pdfURL = `${ CONFIG . EXPENSIFY . EXPENSIFY_URL } secure?secureType=pdfreport&filename=${ fileName } &downloadName=${ downloadFileName } ` ;
63
+ const pdfURL = `${ baseURL } secure?secureType=pdfreport&filename=${ fileName } &downloadName=${ downloadFileName } ` ;
59
64
fileDownload ( pdfURL , downloadFileName ) . finally ( ( ) => setIsDownloading ( false ) ) ;
60
65
return ;
61
66
}
62
67
63
68
User . generateStatementPDF ( yearMonth ) ;
64
- } , [ isWalletStatementGenerating , walletStatement , yearMonth ] ) ;
69
+ } , [ baseURL , isWalletStatementGenerating , walletStatement , yearMonth ] ) ;
65
70
66
71
// eslint-disable-next-line rulesdir/prefer-early-return
67
72
useEffect ( ( ) => {
@@ -79,7 +84,7 @@ function WalletStatementPage({route}: WalletStatementPageProps) {
79
84
const month = yearMonth ?. substring ( 4 ) || getMonth ( new Date ( ) ) ;
80
85
const monthName = format ( new Date ( Number ( year ) , Number ( month ) - 1 ) , CONST . DATE . MONTH_FORMAT ) ;
81
86
const title = translate ( 'statementPage.title' , { year, monthName} ) ;
82
- const url = `${ CONFIG . EXPENSIFY . EXPENSIFY_URL } statement.php?period=${ yearMonth } ${ themePreference === CONST . THEME . DARK ? '&isDarkMode=true' : '' } ` ;
87
+ const url = `${ baseURL } statement.php?period=${ yearMonth } ${ themePreference === CONST . THEME . DARK ? '&isDarkMode=true' : '' } ` ;
83
88
84
89
return (
85
90
< ScreenWrapper
0 commit comments