1
1
import React , { useEffect , useState } from 'react' ;
2
2
import type { ValueOf } from 'type-fest' ;
3
3
import DelegateNoAccessWrapper from '@components/DelegateNoAccessWrapper' ;
4
+ import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator' ;
4
5
import HeaderWithBackButton from '@components/HeaderWithBackButton' ;
5
6
import ScreenWrapper from '@components/ScreenWrapper' ;
6
7
import SelectionList from '@components/SelectionList' ;
@@ -25,8 +26,15 @@ function UpdateDelegateRolePage({route}: UpdateDelegateRolePageProps) {
25
26
const { translate} = useLocalize ( ) ;
26
27
const login = route . params . login ;
27
28
const currentRole = route . params . currentRole ;
28
- const [ isValidateCodeActionModalVisible , setIsValidateCodeActionModalVisible ] = useState ( false ) ;
29
- const [ newRole , setNewRole ] = useState < ValueOf < typeof CONST . DELEGATE_ROLE > | null > ( ) ;
29
+ const showValidateActionModalFromURL = route . params . showValidateActionModal === 'true' ;
30
+ const newRoleFromURL = route . params . newRole ;
31
+ const [ isValidateCodeActionModalVisible , setIsValidateCodeActionModalVisible ] = useState ( showValidateActionModalFromURL ?? false ) ;
32
+ const [ newRole , setNewRole ] = useState < ValueOf < typeof CONST . DELEGATE_ROLE > | undefined > ( newRoleFromURL ) ;
33
+ const [ shouldShowLoading , setShouldShowLoading ] = useState ( showValidateActionModalFromURL ?? false ) ;
34
+
35
+ useEffect ( ( ) => {
36
+ Navigation . setParams ( { showValidateActionModal : isValidateCodeActionModalVisible , newRole} ) ;
37
+ } , [ isValidateCodeActionModalVisible , newRole ] ) ;
30
38
31
39
const styles = useThemeStyles ( ) ;
32
40
const roleOptions = Object . values ( CONST . DELEGATE_ROLE ) . map ( ( role ) => ( {
@@ -89,11 +97,13 @@ function UpdateDelegateRolePage({route}: UpdateDelegateRolePageProps) {
89
97
role = { newRole }
90
98
isValidateCodeActionModalVisible = { isValidateCodeActionModalVisible }
91
99
onClose = { ( ) => {
100
+ setShouldShowLoading ( false ) ;
92
101
setIsValidateCodeActionModalVisible ( false ) ;
93
102
} }
94
103
/>
95
104
) }
96
105
</ DelegateNoAccessWrapper >
106
+ { shouldShowLoading && < FullScreenLoadingIndicator /> }
97
107
</ ScreenWrapper >
98
108
) ;
99
109
}
0 commit comments