@@ -90,9 +90,6 @@ const propTypes = {
90
90
91
91
/** Denotes whether it is a workspace avatar or not */
92
92
isWorkspaceAvatar : PropTypes . bool ,
93
-
94
- /** Whether it is a receipt attachment or not */
95
- isReceiptAttachment : PropTypes . bool ,
96
93
} ;
97
94
98
95
const defaultProps = {
@@ -110,7 +107,6 @@ const defaultProps = {
110
107
onModalHide : ( ) => { } ,
111
108
onCarouselAttachmentChange : ( ) => { } ,
112
109
isWorkspaceAvatar : false ,
113
- isReceiptAttachment : false ,
114
110
} ;
115
111
116
112
function AttachmentModal ( props ) {
@@ -122,6 +118,7 @@ function AttachmentModal(props) {
122
118
const [ isAttachmentInvalid , setIsAttachmentInvalid ] = useState ( false ) ;
123
119
const [ isDeleteReceiptConfirmModalVisible , setIsDeleteReceiptConfirmModalVisible ] = useState ( false ) ;
124
120
const [ isAuthTokenRequired , setIsAuthTokenRequired ] = useState ( props . isAuthTokenRequired ) ;
121
+ const [ isAttachmentReceipt , setIsAttachmentReceipt ] = useState ( null ) ;
125
122
const [ attachmentInvalidReasonTitle , setAttachmentInvalidReasonTitle ] = useState ( '' ) ;
126
123
const [ attachmentInvalidReason , setAttachmentInvalidReason ] = useState ( null ) ;
127
124
const [ source , setSource ] = useState ( props . source ) ;
@@ -157,6 +154,7 @@ function AttachmentModal(props) {
157
154
( attachment ) => {
158
155
setSource ( attachment . source ) ;
159
156
setFile ( attachment . file ) ;
157
+ setIsAttachmentReceipt ( attachment . isReceipt ) ;
160
158
setIsAuthTokenRequired ( attachment . isAuthTokenRequired ) ;
161
159
onCarouselAttachmentChange ( attachment ) ;
162
160
} ,
@@ -359,7 +357,7 @@ function AttachmentModal(props) {
359
357
const sourceForAttachmentView = props . source || source ;
360
358
361
359
const threeDotsMenuItems = useMemo ( ( ) => {
362
- if ( ! props . isReceiptAttachment || ! props . parentReport || ! props . parentReportActions ) {
360
+ if ( ! isAttachmentReceipt || ! props . parentReport || ! props . parentReportActions ) {
363
361
return [ ] ;
364
362
}
365
363
const menuItems = [ ] ;
@@ -394,17 +392,17 @@ function AttachmentModal(props) {
394
392
}
395
393
return menuItems ;
396
394
// eslint-disable-next-line react-hooks/exhaustive-deps
397
- } , [ props . isReceiptAttachment , props . parentReport , props . parentReportActions , props . policy , props . transaction , file ] ) ;
395
+ } , [ isAttachmentReceipt , props . parentReport , props . parentReportActions , props . policy , props . transaction , file ] ) ;
398
396
399
397
// There are a few things that shouldn't be set until we absolutely know if the file is a receipt or an attachment.
400
- // props.isReceiptAttachment will be null until its certain what the file is, in which case it will then be true|false.
398
+ // isAttachmentReceipt will be null until its certain what the file is, in which case it will then be true|false.
401
399
let headerTitle = props . headerTitle ;
402
400
let shouldShowDownloadButton = false ;
403
401
let shouldShowThreeDotsButton = false ;
404
- if ( ! _ . isNull ( props . isReceiptAttachment ) ) {
405
- headerTitle = translate ( props . isReceiptAttachment ? 'common.receipt' : 'common.attachment' ) ;
406
- shouldShowDownloadButton = props . allowDownload && isDownloadButtonReadyToBeShown && ! props . isReceiptAttachment && ! isOffline ;
407
- shouldShowThreeDotsButton = props . isReceiptAttachment && isModalOpen ;
402
+ if ( ! _ . isNull ( isAttachmentReceipt ) ) {
403
+ headerTitle = translate ( isAttachmentReceipt ? 'common.receipt' : 'common.attachment' ) ;
404
+ shouldShowDownloadButton = props . allowDownload && isDownloadButtonReadyToBeShown && ! isAttachmentReceipt && ! isOffline ;
405
+ shouldShowThreeDotsButton = isAttachmentReceipt && isModalOpen ;
408
406
}
409
407
410
408
return (
@@ -445,7 +443,7 @@ function AttachmentModal(props) {
445
443
shouldOverlay
446
444
/>
447
445
< View style = { styles . imageModalImageCenterContainer } >
448
- { ! _ . isEmpty ( props . report ) && ! props . isReceiptAttachment ? (
446
+ { ! _ . isEmpty ( props . report ) ? (
449
447
< AttachmentCarousel
450
448
report = { props . report }
451
449
onNavigate = { onNavigate }
@@ -488,7 +486,7 @@ function AttachmentModal(props) {
488
486
) }
489
487
</ SafeAreaConsumer >
490
488
) }
491
- { props . isReceiptAttachment && (
489
+ { isAttachmentReceipt && (
492
490
< ConfirmModal
493
491
title = { translate ( 'receipt.deleteReceipt' ) }
494
492
isVisible = { isDeleteReceiptConfirmModalVisible }
@@ -501,7 +499,7 @@ function AttachmentModal(props) {
501
499
/>
502
500
) }
503
501
</ Modal >
504
- { ! props . isReceiptAttachment && (
502
+ { ! isAttachmentReceipt && (
505
503
< ConfirmModal
506
504
title = { attachmentInvalidReasonTitle ? translate ( attachmentInvalidReasonTitle ) : '' }
507
505
onConfirm = { closeConfirmModal }
0 commit comments