From 9e54eb8ad65ca76027e273b8ce73f1d67519ff38 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 30 Sep 2024 18:53:59 +0800 Subject: [PATCH 1/2] fix missing header in scan page --- .../request/step/IOURequestStepScan/index.native.tsx | 11 ++++++----- .../iou/request/step/IOURequestStepScan/index.tsx | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 05ebdc1dfc6..46e5a2727c8 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -63,6 +63,7 @@ function IOURequestStepScan({ physicalDevices: ['wide-angle-camera', 'ultra-wide-angle-camera'], }); + const isEditing = action === CONST.IOU.ACTION.EDIT; const hasFlash = !!device?.hasFlash; const camera = useRef(null); const [flash, setFlash] = useState(false); @@ -411,9 +412,9 @@ function IOURequestStepScan({ // Store the receipt on the transaction object in Onyx // On Android devices, fetching blob for a file with name containing spaces fails to retrieve the type of file. // So, let us also save the file type in receipt for later use during blob fetch - IOU.setMoneyRequestReceipt(transactionID, file?.uri ?? '', file.name ?? '', action !== CONST.IOU.ACTION.EDIT, file.type); + IOU.setMoneyRequestReceipt(transactionID, file?.uri ?? '', file.name ?? '', !isEditing, file.type); - if (action === CONST.IOU.ACTION.EDIT) { + if (isEditing) { updateScanAndNavigate(file, file?.uri ?? ''); return; } @@ -448,10 +449,10 @@ function IOURequestStepScan({ .then((photo: PhotoFile) => { // Store the receipt on the transaction object in Onyx const source = getPhotoSource(photo.path); - IOU.setMoneyRequestReceipt(transactionID, source, photo.path, action !== CONST.IOU.ACTION.EDIT); + IOU.setMoneyRequestReceipt(transactionID, source, photo.path, !isEditing); FileUtils.readFileAsync(source, photo.path, (file) => { - if (action === CONST.IOU.ACTION.EDIT) { + if (isEditing) { updateScanAndNavigate(file, source); return; } @@ -476,7 +477,7 @@ function IOURequestStepScan({ includeSafeAreaPaddingBottom headerTitle={translate('common.receipt')} onBackButtonPress={navigateBack} - shouldShowWrapper={!!backTo} + shouldShowWrapper={!!backTo || isEditing} testID={IOURequestStepScan.displayName} > {isLoadingReceipt && } diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 58f20b28193..1d7ff80542b 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -86,6 +86,7 @@ function IOURequestStepScan({ const tabIndex = 1; const isTabActive = useTabNavigatorFocus({tabIndex}); + const isEditing = action === CONST.IOU.ACTION.EDIT; const defaultTaxCode = TransactionUtils.getDefaultTaxCode(policy, transaction); const transactionTaxCode = (transaction?.taxCode ? transaction?.taxCode : defaultTaxCode) ?? ''; const transactionTaxAmount = transaction?.taxAmount ?? 0; @@ -444,9 +445,9 @@ function IOURequestStepScan({ // Store the receipt on the transaction object in Onyx const source = URL.createObjectURL(file as Blob); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - IOU.setMoneyRequestReceipt(transactionID, source, file.name || '', action !== CONST.IOU.ACTION.EDIT); + IOU.setMoneyRequestReceipt(transactionID, source, file.name || '', !isEditing); - if (action === CONST.IOU.ACTION.EDIT) { + if (isEditing) { updateScanAndNavigate(file, source); return; } @@ -478,9 +479,9 @@ function IOURequestStepScan({ const filename = `receipt_${Date.now()}.png`; const file = FileUtils.base64ToFile(imageBase64 ?? '', filename); const source = URL.createObjectURL(file); - IOU.setMoneyRequestReceipt(transactionID, source, file.name, action !== CONST.IOU.ACTION.EDIT); + IOU.setMoneyRequestReceipt(transactionID, source, file.name, !isEditing); - if (action === CONST.IOU.ACTION.EDIT) { + if (isEditing) { updateScanAndNavigate(file, source); return; } @@ -695,7 +696,7 @@ function IOURequestStepScan({ {(isDraggingOverWrapper) => ( From 44b5b734fe4ec45bd561479b80b6d161f2ed2d06 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 30 Sep 2024 22:37:42 +0800 Subject: [PATCH 2/2] lint --- src/pages/iou/request/step/IOURequestStepScan/index.native.tsx | 2 +- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 46e5a2727c8..f6b4c44c80a 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -465,7 +465,7 @@ function IOURequestStepScan({ showCameraAlert(); Log.warn('Error taking photo', error); }); - }, [cameraPermissionStatus, didCapturePhoto, flash, hasFlash, user?.isMutedAllSounds, translate, transactionID, action, navigateToConfirmationStep, updateScanAndNavigate]); + }, [isEditing, cameraPermissionStatus, didCapturePhoto, flash, hasFlash, user?.isMutedAllSounds, translate, transactionID, navigateToConfirmationStep, updateScanAndNavigate]); // Wait for camera permission status to render if (cameraPermissionStatus == null) { diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 1d7ff80542b..19a82b9011e 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -487,7 +487,7 @@ function IOURequestStepScan({ } navigateToConfirmationStep(file, source); - }, [action, transactionID, updateScanAndNavigate, navigateToConfirmationStep, requestCameraPermission]); + }, [isEditing, transactionID, updateScanAndNavigate, navigateToConfirmationStep, requestCameraPermission]); const clearTorchConstraints = useCallback(() => { if (!trackRef.current) {