Skip to content

Commit a175c8e

Browse files
authored
Merge pull request #49629 from mkzie2/fix/49179
2 parents ea12dd2 + ce39083 commit a175c8e

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/pages/workspace/tags/TagGLCodePage.tsx

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type {StackScreenProps} from '@react-navigation/stack';
22
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';
54
import FormProvider from '@components/Form/FormProvider';
65
import InputWrapper from '@components/Form/InputWrapper';
76
import type {FormOnyxValues} from '@components/Form/types';
@@ -10,6 +9,7 @@ import ScreenWrapper from '@components/ScreenWrapper';
109
import TextInput from '@components/TextInput';
1110
import useAutoFocusInput from '@hooks/useAutoFocusInput';
1211
import useLocalize from '@hooks/useLocalize';
12+
import usePolicy from '@hooks/usePolicy';
1313
import useThemeStyles from '@hooks/useThemeStyles';
1414
import Navigation from '@libs/Navigation/Navigation';
1515
import * as PolicyUtils from '@libs/PolicyUtils';
@@ -21,19 +21,15 @@ import ONYXKEYS from '@src/ONYXKEYS';
2121
import ROUTES from '@src/ROUTES';
2222
import type SCREENS from '@src/SCREENS';
2323
import INPUT_IDS from '@src/types/form/WorkspaceTagForm';
24-
import type {PolicyTagLists} from '@src/types/onyx';
2524

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>;
3026

31-
type EditTagGLCodePageProps = WorkspaceEditTagGLCodePageOnyxProps & StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.TAG_GL_CODE>;
32-
33-
function TagGLCodePage({route, policyTags}: EditTagGLCodePageProps) {
27+
function TagGLCodePage({route}: EditTagGLCodePageProps) {
3428
const styles = useThemeStyles();
3529
const {translate} = useLocalize();
3630
const {inputCallbackRef} = useAutoFocusInput();
31+
const policy = usePolicy(route.params.policyID);
32+
const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${route?.params?.policyID}`);
3733

3834
const tagName = route.params.tagName;
3935
const orderWeight = route.params.orderWeight;
@@ -60,6 +56,7 @@ function TagGLCodePage({route, policyTags}: EditTagGLCodePageProps) {
6056
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.CONTROL]}
6157
policyID={route.params.policyID}
6258
featureName={CONST.POLICY.MORE_FEATURES.ARE_CATEGORIES_ENABLED}
59+
shouldBeBlocked={PolicyUtils.hasAccountingConnections(policy)}
6360
>
6461
<ScreenWrapper
6562
includeSafeAreaPaddingBottom={false}
@@ -96,8 +93,4 @@ function TagGLCodePage({route, policyTags}: EditTagGLCodePageProps) {
9693

9794
TagGLCodePage.displayName = 'TagGLCodePage';
9895

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;

src/pages/workspace/tags/TagSettingsPage.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function TagSettingsPage({route, navigation}: TagSettingsPageProps) {
3737
const {translate} = useLocalize();
3838
const policyTag = useMemo(() => PolicyUtils.getTagList(policyTags, orderWeight), [policyTags, orderWeight]);
3939
const policy = usePolicy(policyID);
40+
const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy);
4041

4142
const [isDeleteTagModalOpen, setIsDeleteTagModalOpen] = React.useState(false);
4243

@@ -146,6 +147,8 @@ function TagSettingsPage({route, navigation}: TagSettingsPageProps) {
146147
title={currentPolicyTag['GL Code']}
147148
description={translate(`workspace.tags.glCode`)}
148149
onPress={navigateToEditGlCode}
150+
iconRight={hasAccountingConnections ? Expensicons.Lock : undefined}
151+
interactive={!hasAccountingConnections}
149152
shouldShowRightIcon
150153
/>
151154
</OfflineWithFeedback>

0 commit comments

Comments
 (0)