Skip to content

Commit 37d72ea

Browse files
committed
Add logic for other page
1 parent 2c287ae commit 37d72ea

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/pages/iou/request/step/IOURequestEditReportCommon.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,19 @@ type Props = {
4848
removeFromReport?: () => void;
4949
isEditing?: boolean;
5050
isUnreported?: boolean;
51+
shouldShowNotFoundPage?: boolean;
5152
};
5253

53-
function IOURequestEditReportCommon({backTo, transactionsReports, selectReport, policyID: policyIDFromProps, removeFromReport, isEditing = false, isUnreported}: Props) {
54+
function IOURequestEditReportCommon({
55+
backTo,
56+
transactionsReports,
57+
selectReport,
58+
policyID: policyIDFromProps,
59+
removeFromReport,
60+
isEditing = false,
61+
isUnreported,
62+
shouldShowNotFoundPage = false,
63+
}: Props) {
5464
const {translate, localeCompare} = useLocalize();
5565
const {options} = useOptionsList();
5666
const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {selector: (reports) => mapOnyxCollectionItems(reports, reportSelector), canBeMissing: true});
@@ -119,7 +129,7 @@ function IOURequestEditReportCommon({backTo, transactionsReports, selectReport,
119129
shouldShowWrapper
120130
testID="IOURequestEditReportCommon"
121131
includeSafeAreaPaddingBottom
122-
shouldShowNotFoundPage={expenseReports.length === 0}
132+
shouldShowNotFoundPage={expenseReports.length === 0 || shouldShowNotFoundPage}
123133
>
124134
<SelectionList
125135
sections={[{data: reportOptions}]}

src/pages/iou/request/step/IOURequestStepDistance.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import DotIndicatorMessage from '@components/DotIndicatorMessage';
1313
import DraggableList from '@components/DraggableList';
1414
import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails';
1515
import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails';
16+
import useCanEditStep from '@hooks/useCanEditStep';
1617
import useFetchRoute from '@hooks/useFetchRoute';
1718
import useLocalize from '@hooks/useLocalize';
1819
import useNetwork from '@hooks/useNetwork';
@@ -139,6 +140,7 @@ function IOURequestStepDistance({
139140
const [recentWaypoints, {status: recentWaypointsStatus}] = useOnyx(ONYXKEYS.NVP_RECENT_WAYPOINTS, {canBeMissing: true});
140141
const iouRequestType = getRequestType(transaction);
141142
const customUnitRateID = getRateID(transaction);
143+
const [canEditDistance] = useCanEditStep(action, iouType, report, CONST.EDIT_REQUEST_FIELD.DISTANCE);
142144

143145
// Sets `amount` and `split` share data before moving to the next step to avoid briefly showing `0.00` as the split share for participants
144146
const setDistanceRequestData = useCallback(
@@ -529,7 +531,7 @@ function IOURequestStepDistance({
529531
headerTitle={translate('common.distance')}
530532
onBackButtonPress={navigateBack}
531533
testID={IOURequestStepDistance.displayName}
532-
shouldShowNotFoundPage={isEditing && !transaction?.comment?.waypoints}
534+
shouldShowNotFoundPage={(isEditing && !transaction?.comment?.waypoints) || !canEditDistance}
533535
shouldShowWrapper={!isCreatingNewRequest}
534536
>
535537
<>

src/pages/iou/request/step/IOURequestStepReport.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import {InteractionManager} from 'react-native';
33
import type {ListItem} from '@components/SelectionList/types';
4+
import useCanEditStep from '@hooks/useCanEditStep';
45
import useOnyx from '@hooks/useOnyx';
56
import {changeTransactionsReport, setTransactionReport} from '@libs/actions/Transaction';
67
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
@@ -126,6 +127,8 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) {
126127
Navigation.dismissModal();
127128
};
128129

130+
const [canEditReport] = useCanEditStep(action, iouType, reportOrDraftReport, CONST.EDIT_REQUEST_FIELD.REPORT);
131+
129132
return (
130133
<IOURequestEditReportCommon
131134
backTo={backTo}
@@ -135,6 +138,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) {
135138
removeFromReport={removeFromReport}
136139
isEditing={isEditing}
137140
isUnreported={isUnreported}
141+
shouldShowNotFoundPage={!canEditReport}
138142
/>
139143
);
140144
}

0 commit comments

Comments
 (0)