-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Update Expense Report View / Headers #22484
Changes from all commits
fac11e2
607408f
374e046
ffbf3d1
fc4a0dc
b1a6aaa
f94993c
e209520
433c33d
1547842
9eb7210
5a407ce
b225de5
ccbeb0f
4940131
2b71f1e
1ab77cd
0dec3ff
b7e9f55
885537e
a83aa76
16408a9
53a82a0
36b6f29
684c6ee
e117a32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import React from 'react'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import {View} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import lodashGet from 'lodash/get'; | ||
import HeaderWithBackButton from './HeaderWithBackButton'; | ||
import iouReportPropTypes from '../pages/iouReportPropTypes'; | ||
import * as ReportUtils from '../libs/ReportUtils'; | ||
import * as Expensicons from './Icon/Expensicons'; | ||
import participantPropTypes from './participantPropTypes'; | ||
import styles from '../styles/styles'; | ||
import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions'; | ||
import compose from '../libs/compose'; | ||
import Navigation from '../libs/Navigation/Navigation'; | ||
import ROUTES from '../ROUTES'; | ||
import SettlementButton from './SettlementButton'; | ||
import * as Policy from '../libs/actions/Policy'; | ||
import ONYXKEYS from '../ONYXKEYS'; | ||
import * as IOU from '../libs/actions/IOU'; | ||
import * as CurrencyUtils from '../libs/CurrencyUtils'; | ||
import reportPropTypes from '../pages/reportPropTypes'; | ||
import useLocalize from '../hooks/useLocalize'; | ||
|
||
const propTypes = { | ||
/** The report currently being looked at */ | ||
report: iouReportPropTypes.isRequired, | ||
|
||
/** The policies which the user has access to and which the report could be tied to */ | ||
policies: PropTypes.shape({ | ||
/** Name of the policy */ | ||
name: PropTypes.string, | ||
}).isRequired, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Issue: #26991 |
||
|
||
/** The chat report this report is linked to */ | ||
chatReport: reportPropTypes, | ||
|
||
/** Personal details so we can get the ones for the report participants */ | ||
personalDetails: PropTypes.objectOf(participantPropTypes).isRequired, | ||
|
||
/** Session info for the currently logged in user. */ | ||
session: PropTypes.shape({ | ||
/** Currently logged in user email */ | ||
email: PropTypes.string, | ||
}), | ||
|
||
...windowDimensionsPropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
chatReport: {}, | ||
session: { | ||
email: null, | ||
}, | ||
}; | ||
|
||
function MoneyReportHeader(props) { | ||
const moneyRequestReport = props.report; | ||
const isSettled = ReportUtils.isSettled(moneyRequestReport.reportID); | ||
const policy = props.policies[`${ONYXKEYS.COLLECTION.POLICY}${props.report.policyID}`]; | ||
const isPayer = | ||
Policy.isAdminOfFreePolicy([policy]) || (ReportUtils.isMoneyRequestReport(moneyRequestReport) && lodashGet(props.session, 'accountID', null) === moneyRequestReport.managerID); | ||
const shouldShowSettlementButton = !isSettled && isPayer; | ||
const bankAccountRoute = ReportUtils.getBankAccountRoute(props.chatReport); | ||
const shouldShowPaypal = Boolean(lodashGet(props.personalDetails, [moneyRequestReport.managerID, 'payPalMeAddress'])); | ||
const formattedAmount = CurrencyUtils.convertToDisplayString(ReportUtils.getMoneyRequestTotal(props.report), props.report.currency); | ||
const {translate} = useLocalize(); | ||
|
||
return ( | ||
<View style={[styles.pt0]}> | ||
<HeaderWithBackButton | ||
shouldShowAvatarWithDisplay | ||
shouldShowPinButton={false} | ||
shouldShowThreeDotsButton={false} | ||
threeDotsMenuItems={[ | ||
{ | ||
icon: Expensicons.Trashcan, | ||
text: translate('common.delete'), | ||
onSelected: () => {}, | ||
}, | ||
]} | ||
threeDotsAnchorPosition={styles.threeDotsPopoverOffsetNoCloseButton(props.windowWidth)} | ||
report={props.report} | ||
policies={props.policies} | ||
personalDetails={props.personalDetails} | ||
shouldShowBackButton | ||
onBackButtonPress={() => Navigation.goBack(ROUTES.HOME, false, true)} | ||
shouldShowBorderBottom={!shouldShowSettlementButton || !props.isSmallScreenWidth} | ||
> | ||
{shouldShowSettlementButton && !props.isSmallScreenWidth && ( | ||
<View style={[styles.pv2]}> | ||
<SettlementButton | ||
currency={props.report.currency} | ||
policyID={props.report.policyID} | ||
shouldShowPaypal={shouldShowPaypal} | ||
chatReportID={props.chatReport.reportID} | ||
iouReport={props.report} | ||
onPress={(paymentType) => IOU.payMoneyRequest(paymentType, props.chatReport, props.report)} | ||
enablePaymentsRoute={ROUTES.BANK_ACCOUNT_NEW} | ||
addBankAccountRoute={bankAccountRoute} | ||
shouldShowPaymentOptions | ||
style={[styles.pv2]} | ||
formattedAmount={formattedAmount} | ||
/> | ||
</View> | ||
)} | ||
</HeaderWithBackButton> | ||
{shouldShowSettlementButton && props.isSmallScreenWidth && ( | ||
<View style={[styles.ph5, styles.pb2, props.isSmallScreenWidth && styles.borderBottom]}> | ||
<SettlementButton | ||
currency={props.report.currency} | ||
policyID={props.report.policyID} | ||
shouldShowPaypal={shouldShowPaypal} | ||
chatReportID={props.report.chatReportID} | ||
iouReport={props.report} | ||
onPress={(paymentType) => IOU.payMoneyRequest(paymentType, props.chatReport, props.report)} | ||
enablePaymentsRoute={ROUTES.BANK_ACCOUNT_NEW} | ||
addBankAccountRoute={bankAccountRoute} | ||
Comment on lines
+99
to
+117
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We missed to pass |
||
shouldShowPaymentOptions | ||
formattedAmount={formattedAmount} | ||
/> | ||
</View> | ||
)} | ||
</View> | ||
); | ||
} | ||
|
||
MoneyReportHeader.displayName = 'MoneyReportHeader'; | ||
MoneyReportHeader.propTypes = propTypes; | ||
MoneyReportHeader.defaultProps = defaultProps; | ||
|
||
export default compose( | ||
withWindowDimensions, | ||
withOnyx({ | ||
chatReport: { | ||
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report.chatReportID}`, | ||
}, | ||
session: { | ||
key: ONYXKEYS.SESSION, | ||
}, | ||
}), | ||
)(MoneyReportHeader); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React from 'react'; | ||
import {View, Image} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import reportPropTypes from '../../pages/reportPropTypes'; | ||
import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; | ||
import styles from '../../styles/styles'; | ||
import * as ReportUtils from '../../libs/ReportUtils'; | ||
import * as StyleUtils from '../../styles/StyleUtils'; | ||
import CONST from '../../CONST'; | ||
import Text from '../Text'; | ||
import Icon from '../Icon'; | ||
import * as Expensicons from '../Icon/Expensicons'; | ||
import variables from '../../styles/variables'; | ||
import * as CurrencyUtils from '../../libs/CurrencyUtils'; | ||
import EmptyStateBackgroundImage from '../../../assets/images/empty-state_background-fade.png'; | ||
import useLocalize from '../../hooks/useLocalize'; | ||
|
||
const propTypes = { | ||
/** The report currently being looked at */ | ||
report: reportPropTypes.isRequired, | ||
|
||
/** Whether we should display the horizontal rule below the component */ | ||
shouldShowHorizontalRule: PropTypes.bool.isRequired, | ||
|
||
...windowDimensionsPropTypes, | ||
}; | ||
|
||
function MoneyReportView(props) { | ||
const formattedAmount = CurrencyUtils.convertToDisplayString(ReportUtils.getMoneyRequestTotal(props.report), props.report.currency); | ||
const isSettled = ReportUtils.isSettled(props.report.reportID); | ||
const {translate} = useLocalize(); | ||
|
||
return ( | ||
<View> | ||
<View style={[StyleUtils.getReportWelcomeContainerStyle(props.isSmallScreenWidth), StyleUtils.getMinimumHeight(CONST.EMPTY_STATE_BACKGROUND.MONEY_REPORT.MIN_HEIGHT)]}> | ||
<Image | ||
pointerEvents="none" | ||
source={EmptyStateBackgroundImage} | ||
style={[StyleUtils.getReportWelcomeBackgroundImageStyle(true)]} | ||
/> | ||
</View> | ||
<View style={[styles.flexRow, styles.menuItemTextContainer, styles.pointerEventsNone, styles.containerWithSpaceBetween, styles.ph5, styles.pv2]}> | ||
<View style={[styles.flex1, styles.justifyContentCenter]}> | ||
<Text | ||
style={[styles.textLabelSupporting, styles.lhNormal, StyleUtils.getFontSizeStyle(variables.fontSizeNormal)]} | ||
numberOfLines={1} | ||
> | ||
{translate('common.total')} | ||
</Text> | ||
</View> | ||
<View style={[styles.flexRow, styles.justifyContentCenter]}> | ||
{isSettled && ( | ||
<View style={[styles.defaultCheckmarkWrapper, styles.mh1]}> | ||
<Icon | ||
src={Expensicons.Checkmark} | ||
fill={styles.success} | ||
/> | ||
</View> | ||
)} | ||
<Text | ||
numberOfLines={1} | ||
style={[styles.taskTitleMenuItem, styles.alignSelfCenter]} | ||
> | ||
{formattedAmount} | ||
</Text> | ||
</View> | ||
</View> | ||
{props.shouldShowHorizontalRule && <View style={styles.reportHorizontalRule} />} | ||
</View> | ||
); | ||
} | ||
|
||
MoneyReportView.propTypes = propTypes; | ||
MoneyReportView.displayName = 'MoneyReportView'; | ||
|
||
export default withWindowDimensions(MoneyReportView); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,6 +147,7 @@ export default { | |
km: 'kilometer', | ||
copied: 'Copied!', | ||
someone: 'Someone', | ||
total: 'Total', | ||
edit: 'Edit', | ||
}, | ||
anonymousReportFooter: { | ||
|
@@ -353,9 +354,9 @@ export default { | |
settledExpensify: 'Paid', | ||
settledElsewhere: 'Paid elsewhere', | ||
settledPaypalMe: 'Paid using Paypal.me', | ||
settleExpensify: 'Pay with Expensify', | ||
settleExpensify: ({formattedAmount}) => `Pay ${formattedAmount} with Expensify`, | ||
payElsewhere: 'Pay elsewhere', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, the |
||
settlePaypalMe: 'Pay with PayPal.me', | ||
settlePaypalMe: ({formattedAmount}) => `Pay ${formattedAmount} with PayPal.me`, | ||
requestAmount: ({amount}) => `request ${amount}`, | ||
splitAmount: ({amount}) => `split ${amount}`, | ||
amountEach: ({amount}) => `${amount} each`, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was overlooked.
There was no
lineHeightNormal
property instyles
.Making this valid caused minor regression - Test
Assignee
is cut of from the bottom