-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Show not found for invalid report or transaction in review duplicates confirmation page #45965
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
Changes from 6 commits
dcfd9e7
57113d5
d0dec61
25dd71a
d235782
b001f62
a6f5190
e854d85
e08a9bd
270ffd1
9f2294e
37d8dd0
2f6fe1e
f4e8685
4d8ae30
b2ee36c
545d78e
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 | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,12 +1,13 @@ | ||||||||||||||||||||
import type {RouteProp} from '@react-navigation/native'; | ||||||||||||||||||||
import {useRoute} from '@react-navigation/native'; | ||||||||||||||||||||
import React, {useCallback, useMemo} from 'react'; | ||||||||||||||||||||
import {useNavigation, useRoute} from '@react-navigation/native'; | ||||||||||||||||||||
import React, {useCallback, useEffect, useMemo, useState} from 'react'; | ||||||||||||||||||||
import {View} from 'react-native'; | ||||||||||||||||||||
import type {OnyxEntry} from 'react-native-onyx'; | ||||||||||||||||||||
import {useOnyx} from 'react-native-onyx'; | ||||||||||||||||||||
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; | ||||||||||||||||||||
import Button from '@components/Button'; | ||||||||||||||||||||
import FixedFooter from '@components/FixedFooter'; | ||||||||||||||||||||
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; | ||||||||||||||||||||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||||||||||||||||||||
import MoneyRequestView from '@components/ReportActionItem/MoneyRequestView'; | ||||||||||||||||||||
import ScreenWrapper from '@components/ScreenWrapper'; | ||||||||||||||||||||
|
@@ -20,17 +21,21 @@ import type {TransactionDuplicateNavigatorParamList} from '@libs/Navigation/type | |||||||||||||||||||
import variables from '@styles/variables'; | ||||||||||||||||||||
import * as IOU from '@src/libs/actions/IOU'; | ||||||||||||||||||||
import * as ReportActionsUtils from '@src/libs/ReportActionsUtils'; | ||||||||||||||||||||
import * as ReportUtils from '@src/libs/ReportUtils'; | ||||||||||||||||||||
import * as TransactionUtils from '@src/libs/TransactionUtils'; | ||||||||||||||||||||
import ONYXKEYS from '@src/ONYXKEYS'; | ||||||||||||||||||||
import ROUTES from '@src/ROUTES'; | ||||||||||||||||||||
import type SCREENS from '@src/SCREENS'; | ||||||||||||||||||||
import type {Transaction} from '@src/types/onyx'; | ||||||||||||||||||||
import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||||||||||||||||||||
|
||||||||||||||||||||
function Confirmation() { | ||||||||||||||||||||
const styles = useThemeStyles(); | ||||||||||||||||||||
const {translate} = useLocalize(); | ||||||||||||||||||||
const navigation = useNavigation(); | ||||||||||||||||||||
const route = useRoute<RouteProp<TransactionDuplicateNavigatorParamList, typeof SCREENS.TRANSACTION_DUPLICATE.REVIEW>>(); | ||||||||||||||||||||
const [reviewDuplicates] = useOnyx(ONYXKEYS.REVIEW_DUPLICATES); | ||||||||||||||||||||
const [isExiting, setIsExiting] = useState(false); | ||||||||||||||||||||
const [reviewDuplicates, {status}] = useOnyx(ONYXKEYS.REVIEW_DUPLICATES); | ||||||||||||||||||||
gijoe0295 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
const transaction = useMemo(() => TransactionUtils.buildNewTransactionAfterReviewingDuplicates(reviewDuplicates), [reviewDuplicates]); | ||||||||||||||||||||
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`); | ||||||||||||||||||||
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transaction?.reportID}`); | ||||||||||||||||||||
|
@@ -56,13 +61,28 @@ function Confirmation() { | |||||||||||||||||||
[report, reportAction], | ||||||||||||||||||||
); | ||||||||||||||||||||
|
||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||
const unsubscribeBeforeRemove = navigation.addListener('beforeRemove', () => { | ||||||||||||||||||||
setIsExiting(true); | ||||||||||||||||||||
}); | ||||||||||||||||||||
|
||||||||||||||||||||
return unsubscribeBeforeRemove; | ||||||||||||||||||||
}, [navigation]); | ||||||||||||||||||||
|
||||||||||||||||||||
if (status === 'loading') { | ||||||||||||||||||||
gijoe0295 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
return <FullScreenLoadingIndicator />; | ||||||||||||||||||||
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. Due to the |
||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
// eslint-disable-next-line rulesdir/no-negated-variables | ||||||||||||||||||||
const shouldShowNotFoundPage = isEmptyObject(report) || ReportUtils.isReportNotFound(report) || (!isExiting && status === 'loaded' && !transaction?.transactionID); | ||||||||||||||||||||
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. When
When we close the confirmation page RHP, it would be reset due to:
so not found page would briefly show when the RHP is closing. 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. I see. Is there a better way to manage the 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. @parasharrajat As you've reviewed the duplicate confirmation PR, could you let me know what these lines are for?
In other words, when exactly should I just want to confirm if 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 tells that If user is leaving from 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. @parasharrajat 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. Even if 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. OK. I am fine with the approach for now. |
||||||||||||||||||||
|
||||||||||||||||||||
return ( | ||||||||||||||||||||
<ScreenWrapper | ||||||||||||||||||||
testID={Confirmation.displayName} | ||||||||||||||||||||
shouldShowOfflineIndicator | ||||||||||||||||||||
> | ||||||||||||||||||||
{({safeAreaPaddingBottomStyle}) => ( | ||||||||||||||||||||
<FullPageNotFoundView shouldShow={!reviewDuplicates}> | ||||||||||||||||||||
<FullPageNotFoundView shouldShow={shouldShowNotFoundPage}> | ||||||||||||||||||||
<View style={[styles.flex1, safeAreaPaddingBottomStyle]}> | ||||||||||||||||||||
<HeaderWithBackButton title={translate('iou.reviewDuplicates')} /> | ||||||||||||||||||||
<ScrollView> | ||||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.