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