From 8c809872141780d15a511552207cf664d947d3c4 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 5 Oct 2023 14:16:43 +0100 Subject: [PATCH] feat: show submit button in Report preview for open/draft reports --- .../ReportActionItem/ReportPreview.js | 18 ++++++++++++++++-- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/ReportUtils.js | 9 +++++++++ src/libs/actions/IOU.js | 3 +++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/ReportPreview.js b/src/components/ReportActionItem/ReportPreview.js index a79cfd315b12..e530041ae9e0 100644 --- a/src/components/ReportActionItem/ReportPreview.js +++ b/src/components/ReportActionItem/ReportPreview.js @@ -4,8 +4,9 @@ import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; -import Text from '../Text'; +import Button from '../Button'; import Icon from '../Icon'; +import Text from '../Text'; import * as Expensicons from '../Icon/Expensicons'; import styles from '../../styles/styles'; import reportActionPropTypes from '../../pages/home/report/reportActionPropTypes'; @@ -20,6 +21,7 @@ import * as CurrencyUtils from '../../libs/CurrencyUtils'; import * as ReportUtils from '../../libs/ReportUtils'; import Navigation from '../../libs/Navigation/Navigation'; import ROUTES from '../../ROUTES'; +import useLocalize from '../../hooks/useLocalize'; import SettlementButton from '../SettlementButton'; import * as IOU from '../../libs/actions/IOU'; import refPropTypes from '../refPropTypes'; @@ -105,6 +107,8 @@ const defaultProps = { }; function ReportPreview(props) { + const {translate} = useLocalize(); + const managerID = props.iouReport.managerID || 0; const isCurrentUserManager = managerID === lodashGet(props.session, 'accountID'); const reportTotal = ReportUtils.getMoneyRequestTotal(props.iouReport); @@ -113,6 +117,7 @@ function ReportPreview(props) { const iouCanceled = ReportUtils.isArchivedRoom(props.chatReport); const numberOfRequests = ReportActionUtils.getNumberOfMoneyRequests(props.action); const moneyRequestComment = lodashGet(props.action, 'childLastMoneyRequestComment', ''); + const isReportDraft = ReportUtils.isReportDraft(props.iouReport); const transactionsWithReceipts = ReportUtils.getTransactionsWithReceipts(props.iouReportID); const numberOfScanningReceipts = _.filter(transactionsWithReceipts, (transaction) => TransactionUtils.isReceiptBeingScanned(transaction)).length; @@ -164,7 +169,7 @@ function ReportPreview(props) { const bankAccountRoute = ReportUtils.getBankAccountRoute(props.chatReport); const shouldShowSettlementButton = ReportUtils.isControlPolicyExpenseChat(props.chatReport) ? props.policy.role === CONST.POLICY.ROLE.ADMIN && ReportUtils.isReportApproved(props.iouReport) && !iouSettled && !iouCanceled - : !_.isEmpty(props.iouReport) && isCurrentUserManager && !iouSettled && !iouCanceled && !props.iouReport.isWaitingOnBankAccount && reportTotal !== 0; + : !_.isEmpty(props.iouReport) && isCurrentUserManager && !isReportDraft && !iouSettled && !iouCanceled && !props.iouReport.isWaitingOnBankAccount && reportTotal !== 0; return ( @@ -232,6 +237,15 @@ function ReportPreview(props) { style={[styles.requestPreviewBox]} /> )} + {isReportDraft && ( +