@@ -2,20 +2,32 @@ import type {StackScreenProps} from '@react-navigation/stack';
2
2
import React from 'react' ;
3
3
import ImportSpreedsheet from '@components/ImportSpreadsheet' ;
4
4
import type { SettingsNavigatorParamList } from '@libs/Navigation/types' ;
5
+ import * as PolicyUtils from '@libs/PolicyUtils' ;
6
+ import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper' ;
7
+ import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading' ;
8
+ import type { WithPolicyAndFullscreenLoadingProps } from '@pages/workspace/withPolicyAndFullscreenLoading' ;
9
+ import CONST from '@src/CONST' ;
5
10
import ROUTES from '@src/ROUTES' ;
6
11
import type SCREENS from '@src/SCREENS' ;
12
+ import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
7
13
8
- type ImportMembersPageProps = StackScreenProps < SettingsNavigatorParamList , typeof SCREENS . WORKSPACE . MEMBERS_IMPORT > ;
14
+ type ImportMembersPageProps = WithPolicyAndFullscreenLoadingProps & StackScreenProps < SettingsNavigatorParamList , typeof SCREENS . WORKSPACE . MEMBERS_IMPORT > ;
9
15
10
- function ImportMembersPage ( { route } : ImportMembersPageProps ) {
11
- const policyID = route . params . policyID ;
16
+ function ImportMembersPage ( { policy } : ImportMembersPageProps ) {
17
+ const policyID = policy ?. id ?? '' ;
12
18
13
19
return (
14
- < ImportSpreedsheet
15
- backTo = { ROUTES . WORKSPACE_MEMBERS . getRoute ( policyID ) }
16
- goTo = { ROUTES . WORKSPACE_MEMBERS_IMPORTED . getRoute ( policyID ) }
17
- />
20
+ < AccessOrNotFoundWrapper
21
+ policyID = { policyID }
22
+ accessVariants = { [ CONST . POLICY . ACCESS_VARIANTS . ADMIN ] }
23
+ fullPageNotFoundViewProps = { { subtitleKey : isEmptyObject ( policy ) ? undefined : 'workspace.common.notAuthorized' , onLinkPress : PolicyUtils . goBackFromInvalidPolicy } }
24
+ >
25
+ < ImportSpreedsheet
26
+ backTo = { ROUTES . WORKSPACE_MEMBERS . getRoute ( policyID ) }
27
+ goTo = { ROUTES . WORKSPACE_MEMBERS_IMPORTED . getRoute ( policyID ) }
28
+ />
29
+ </ AccessOrNotFoundWrapper >
18
30
) ;
19
31
}
20
32
21
- export default ImportMembersPage ;
33
+ export default withPolicyAndFullscreenLoading ( ImportMembersPage ) ;
0 commit comments