Skip to content

Commit

Permalink
refactor props
Browse files Browse the repository at this point in the history
  • Loading branch information
luacmartins committed Sep 15, 2023
1 parent 164b129 commit b81a159
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/pages/EditRequestReceiptPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function EditRequestReceiptPage({route, transactionID}) {
<ReceiptSelector
route={route}
transactionID={transactionID}
isReplacingReceipt
/>
</DragAndDropProvider>
</ScreenWrapper>
Expand Down
6 changes: 1 addition & 5 deletions src/pages/iou/ReceiptSelector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ const propTypes = {
/** Holds data related to Money Request view state, rather than the underlying Money Request data. */
iou: iouPropTypes,

/** Whether the user is replacing the receipt */
isReplacingReceipt: PropTypes.bool,

/** The id of the transaction we're editing */
transactionID: PropTypes.string,
};
Expand All @@ -64,7 +61,6 @@ const defaultProps = {
},
report: {},
iou: iouDefaultProps,
isReplacingReceipt: false,
transactionID: '',
};

Expand Down Expand Up @@ -93,7 +89,7 @@ function ReceiptSelector(props) {
const filePath = URL.createObjectURL(file);
IOU.setMoneyRequestReceipt(filePath, file.name);

if (props.isReplacingReceipt) {
if (props.transactionID) {
IOU.replaceReceipt(props.transactionID, file, filePath);
Navigation.dismissModal();
return;
Expand Down
12 changes: 4 additions & 8 deletions src/pages/iou/ReceiptSelector/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,13 @@ const propTypes = {
/** Holds data related to Money Request view state, rather than the underlying Money Request data. */
iou: iouPropTypes,

/** Whether the user is replacing the receipt */
isReplacingReceipt: PropTypes.bool,

/** The id of the transaction we're editing */
transactionID: PropTypes.string,
};

const defaultProps = {
report: {},
iou: iouDefaultProps,
isReplacingReceipt: false,
transactionID: '',
};

Expand Down Expand Up @@ -83,7 +79,7 @@ function getImagePickerOptions(type) {
};
}

function ReceiptSelector({route, report, iou, isReplacingReceipt, transactionID}) {
function ReceiptSelector({route, report, iou, transactionID}) {
const devices = useCameraDevices('wide-angle-camera');
const device = devices.back;

Expand Down Expand Up @@ -206,7 +202,7 @@ function ReceiptSelector({route, report, iou, isReplacingReceipt, transactionID}
.then((photo) => {
IOU.setMoneyRequestReceipt(`file://${photo.path}`, photo.path);

if (isReplacingReceipt) {
if (transactionID) {
IOU.replaceReceipt(transactionID, photo, `file://${photo.path}`);
Navigation.dismissModal();
return;
Expand All @@ -218,7 +214,7 @@ function ReceiptSelector({route, report, iou, isReplacingReceipt, transactionID}
showCameraAlert();
Log.warn('Error taking photo', error);
});
}, [flash, iouType, iou, report, reportID, translate, transactionID, isReplacingReceipt]);
}, [flash, iouType, iou, report, reportID, translate, transactionID]);

CameraPermission.getCameraPermissionStatus().then((permissionStatus) => {
setPermissions(permissionStatus);
Expand Down Expand Up @@ -278,7 +274,7 @@ function ReceiptSelector({route, report, iou, isReplacingReceipt, transactionID}
.then((receiptImage) => {
IOU.setMoneyRequestReceipt(receiptImage[0].uri, receiptImage[0].fileName);

if (isReplacingReceipt) {
if (transactionID) {
IOU.replaceReceipt(transactionID, receiptImage, receiptImage[0].uri);
Navigation.dismissModal();
return;
Expand Down

0 comments on commit b81a159

Please sign in to comment.