@@ -2,18 +2,23 @@ import {PortalHost} from '@gorhom/portal';
22import React from 'react' ;
33import type { ViewStyle } from 'react-native' ;
44import { View } from 'react-native' ;
5+ import OfflineWithFeedback from '@components/OfflineWithFeedback' ;
56import ScreenWrapper from '@components/ScreenWrapper' ;
67import WideRHPOverlayWrapper from '@components/WideRHPOverlayWrapper' ;
78import useActionListContextValue from '@hooks/useActionListContextValue' ;
89import { useCurrentReportIDState } from '@hooks/useCurrentReportID' ;
10+ import useOnyx from '@hooks/useOnyx' ;
911import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
1012import useSubmitToDestinationVisible from '@hooks/useSubmitToDestinationVisible' ;
1113import useThemeStyles from '@hooks/useThemeStyles' ;
1214import useViewportOffsetTop from '@hooks/useViewportOffsetTop' ;
15+ import { removeFailedReport } from '@libs/actions/Report' ;
1316import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID' ;
17+ import Navigation from '@libs/Navigation/Navigation' ;
1418import type { PlatformStackScreenProps } from '@libs/Navigation/PlatformStackNavigation/types' ;
1519import type { ReportsSplitNavigatorParamList , RightModalNavigatorParamList } from '@navigation/types' ;
1620import CONST from '@src/CONST' ;
21+ import ONYXKEYS from '@src/ONYXKEYS' ;
1722import SCREENS from '@src/SCREENS' ;
1823import AccountManagerBanner from './AccountManagerBanner' ;
1924import { AgentZeroStatusProvider } from './AgentZeroStatusContext' ;
@@ -63,6 +68,20 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
6368
6469 const actionListValue = useActionListContextValue ( ) ;
6570
71+ const [ reportPendingActionAndErrors ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ reportIDFromRoute } ` , {
72+ selector : ( r ) => ( {
73+ reportPendingAction : r ?. pendingFields ?. addWorkspaceRoom ?? r ?. pendingFields ?. createChat ?? r ?. pendingFields ?. createReport ?? r ?. pendingFields ?. reportName ,
74+ reportErrors : r ?. errorFields ?. addWorkspaceRoom ?? r ?. errorFields ?. createChat ?? r ?. errorFields ?. createReport ,
75+ } ) ,
76+ } ) ;
77+ const { reportPendingAction, reportErrors} = reportPendingActionAndErrors ?? { } ;
78+
79+ const dismissReportCreationError = ( ) => {
80+ Navigation . goBack ( undefined , {
81+ afterTransition : ( ) => removeFailedReport ( reportIDFromRoute ) ,
82+ } ) ;
83+ } ;
84+
6685 return (
6786 < WideRHPOverlayWrapper shouldWrap = { route . name === SCREENS . RIGHT_MODAL . SEARCH_REPORT } >
6887 < ActionListContext . Provider value = { actionListValue } >
@@ -87,20 +106,30 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
87106 { ! shouldDeferNonEssentials && < ReportLifecycleHandler reportID = { reportIDFromRoute } /> }
88107 < ReportHeader />
89108 { ! shouldDeferNonEssentials && < AccountManagerBanner reportID = { reportIDFromRoute } /> }
90- < View style = { [ styles . flex1 , styles . flexRow ] } >
91- { ! shouldDeferNonEssentials && < WideRHPReceiptPanel /> }
92- < AgentZeroStatusProvider reportID = { reportIDFromRoute } >
93- < ConciergeDraftProvider reportID = { reportIDFromRoute } >
94- < View
95- style = { [ styles . flex1 , styles . justifyContentEnd , styles . overflowHidden ] }
96- testID = "report-actions-view-wrapper"
97- >
98- < ReportActionsList />
99- { shouldDeferNonEssentials ? < ReportActionComposePlaceholder /> : < ReportFooter /> }
100- </ View >
101- </ ConciergeDraftProvider >
102- </ AgentZeroStatusProvider >
103- </ View >
109+ < OfflineWithFeedback
110+ pendingAction = { reportPendingAction }
111+ errors = { reportErrors }
112+ onClose = { dismissReportCreationError }
113+ needsOffscreenAlphaCompositing
114+ style = { styles . flex1 }
115+ contentContainerStyle = { styles . flex1 }
116+ errorRowStyles = { [ styles . ph5 , styles . mv2 ] }
117+ >
118+ < View style = { [ styles . flex1 , styles . flexRow ] } >
119+ { ! shouldDeferNonEssentials && < WideRHPReceiptPanel /> }
120+ < AgentZeroStatusProvider reportID = { reportIDFromRoute } >
121+ < ConciergeDraftProvider reportID = { reportIDFromRoute } >
122+ < View
123+ style = { [ styles . flex1 , styles . justifyContentEnd , styles . overflowHidden ] }
124+ testID = "report-actions-view-wrapper"
125+ >
126+ < ReportActionsList />
127+ { shouldDeferNonEssentials ? < ReportActionComposePlaceholder /> : < ReportFooter /> }
128+ </ View >
129+ </ ConciergeDraftProvider >
130+ </ AgentZeroStatusProvider >
131+ </ View >
132+ </ OfflineWithFeedback >
104133 < PortalHost name = "suggestions" />
105134 </ ReportDragAndDropProvider >
106135 </ LinkedActionNotFoundGuard >
0 commit comments