Skip to content

Commit

Permalink
Fix comments, propTypes, and JSDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
youssef-lr committed Dec 5, 2022
1 parent b7c2ac9 commit c4492d2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/ReportActionItem/IOUAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const propTypes = {
/** The associated chatReport */
chatReportID: PropTypes.string.isRequired,

/** The associated chatReport */
iouReportID: PropTypes.string.isRequired,

/** Is this IOUACTION the most recent? */
isMostRecentIOUReportAction: PropTypes.bool.isRequired,

Expand All @@ -49,6 +46,9 @@ const propTypes = {
/** Whether the IOU is hovered so we can modify its style */
isHovered: PropTypes.bool,

network: {
isOffline: PropTypes.bool,
}.isRequired,
};

const defaultProps = {
Expand Down
20 changes: 20 additions & 0 deletions src/libs/IOUUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ function updateIOUOwnerAndTotal(iouReport, actorEmail, amount, currency, type =
return iouReportUpdate;
}

/**
* Returns the list of IOU actions
*
* @param {Array} reportIOUActions
* @param {Object} iouReport
* @param {String} type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split)
* @param {String} pendingAction
* @param {Boolean} filterRequestsInDifferentCurrency
*
* @returns {Array}
*/
function getIOUReportActions(reportIOUActions, iouReport, type, pendingAction = '', filterRequestsInDifferentCurrency = false) {
return _.chain(reportIOUActions)
.filter(action => action.originalMessage
Expand All @@ -74,6 +85,15 @@ function getIOUReportActions(reportIOUActions, iouReport, type, pendingAction =
.value();
}

/**
* Returns whether or not an IOU report contains money requests in a different currency
* that are either created or cancelled offline, and thus haven't been converted to the report's currency yet
*
* @param {Array} reportActions
* @param {Object} iouReport
*
* @returns {Boolean}
*/
function isIOUReportPendingCurrencyConversion(reportActions, iouReport) {
// Pending money requests that are in a different currency
const pendingRequestsInDifferentCurrency = _.chain(getIOUReportActions(
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ function splitBillAndOpenReport(participants, currentUserLogin, amount, comment,
* @param {String} iouReportID
* @param {String} type - cancel|decline
* @param {Object} moneyRequestAction - the create IOU reportAction we are cancelling
* @param {Array} reportActions - the chat report's reportActions
*/
function cancelMoneyRequest(chatReportID, iouReportID, type, moneyRequestAction, reportActions) {
const chatReport = chatReports[`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`];
Expand Down

0 comments on commit c4492d2

Please sign in to comment.