diff --git a/src/CONST.js b/src/CONST.js index cbf24bae5610..b1edc54f3372 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -661,6 +661,8 @@ const CONST = { PAY: 'pay', CREATE: 'create', SPLIT: 'split', + DECLINE: 'decline', + CANCEL: 'cancel', }, AMOUNT_MAX_LENGTH: 10, }, diff --git a/src/components/KYCWall/kycWallPropTypes.js b/src/components/KYCWall/kycWallPropTypes.js index 5886001c8c92..73e2b550b69f 100644 --- a/src/components/KYCWall/kycWallPropTypes.js +++ b/src/components/KYCWall/kycWallPropTypes.js @@ -24,7 +24,7 @@ const propTypes = { userWallet: userWalletPropTypes, /** When the button is opened via an IOU, ID for the chatReport that the IOU is linked to */ - chatReportID: PropTypes.number, + chatReportID: PropTypes.string, }; const defaultProps = { @@ -32,7 +32,7 @@ const defaultProps = { popoverPlacement: 'top', shouldListenForResize: false, isDisabled: false, - chatReportID: 0, + chatReportID: '', }; export {propTypes, defaultProps}; diff --git a/src/components/ReportTransaction.js b/src/components/ReportTransaction.js index 8e2aaeb165ab..21158e9a94b1 100644 --- a/src/components/ReportTransaction.js +++ b/src/components/ReportTransaction.js @@ -1,14 +1,14 @@ import React, {Component} from 'react'; import PropTypes from 'prop-types'; -import lodashGet from 'lodash/get'; import {View} from 'react-native'; -import {withOnyx} from 'react-native-onyx'; -import _ from 'underscore'; -import ONYXKEYS from '../ONYXKEYS'; import styles from '../styles/styles'; +import CONST from '../CONST'; import * as IOU from '../libs/actions/IOU'; +import * as ReportActions from '../libs/actions/ReportActions'; import reportActionPropTypes from '../pages/home/report/reportActionPropTypes'; import ReportActionItemSingle from '../pages/home/report/ReportActionItemSingle'; +import withLocalize, {withLocalizePropTypes} from './withLocalize'; +import OfflineWithFeedback from './OfflineWithFeedback'; import Text from './Text'; import Button from './Button'; @@ -27,17 +27,10 @@ const propTypes = { /** Can this transaction be rejected? */ canBeRejected: PropTypes.bool, - /** Text label for the reject transaction button */ - rejectButtonLabelText: PropTypes.string.isRequired, + /** Type of the reject transaction button */ + rejectButtonType: PropTypes.oneOf([CONST.IOU.REPORT_ACTION_TYPE.DECLINE, CONST.IOU.REPORT_ACTION_TYPE.CANCEL]).isRequired, - /* Onyx Props */ - - /** List of transactionIDs in process of rejection */ - /* eslint-disable-next-line react/no-unused-prop-types, react/require-default-props */ - transactionsBeingRejected: PropTypes.shape({ - /** IOUTransactionID that's being rejected */ - transactionID: PropTypes.bool, - }), + ...withLocalizePropTypes, }; const defaultProps = { @@ -48,62 +41,57 @@ class ReportTransaction extends Component { constructor(props) { super(props); - this.rejectTransaction = this.rejectTransaction.bind(this); - } - - rejectTransaction() { - IOU.rejectTransaction({ - reportID: this.props.iouReportID, - chatReportID: this.props.chatReportID, - transactionID: this.props.action.originalMessage.IOUTransactionID, - comment: '', - }); + this.cancelMoneyRequest = this.cancelMoneyRequest.bind(this); } - /** - * Checks if current IOUTransactionID is being rejected. - * @returns {boolean} Returns `true` if current IOUtransactionID is being rejected, else `false`. - */ - isBeingRejected() { - const IOUTransactionID = lodashGet(this.props.action, 'originalMessage.IOUTransactionID', ''); - const transactionsBeingRejected = lodashGet(this.props, 'transactionsBeingRejected', {}); - if (_.isEmpty(transactionsBeingRejected)) { - return false; - } - return _.has(transactionsBeingRejected, IOUTransactionID); + cancelMoneyRequest() { + IOU.cancelMoneyRequest( + this.props.chatReportID, + this.props.iouReportID, + this.props.rejectButtonType, + this.props.action, + ); } render() { return ( - - - - {this.props.action.message[0].text} - - - {this.props.canBeRejected && ( - -