Skip to content

Commit

Permalink
Merge pull request #6992 from Expensify/marcaaron-improveSendMoneyMethod
Browse files Browse the repository at this point in the history
Return promise in payIOUReport / Fix AdditionalDetailsStep
  • Loading branch information
Jag96 authored Jan 4, 2022
2 parents 667570c + 8b38d0a commit 6e9e7a3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
15 changes: 6 additions & 9 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ function buildPayPalPaymentUrl(amount, submitterPayPalMeAddress, currency) {
* @param {String} [params.requestorPhoneNumber] - used for Venmo
* @param {String} [params.requestorPayPalMeAddress]
* @param {String} [params.newIOUReportDetails] - Extra details required only for send money flow
* @param {Boolean} [params.shouldRedirectToChatReport]
*
* @return {Promise}
*/
function payIOUReport({
chatReportID,
Expand All @@ -260,7 +261,6 @@ function payIOUReport({
requestorPhoneNumber,
requestorPayPalMeAddress,
newIOUReportDetails,
shouldRedirectToChatReport = false,
}) {
Onyx.merge(ONYXKEYS.IOU, {loading: true, error: false});

Expand All @@ -278,7 +278,7 @@ function payIOUReport({
url = buildVenmoPaymentURL(amount, requestorPhoneNumber);
}

asyncOpenURL(payIOUPromise
const promiseWithHandlers = payIOUPromise
.then((response) => {
if (response.jsonCode !== 200) {
throw new Error(response.message);
Expand All @@ -304,12 +304,9 @@ function payIOUReport({
})
.finally(() => {
Onyx.merge(ONYXKEYS.IOU, {loading: false});

if (shouldRedirectToChatReport) {
Navigation.navigate(ROUTES.REPORT);
}
}),
url);
});
asyncOpenURL(promiseWithHandlers, url);
return promiseWithHandlers;
}

export {
Expand Down
18 changes: 11 additions & 7 deletions src/pages/EnablePayments/AdditionalDetailsStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,17 @@ class AdditionalDetailsStep extends React.Component {
<AddressSearch
label={this.props.translate(this.fieldNameTranslationKeys.addressStreet)}
value={this.state.addressStreet}
onChangeText={(fieldName, value) => {
if (fieldName === 'addressZipCode') {
this.clearErrorAndSetValue('addressZip', value);
return;
}

this.clearErrorAndSetValue(fieldName, value);
onChange={(values) => {
const renamedFields = {
street: 'addressStreet',
state: 'addressState',
zipCode: 'addressZip',
city: 'addressCity',
};
_.each(values, (value, inputKey) => {
const renamedInputKey = lodashGet(renamedFields, inputKey, inputKey);
this.clearErrorAndSetValue(renamedInputKey, value);
});
}}
errorText={this.getErrorText('addressStreet')}
/>
Expand Down
6 changes: 4 additions & 2 deletions src/pages/iou/IOUModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,10 @@ class IOUModal extends Component {
requestorPhoneNumber: this.state.participants[0].phoneNumber,
comment,
newIOUReportDetails,
shouldRedirectToChatReport: true,
});
})
.finally(() => {
Navigation.navigate(ROUTES.REPORT);
});
}

/**
Expand Down

0 comments on commit 6e9e7a3

Please sign in to comment.