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

fix: receipt in dupe detect is removable #47536

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

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

route param returns string and we are considering it as a boolean which causes a bug related to it here.


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
Loading