Skip to content

Commit

Permalink
fix: receipt in dupe detect is removable
Browse files Browse the repository at this point in the history
  • Loading branch information
gijoe0295 committed Aug 16, 2024
1 parent 5e5bff3 commit 459b12d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ const ROUTES = {

TRANSACTION_RECEIPT: {
route: 'r/:reportID/transaction/:transactionID/receipt',
getRoute: (reportID: string, transactionID: string) => `r/${reportID}/transaction/${transactionID}/receipt` as const,
getRoute: (reportID: string, transactionID: string, readonly = false) => `r/${reportID}/transaction/${transactionID}/receipt${readonly ? '?readonly=true' : ''}` as const,
},
TRANSACTION_DUPLICATE_REVIEW_PAGE: {
route: 'r/:threadReportID/duplicates/review',
Expand Down
1 change: 1 addition & 0 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ function MoneyRequestView({
filename={receiptURIs?.filename}
transaction={transaction}
enablePreviewModal
readonly={readonly}
/>
</View>
)}
Expand Down
8 changes: 7 additions & 1 deletion src/components/ReportActionItem/ReportActionItemImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ type ReportActionItemImageProps = {

/** Whether the map view should have border radius */
shouldMapHaveBorderRadius?: boolean;

/** Whether the receipt is not editable */
readonly?: boolean;
};

/**
Expand All @@ -70,6 +73,7 @@ function ReportActionItemImage({
fileExtension,
filename,
isSingleImage = true,
readonly = false,
shouldMapHaveBorderRadius,
}: ReportActionItemImageProps) {
const styles = useThemeStyles();
Expand Down Expand Up @@ -130,7 +134,9 @@ function ReportActionItemImage({
<PressableWithoutFocus
style={[styles.w100, styles.h100, styles.noOutline as ViewStyle]}
onPress={() =>
Navigation.navigate(ROUTES.TRANSACTION_RECEIPT.getRoute(transactionThreadReport?.reportID ?? report?.reportID ?? '-1', transaction?.transactionID ?? '-1'))
Navigation.navigate(
ROUTES.TRANSACTION_RECEIPT.getRoute(transactionThreadReport?.reportID ?? report?.reportID ?? '-1', transaction?.transactionID ?? '-1', readonly),
)
}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
accessibilityRole={CONST.ROLE.BUTTON}
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,7 @@ type AuthScreensParamList = CentralPaneScreensParamList &
[SCREENS.TRANSACTION_RECEIPT]: {
reportID: string;
transactionID: string;
readonly?: boolean;
};
[SCREENS.CONNECTION_COMPLETE]: undefined;
};
Expand Down
3 changes: 2 additions & 1 deletion src/pages/TransactionReceiptPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function TransactionReceipt({transaction, report, reportMetadata = {isLoadingIni
const imageSource = tryResolveUrlFromApiRoot(receiptURIs.image ?? '');

const isLocalFile = receiptURIs.isLocalFile;
const readonly = route.params.readonly ?? false;

const parentReportAction = ReportActionUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1');
const canEditReceipt = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.RECEIPT);
Expand Down Expand Up @@ -58,7 +59,7 @@ function TransactionReceipt({transaction, report, reportMetadata = {isLoadingIni
isAuthTokenRequired={!isLocalFile}
report={report}
isReceiptAttachment
canEditReceipt={canEditReceipt}
canEditReceipt={canEditReceipt && !readonly}
allowDownload={!isEReceipt}
isTrackExpenseAction={isTrackExpenseAction}
originalFileName={receiptURIs?.filename}
Expand Down

0 comments on commit 459b12d

Please sign in to comment.