1
1
import type { StackScreenProps } from '@react-navigation/stack' ;
2
2
import React , { useCallback } from 'react' ;
3
- import { withOnyx } from 'react-native-onyx' ;
4
- import type { OnyxEntry } from 'react-native-onyx' ;
3
+ import { useOnyx } from 'react-native-onyx' ;
5
4
import FormProvider from '@components/Form/FormProvider' ;
6
5
import InputWrapper from '@components/Form/InputWrapper' ;
7
6
import type { FormOnyxValues } from '@components/Form/types' ;
@@ -10,6 +9,7 @@ import ScreenWrapper from '@components/ScreenWrapper';
10
9
import TextInput from '@components/TextInput' ;
11
10
import useAutoFocusInput from '@hooks/useAutoFocusInput' ;
12
11
import useLocalize from '@hooks/useLocalize' ;
12
+ import usePolicy from '@hooks/usePolicy' ;
13
13
import useThemeStyles from '@hooks/useThemeStyles' ;
14
14
import Navigation from '@libs/Navigation/Navigation' ;
15
15
import * as PolicyUtils from '@libs/PolicyUtils' ;
@@ -21,19 +21,15 @@ import ONYXKEYS from '@src/ONYXKEYS';
21
21
import ROUTES from '@src/ROUTES' ;
22
22
import type SCREENS from '@src/SCREENS' ;
23
23
import INPUT_IDS from '@src/types/form/WorkspaceTagForm' ;
24
- import type { PolicyTagLists } from '@src/types/onyx' ;
25
24
26
- type WorkspaceEditTagGLCodePageOnyxProps = {
27
- /** Collection of categories attached to a policy */
28
- policyTags : OnyxEntry < PolicyTagLists > ;
29
- } ;
25
+ type EditTagGLCodePageProps = StackScreenProps < SettingsNavigatorParamList , typeof SCREENS . WORKSPACE . TAG_GL_CODE > ;
30
26
31
- type EditTagGLCodePageProps = WorkspaceEditTagGLCodePageOnyxProps & StackScreenProps < SettingsNavigatorParamList , typeof SCREENS . WORKSPACE . TAG_GL_CODE > ;
32
-
33
- function TagGLCodePage ( { route, policyTags} : EditTagGLCodePageProps ) {
27
+ function TagGLCodePage ( { route} : EditTagGLCodePageProps ) {
34
28
const styles = useThemeStyles ( ) ;
35
29
const { translate} = useLocalize ( ) ;
36
30
const { inputCallbackRef} = useAutoFocusInput ( ) ;
31
+ const policy = usePolicy ( route . params . policyID ) ;
32
+ const [ policyTags ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY_TAGS } ${ route ?. params ?. policyID } ` ) ;
37
33
38
34
const tagName = route . params . tagName ;
39
35
const orderWeight = route . params . orderWeight ;
@@ -60,6 +56,7 @@ function TagGLCodePage({route, policyTags}: EditTagGLCodePageProps) {
60
56
accessVariants = { [ CONST . POLICY . ACCESS_VARIANTS . ADMIN , CONST . POLICY . ACCESS_VARIANTS . CONTROL ] }
61
57
policyID = { route . params . policyID }
62
58
featureName = { CONST . POLICY . MORE_FEATURES . ARE_CATEGORIES_ENABLED }
59
+ shouldBeBlocked = { PolicyUtils . hasAccountingConnections ( policy ) }
63
60
>
64
61
< ScreenWrapper
65
62
includeSafeAreaPaddingBottom = { false }
@@ -96,8 +93,4 @@ function TagGLCodePage({route, policyTags}: EditTagGLCodePageProps) {
96
93
97
94
TagGLCodePage . displayName = 'TagGLCodePage' ;
98
95
99
- export default withOnyx < EditTagGLCodePageProps , WorkspaceEditTagGLCodePageOnyxProps > ( {
100
- policyTags : {
101
- key : ( { route} ) => `${ ONYXKEYS . COLLECTION . POLICY_TAGS } ${ route ?. params ?. policyID } ` ,
102
- } ,
103
- } ) ( TagGLCodePage ) ;
96
+ export default TagGLCodePage ;
0 commit comments