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

[No QA] Created IOU preview component within chat #2112

Merged
merged 35 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d581791
Created IOU preview component within chat
tugbadogan Mar 26, 2021
1e7a1c9
Added ReportActionItemIOUQuote component
tugbadogan Mar 28, 2021
095aad9
Added IOU Preview UI
tugbadogan Mar 30, 2021
8b2a0b4
Fixed live update issues and addressing comments
tugbadogan Mar 31, 2021
b04df47
Created IOU preview component within chat
tugbadogan Mar 26, 2021
6870e69
Added ReportActionItemIOUQuote component
tugbadogan Mar 28, 2021
8bc24d2
Added IOU Preview UI
tugbadogan Mar 30, 2021
5f68df7
Fixed live update issues and addressing comments
tugbadogan Mar 31, 2021
0c1e7f6
Update chat report real time on IOU report changes
tugbadogan Apr 5, 2021
eff5eb2
Merge branch 'tugbadogan-create-iou-preview-component' of https://git…
tugbadogan Apr 5, 2021
051fd09
Fix linter errors
tugbadogan Apr 5, 2021
3da3fb4
Addressing comments and styling changes
tugbadogan Apr 8, 2021
b66ab2e
Merge branch 'master' into tugbadogan-create-iou-preview-component
tugbadogan Apr 8, 2021
75d0302
Fixing merge issues
tugbadogan Apr 8, 2021
cdbaaff
Create a separate function for updateIOUAndChatReportData
tugbadogan Apr 8, 2021
d4be1b5
Addressing comments
tugbadogan Apr 9, 2021
893f34d
Merge branch 'master' into tugbadogan-create-iou-preview-component
tugbadogan Apr 9, 2021
61cb1e4
Updating Report.js to work with fixed push notifications
tugbadogan Apr 14, 2021
5976424
Merge pull request #14 from Expensify/master
tugbadogan Apr 14, 2021
cc83654
Merge branch 'master' into tugbadogan-create-iou-preview-component
tugbadogan Apr 14, 2021
d4455b8
Merge pull request #15 from Expensify/master
tugbadogan Apr 15, 2021
975c0fc
Addressing comments
tugbadogan Apr 18, 2021
195b424
Merge pull request #16 from Expensify/main
tugbadogan Apr 19, 2021
f64e2f3
Merge branch 'master' into tugbadogan-create-iou-preview-component
tugbadogan Apr 19, 2021
103e1d1
Simplify Report.js
tugbadogan Apr 20, 2021
70522c4
Another set of refactoring in Report.js
tugbadogan Apr 21, 2021
bada5ba
Merge pull request #17 from Expensify/main
tugbadogan Apr 21, 2021
ff0d54b
Merge branch 'master' into tugbadogan-create-iou-preview-component
tugbadogan Apr 21, 2021
f2fceb9
Fixed lint error
tugbadogan Apr 21, 2021
1ab7855
Updated comment and pod install
tugbadogan Apr 21, 2021
6d3bfa3
Revert changes from pod install
tugbadogan Apr 23, 2021
d16c1b2
Merge pull request #18 from Expensify/main
tugbadogan Apr 23, 2021
33ecad8
Merge branch 'master' into tugbadogan-create-iou-preview-component
tugbadogan Apr 23, 2021
a3a7063
Merge pull request #19 from Expensify/main
tugbadogan Apr 23, 2021
88989a6
Merge branch 'master' into tugbadogan-create-iou-preview-component
tugbadogan Apr 23, 2021
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
45 changes: 23 additions & 22 deletions src/components/ReportActionItemIOUPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ import Text from './Text';
import MultipleAvatars from './MultipleAvatars';
import styles from '../styles/styles';

const personalDetailsPropTypes = PropTypes.shape({
// This is either the user's full name, or their login if full name is an empty string
displayName: PropTypes.string.isRequired,
});

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

// Is this the most recent IOU Action?
isMostRecentIOUReport: PropTypes.bool.isRequired,

// The report currently being looked at
report: PropTypes.shape({

// IOU report ID associated with current report
iouReportID: PropTypes.number,

// Whether there is an outstanding amount in IOU
hasOutstandingIOU: PropTypes.bool,
}).isRequired,

/* Window Dimensions Props */
...windowDimensionsPropTypes,

Expand All @@ -40,7 +45,11 @@ const propTypes = {
}),

// All of the personal details for everyone
personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired,
personalDetails: PropTypes.objectOf(PropTypes.shape({

// This is either the user's full name, or their login if full name is an empty string
displayName: PropTypes.string.isRequired,
})).isRequired,

