Skip to content

Commit

Permalink
Added ReportActionItemIOUQuote component
Browse files Browse the repository at this point in the history
  • Loading branch information
tugbadogan committed Apr 3, 2021
1 parent b04df47 commit 6870e69
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
7 changes: 4 additions & 3 deletions src/components/ReportActionItemIOUPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import ONYXKEYS from '../ONYXKEYS';
import ReportActionItemMessage from '../pages/home/report/ReportActionItemMessage';
import ReportActionItemIOUQuote from './ReportActionItemIOUQuote';
import ReportActionPropTypes from '../pages/home/report/ReportActionPropTypes';

const propTypes = {
Expand All @@ -24,7 +24,6 @@ const propTypes = {
// Active IOU Report for current report
// eslint-disable-next-line react/forbid-prop-types
iou: PropTypes.object.isRequired,

};

const ReportActionItemIOUPreview = ({
Expand All @@ -33,10 +32,12 @@ const ReportActionItemIOUPreview = ({
report,
iou,
}) => (
<ReportActionItemMessage action={action} />
<ReportActionItemIOUQuote action={action} />
);

ReportActionItemIOUPreview.propTypes = propTypes;
ReportActionItemIOUPreview.displayName = 'ReportActionItemIOUPreview';

export default withOnyx({
iou: {
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_IOUS}${report.iouReportID}`,
Expand Down
30 changes: 30 additions & 0 deletions src/components/ReportActionItemIOUQuote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import styles from '../styles/styles';
import ReportActionPropTypes from '../pages/home/report/ReportActionPropTypes';
import RenderHTML from './RenderHTML';

const propTypes = {
// All the data of the action
action: PropTypes.shape(ReportActionPropTypes).isRequired,

};
const ReportActionItemIOUQuote = ({action}) => (
<View style={[styles.chatItemMessage]}>
{_.map(_.compact(action.message), (fragment, index) => {
const viewDetails = '<br /><a href="#" style="text-decoration:none;">View Details</a>';
const html = `<blockquote>${fragment.text}${viewDetails}</blockquote>`;
return (
<RenderHTML key={`iouQuote-${action.sequenceNumber}-${index}`} html={html} debug={false} />
);
})}
</View>

);

ReportActionItemIOUQuote.propTypes = propTypes;
ReportActionItemIOUQuote.displayName = 'ReportActionItemIOUQuote';

export default ReportActionItemIOUQuote;
11 changes: 0 additions & 11 deletions src/pages/home/report/ReportActionItemFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ const propTypes = {
// Is this fragment an attachment?
isAttachment: PropTypes.bool,

// Type of the current action
actionName: PropTypes.string,

// Does this fragment belong to a reportAction that has not yet loaded?
loading: PropTypes.bool,
};
Expand All @@ -30,7 +27,6 @@ const defaultProps = {
isAttachment: false,
loading: false,
tooltipText: '',
actionName: '',
};

class ReportActionItemFragment extends React.PureComponent {
Expand Down Expand Up @@ -58,13 +54,6 @@ class ReportActionItemFragment extends React.PureComponent {
<Text selectable>{Str.htmlDecode(fragment.text)}</Text>
);
case 'TEXT':
if (this.props.actionName === 'IOU') {
const viewDetails = '<br /><a href="#" style="text-decoration:none;">View Details</a>';
const html = `<blockquote>${fragment.text}${viewDetails}</blockquote>`;
return (
<RenderHTML html={html} debug={false} />
);
}
return (
<Tooltip text={tooltipText}>
<Text
Expand Down
1 change: 0 additions & 1 deletion src/pages/home/report/ReportActionItemMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const ReportActionItemMessage = ({action}) => (
fragment={fragment}
isAttachment={action.isAttachment}
loading={action.loading}
actionName={action.actionName}
/>
))}
</View>
Expand Down

0 comments on commit 6870e69

Please sign in to comment.