Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Add UpdateMoneyRequestDistance command #34107

Merged
merged 6 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ function updateMoneyRequestMerchant(transactionID, transactionThreadReportID, va
}

/**
* Updates the created date of a money request
* Updates the tag of a money request
*
* @param {String} transactionID
* @param {Number} transactionThreadReportID
Expand All @@ -1183,6 +1183,21 @@ function updateMoneyRequestTag(transactionID, transactionThreadReportID, tag) {
API.write('UpdateMoneyRequestTag', params, onyxData);
}

/**
* Updates the waypoints of a distance money request
*
* @param {String} transactionID
* @param {Number} transactionThreadReportID
* @param {Object} waypoints
*/
function updateMoneyRequestDistance(transactionID, transactionThreadReportID, waypoints) {
const transactionChanges = {
waypoints,
};
const {params, onyxData} = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, true);
API.write('UpdateMoneyRequestDistance', params, onyxData);
}

/**
* Updates the category of a money request
*
Expand Down Expand Up @@ -3734,6 +3749,7 @@ export {
updateMoneyRequestBillable,
updateMoneyRequestMerchant,
updateMoneyRequestTag,
updateMoneyRequestDistance,
updateMoneyRequestCategory,
updateMoneyRequestAmountAndCurrency,
updateMoneyRequestDescription,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/EditRequestDistancePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function EditRequestDistancePage({report, route, transaction, transactionBackup}
return;
}

IOU.editMoneyRequest(transaction, report.reportID, {waypoints});
IOU.updateMoneyRequestDistance(transaction.transactionID, report.reportID, waypoints);

// If the client is offline, then the modal can be closed as well (because there are no errors or other feedback to show them
// until they come online again and sync with the server).
Expand Down
Loading