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

Adds Receipt Component to Money Request confirmation page #34533

Merged
Merged
22 changes: 21 additions & 1 deletion src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import Image from './Image';
import MenuItemWithTopDescription from './MenuItemWithTopDescription';
import optionPropTypes from './optionPropTypes';
import OptionsSelector from './OptionsSelector';
import ReceiptEmptyState from './ReceiptEmptyState';
import SettlementButton from './SettlementButton';
import ShowMoreButton from './ShowMoreButton';
import Switch from './Switch';
Expand Down Expand Up @@ -222,6 +223,9 @@ function MoneyRequestConfirmationList(props) {
const isSplitBill = props.iouType === CONST.IOU.TYPE.SPLIT;
const isTypeSend = props.iouType === CONST.IOU.TYPE.SEND;

// A flag for checking if the associated policy is of type Team or Corporate ("Control" or "Collect")
const isFromPaidPolicy = props.policy && (props.policy.type === CONST.POLICY.TYPE.TEAM || props.policy.type === CONST.POLICY.TYPE.CORPORATE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use PolicyUtils.isPaidGroupPolicy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! We can. I wasn't aware of this util. I'll do a quick change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fixing the lint errors


const isSplitWithScan = isSplitBill && props.isScanRequest;

const {unit, rate, currency} = props.mileageRate;
Expand Down Expand Up @@ -604,7 +608,7 @@ function MoneyRequestConfirmationList(props) {
<ConfirmedRoute transaction={props.transaction} />
</View>
)}
{(receiptImage || receiptThumbnail) && (
{receiptImage || receiptThumbnail ? (
<Image
style={styles.moneyRequestImage}
source={{uri: receiptThumbnail || receiptImage}}
Expand All @@ -613,6 +617,22 @@ function MoneyRequestConfirmationList(props) {
// So if we have a thumbnail, it means we're retrieving the image from the server
isAuthTokenRequired={!_.isEmpty(receiptThumbnail)}
/>
) : (
isFromPaidPolicy && (
cdanwards marked this conversation as resolved.
Show resolved Hide resolved
<ReceiptEmptyState
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
CONST.IOU.ACTION.CREATE,
CONST.IOU.TYPE.REQUEST,
cdanwards marked this conversation as resolved.
Show resolved Hide resolved
transaction.transactionID,
props.reportID,
Navigation.getActiveRouteWithoutParams(),
),
)
}
/>
)
cdanwards marked this conversation as resolved.
Show resolved Hide resolved
)}
{props.shouldShowSmartScanFields && (
<MenuItemWithTopDescription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import Image from './Image';
import MenuItemWithTopDescription from './MenuItemWithTopDescription';
import optionPropTypes from './optionPropTypes';
import OptionsSelector from './OptionsSelector';
import ReceiptEmptyState from './ReceiptEmptyState';
import SettlementButton from './SettlementButton';
import Switch from './Switch';
import tagPropTypes from './tagPropTypes';
Expand Down Expand Up @@ -252,6 +253,9 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
const isTypeSplit = iouType === CONST.IOU.TYPE.SPLIT;
const isTypeSend = iouType === CONST.IOU.TYPE.SEND;

// A flag for checking if the associated policy is of type Team or Corporate ("Control" or "Collect")
const isFromPaidPolicy = policy && (policy.type === CONST.POLICY.TYPE.TEAM || policy.type === CONST.POLICY.TYPE.CORPORATE);

const {unit, rate, currency} = mileageRate;
const distance = lodashGet(transaction, 'routes.route0.distance', 0);
const shouldCalculateDistanceAmount = isDistanceRequest && iouAmount === 0;
Expand Down Expand Up @@ -638,7 +642,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
<ConfirmedRoute transaction={transaction} />
</View>
)}
{(receiptImage || receiptThumbnail) && (
{receiptImage || receiptThumbnail ? (
<Image
style={styles.moneyRequestImage}
source={{uri: receiptThumbnail || receiptImage}}
Expand All @@ -647,6 +651,22 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
// So if we have a thumbnail, it means we're retrieving the image from the server
isAuthTokenRequired={!_.isEmpty(receiptThumbnail)}
/>
) : (
isFromPaidPolicy && (
cdanwards marked this conversation as resolved.
Show resolved Hide resolved
<ReceiptEmptyState
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
CONST.IOU.ACTION.CREATE,
CONST.IOU.TYPE.REQUEST,
cdanwards marked this conversation as resolved.
Show resolved Hide resolved
transaction.transactionID,
reportID,
Navigation.getActiveRouteWithoutParams(),
),
)
}
/>
)
)}
{shouldShowSmartScanFields && (
<MenuItemWithTopDescription
Expand Down
Loading