// Session info for the currently logged in user.
session: PropTypes.shape({
Expand All @@ -50,7 +59,7 @@ const propTypes = {
};

const defaultProps = {
iou: null,
iou: {},
marcaaron marked this conversation as resolved.
Show resolved Hide resolved
};

class ReportActionItemIOUPreview extends React.Component {
Expand Down Expand Up @@ -96,11 +105,6 @@ class ReportActionItemIOUPreview extends React.Component {
const ownerAvatar = lodashGet(this.props.personalDetails, [this.props.iou.ownerEmail, 'avatar'], '');
const sessionEmail = lodashGet(this.props.session, 'email', null);
const cachedTotal = this.props.iou.cachedTotal.replace(/[()]/g, '');
tugbadogan marked this conversation as resolved.
Show resolved Hide resolved
const amount = Number(cachedTotal.substring(1));

if (amount === 0) {
return null;
}

return (
<View style={[styles.iouPreviewBox, {width: this.props.isSmallScreenWidth ? '100%' : '50%'}]}>
tugbadogan marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -115,12 +119,7 @@ class ReportActionItemIOUPreview extends React.Component {
</View>
<MultipleAvatars
avatarImageURLs={[managerAvatar, ownerAvatar]}
styles={{
secondAvatar: {
bottom: -3,
right: -25,
},
}}
styles={{secondAvatar: styles.secondAvatarInline}}
/>
</View>
{(this.props.iou.managerEmail === sessionEmail) ? (
Expand All @@ -135,9 +134,11 @@ class ReportActionItemIOUPreview extends React.Component {
return (
<View>
<ReportActionItemIOUQuote action={this.props.action} />
{this.props.isMostRecentIOUReport && this.props.iou ? (
this.createPreviewBox()
)
{this.props.isMostRecentIOUReport
&& this.props.report.hasOutstandingIOU
&& this.props.iou ? (
this.createPreviewBox()
)
: null}
</View>
);
Expand All @@ -150,7 +151,7 @@ ReportActionItemIOUPreview.displayName = 'ReportActionItemIOUPreview';

export default withWindowDimensions(withOnyx({
iou: {
key: ({iouReportID}) => `${ONYXKEYS.COLLECTION.REPORT_IOUS}${iouReportID}`,
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_IOUS}${report.iouReportID}`,
},
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS,
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ function fetchChatReportsByIDs(chatList) {
simplifiedReports[reportKey].iouReportID = iouReportObject.reportID;
simplifiedReports[reportKey].hasOutstandingIOU = iouReportObject.stateNum === 1
&& iouReportObject.total !== 0;
Onyx.merge(iouReportKey, iouReportObject);
tugbadogan marked this conversation as resolved.
Show resolved Hide resolved
});

// We use mergeCollection such that it updates the collection in one go.
Expand Down
7 changes: 4 additions & 3 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class ReportActionItem extends Component {
shouldComponentUpdate(nextProps, nextState) {
return this.state.isPopoverVisible !== nextState.isPopoverVisible
|| this.props.displayAsGroup !== nextProps.displayAsGroup
|| !_.isEqual(this.props.action, nextProps.action);
|| !_.isEqual(this.props.action, nextProps.action)
|| this.props.isMostRecentIOUReport !== nextProps.isMostRecentIOUReport;
}

/**
Expand Down Expand Up @@ -124,14 +125,14 @@ class ReportActionItem extends Component {
? (
<ReportActionItemSingle
action={this.props.action}
iouReportID={this.props.report.iouReportID}
report={this.props.report}
isMostRecentIOUReport={this.props.isMostRecentIOUReport}
/>
)
: (
<ReportActionItemGrouped
action={this.props.action}
iouReportID={this.props.report.iouReportID}
report={this.props.report}
isMostRecentIOUReport={this.props.isMostRecentIOUReport}
/>
)}
Expand Down
15 changes: 7 additions & 8 deletions src/pages/home/report/ReportActionItemGrouped.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ const propTypes = {
// Is this the most recent IOU Action?
isMostRecentIOUReport: PropTypes.bool.isRequired,

// IOU report ID associated with current report
iouReportID: PropTypes.number,
};
// The report currently being looked at
report: PropTypes.shape({

const defaultProps = {
iouReportID: null,
// IOU report ID associated with current report
iouReportID: PropTypes.number,
}).isRequired,
};

const ReportActionItemGrouped = ({action, iouReportID, isMostRecentIOUReport}) => (
const ReportActionItemGrouped = ({action, report, isMostRecentIOUReport}) => (
<View style={[styles.chatItem]}>
<View style={[styles.chatItemRightGrouped]}>
{action.actionName === 'IOU'
tugbadogan marked this conversation as resolved.
Show resolved Hide resolved
? (
<ReportActionItemIOUPreview
iouReportID={iouReportID}
report={report}
action={action}
isMostRecentIOUReport={isMostRecentIOUReport}
/>
Expand All @@ -38,5 +38,4 @@ const ReportActionItemGrouped = ({action, iouReportID, isMostRecentIOUReport}) =
);

ReportActionItemGrouped.propTypes = propTypes;
ReportActionItemGrouped.defaultProps = defaultProps;
export default ReportActionItemGrouped;
15 changes: 7 additions & 8 deletions src/pages/home/report/ReportActionItemSingle.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ const propTypes = {
// Is this the most recent IOU Action?
isMostRecentIOUReport: PropTypes.bool.isRequired,

// IOU report ID associated with current report
iouReportID: PropTypes.number,
};
// The report currently being looked at
report: PropTypes.shape({

const defaultProps = {
iouReportID: null,
// IOU report ID associated with current report
iouReportID: PropTypes.number,
}).isRequired,
};

const ReportActionItemSingle = ({action, iouReportID, isMostRecentIOUReport}) => {
const ReportActionItemSingle = ({action, report, isMostRecentIOUReport}) => {
const avatarUrl = action.automatic
? `${CONST.CLOUDFRONT_URL}/images/icons/concierge_2019.svg`
: action.avatar;
Expand All @@ -52,7 +52,7 @@ const ReportActionItemSingle = ({action, iouReportID, isMostRecentIOUReport}) =>
{action.actionName === 'IOU'
? (
<ReportActionItemIOUPreview
iouReportID={iouReportID}
report={report}
action={action}
isMostRecentIOUReport={isMostRecentIOUReport}
/>
Expand All @@ -64,5 +64,4 @@ const ReportActionItemSingle = ({action, iouReportID, isMostRecentIOUReport}) =>
};

ReportActionItemSingle.propTypes = propTypes;
ReportActionItemSingle.defaultProps = defaultProps;
export default ReportActionItemSingle;
5 changes: 5 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,11 @@ const styles = {
borderColor: 'transparent',
},

secondAvatarInline: {
bottom: -3,
right: -25,
},

avatarNormal: {
height: variables.componentSizeNormal,
width: variables.componentSizeNormal,
Expand Down