-
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
[NoQA] feat: show submit button in MoneyReportHeader when report is in draft #28998
Changes from all commits
45f9fd6
2eca6a1
687ab6d
4775ea7
09c620c
7bb0e0b
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 |
---|---|---|
|
@@ -69,16 +69,19 @@ function MoneyReportHeader({session, personalDetails, policy, chatReport, report | |
const isPolicyAdmin = policyType !== CONST.POLICY.TYPE.PERSONAL && lodashGet(policy, 'role') === CONST.POLICY.ROLE.ADMIN; | ||
const isManager = ReportUtils.isMoneyRequestReport(moneyRequestReport) && lodashGet(session, 'accountID', null) === moneyRequestReport.managerID; | ||
const isPayer = policyType === CONST.POLICY.TYPE.CORPORATE ? isPolicyAdmin && isApproved : isPolicyAdmin || (ReportUtils.isMoneyRequestReport(moneyRequestReport) && isManager); | ||
const isDraft = ReportUtils.isReportDraft(moneyRequestReport); | ||
const shouldShowSettlementButton = useMemo( | ||
() => isPayer && !isSettled && !moneyRequestReport.isWaitingOnBankAccount && reportTotal !== 0 && !ReportUtils.isArchivedRoom(chatReport), | ||
[isPayer, isSettled, moneyRequestReport, reportTotal, chatReport], | ||
() => isPayer && !isDraft && !isSettled && !moneyRequestReport.isWaitingOnBankAccount && reportTotal !== 0 && !ReportUtils.isArchivedRoom(chatReport), | ||
[isPayer, isDraft, isSettled, moneyRequestReport, reportTotal, chatReport], | ||
); | ||
const shouldShowApproveButton = useMemo(() => { | ||
if (policyType !== CONST.POLICY.TYPE.CORPORATE) { | ||
return false; | ||
} | ||
return isManager && !isApproved && !isSettled; | ||
}, [policyType, isManager, isApproved, isSettled]); | ||
return isManager && !isDraft && !isApproved && !isSettled; | ||
}, [policyType, isManager, isDraft, isApproved, isSettled]); | ||
const shouldShowSubmitButton = isDraft; | ||
const shouldShowAnyButton = shouldShowSettlementButton || shouldShowApproveButton || shouldShowSubmitButton; | ||
const bankAccountRoute = ReportUtils.getBankAccountRoute(chatReport); | ||
const formattedAmount = CurrencyUtils.convertToDisplayString(reportTotal, moneyRequestReport.currency); | ||
|
||
|
@@ -93,10 +96,10 @@ function MoneyReportHeader({session, personalDetails, policy, chatReport, report | |
personalDetails={personalDetails} | ||
shouldShowBackButton={isSmallScreenWidth} | ||
onBackButtonPress={() => Navigation.goBack(ROUTES.HOME, false, true)} | ||
shouldShowBorderBottom={!shouldShowSettlementButton || !isSmallScreenWidth} | ||
shouldShowBorderBottom={!shouldShowAnyButton || !isSmallScreenWidth} | ||
> | ||
{shouldShowSettlementButton && !isSmallScreenWidth && ( | ||
<View style={[styles.pv2]}> | ||
<View style={styles.pv2}> | ||
<SettlementButton | ||
currency={moneyRequestReport.currency} | ||
policyID={moneyRequestReport.policyID} | ||
|
@@ -116,7 +119,7 @@ function MoneyReportHeader({session, personalDetails, policy, chatReport, report | |
</View> | ||
)} | ||
{shouldShowApproveButton && !isSmallScreenWidth && ( | ||
<View style={[styles.pv2]}> | ||
<View style={styles.pv2}> | ||
<Button | ||
success | ||
medium | ||
|
@@ -126,6 +129,17 @@ function MoneyReportHeader({session, personalDetails, policy, chatReport, report | |
/> | ||
</View> | ||
)} | ||
{shouldShowSubmitButton && !isSmallScreenWidth && ( | ||
<View style={styles.pv2}> | ||
<Button | ||
medium | ||
success={chatReport.isOwnPolicyExpenseChat} | ||
text={translate('common.submit')} | ||
style={[styles.mnw120, styles.pv2, styles.pr0]} | ||
onPress={() => IOU.submitReport(moneyRequestReport)} | ||
/> | ||
</View> | ||
)} | ||
</HeaderWithBackButton> | ||
{shouldShowSettlementButton && isSmallScreenWidth && ( | ||
<View style={[styles.ph5, styles.pb2, isSmallScreenWidth && styles.borderBottom]}> | ||
|
@@ -153,6 +167,17 @@ function MoneyReportHeader({session, personalDetails, policy, chatReport, report | |
/> | ||
</View> | ||
)} | ||
{shouldShowSubmitButton && isSmallScreenWidth && ( | ||
<View style={[styles.ph5, styles.pb2, isSmallScreenWidth && styles.borderBottom]}> | ||
<Button | ||
medium | ||
success={chatReport.isOwnPolicyExpenseChat} | ||
text={translate('common.submit')} | ||
style={[styles.w100, styles.pr0]} | ||
BeeMargarida marked this conversation as resolved.
Show resolved
Hide resolved
|
||
onPress={() => IOU.submitReport(moneyRequestReport)} | ||
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. This is not exported right now I believe, wont we get complains about it? 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. It's being exported from lib/actions/IOU 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. Ah I must have seen some commit diff then, sorry. |
||
/> | ||
</View> | ||
)} | ||
</View> | ||
); | ||
} | ||
|
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.
Admin can submit and approve it is own report when
Prevent self approval
is enabled. So we should have prevented submitting it, ref: #36425