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