Skip to content

Commit

Permalink
handle button ui for the web breakpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
BrtqKr committed May 17, 2024
1 parent 6750c63 commit 13e8335
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ function MoneyRequestHeader({
const isSettled = ReportUtils.isSettled(moneyRequestReport?.reportID);
const isApproved = ReportUtils.isReportApproved(moneyRequestReport);
const isOnHold = TransactionUtils.isOnHold(transaction);
const {windowWidth} = useWindowDimensions();
const {windowWidth, isSmallScreenWidth} = useWindowDimensions();

// Only the requestor can take delete the expense, admins can only edit it.
const isActionOwner = typeof parentReportAction?.actorAccountID === 'number' && typeof session?.accountID === 'number' && parentReportAction.actorAccountID === session?.accountID;
const isPolicyAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;
const isApprover = ReportUtils.isMoneyRequestReport(moneyRequestReport) && moneyRequestReport?.managerID !== null && session?.accountID === moneyRequestReport?.managerID;
const hasAllPendingRTERViolations = TransactionUtils.allHavePendingRTERViolation([transaction?.transactionID ?? '']);
const showFullWidthMarkAsCashButton = isSmallScreenWidth && hasAllPendingRTERViolations;

const deleteTransaction = useCallback(() => {
if (parentReportAction) {
Expand Down Expand Up @@ -150,7 +151,11 @@ function MoneyRequestHeader({
return {title: getStatusIcon(Expensicons.ReceiptScan), description: translate('iou.receiptScanInProgressDescription'), shouldShowBorderBottom: true};
}
if (TransactionUtils.hasPendingRTERViolation(TransactionUtils.getTransactionViolations(transaction?.transactionID ?? '', transactionViolations))) {
return {title: getStatusIcon(Expensicons.Hourglass), description: translate('iou.pendingMatchWithCreditCardDescription'), shouldShowBorderBottom: !hasAllPendingRTERViolations};
return {
title: getStatusIcon(Expensicons.Hourglass),
description: translate('iou.pendingMatchWithCreditCardDescription'),
shouldShowBorderBottom: !showFullWidthMarkAsCashButton,
};
}
};

Expand Down Expand Up @@ -234,7 +239,19 @@ function MoneyRequestHeader({
policy={policy}
shouldShowBackButton={shouldUseNarrowLayout}
onBackButtonPress={onBackButtonPress}
/>
>
{!isSmallScreenWidth && hasAllPendingRTERViolations && (
<Button
success
medium
text={translate('iou.markAsCash')}
style={[styles.p0]}
onPress={() => {
TransactionActions.markAsCash(transaction?.transactionID ?? '', transaction?.reportID ?? '');
}}
/>
)}
</HeaderWithBackButton>
{statusBarProps && (
<MoneyRequestHeaderStatusBar
title={statusBarProps.title}
Expand All @@ -243,7 +260,7 @@ function MoneyRequestHeader({
shouldShowBorderBottom={statusBarProps.shouldShowBorderBottom}
/>
)}
{hasAllPendingRTERViolations && (
{showFullWidthMarkAsCashButton && (
<View style={[styles.ph5, styles.pb3, styles.borderBottom]}>
<Button
medium
Expand Down

0 comments on commit 13e8335

Please sign in to comment.