Skip to content

Commit 8f6c812

Browse files
committed
Add AccessOrNotFoundWrapper
1 parent 234bdfd commit 8f6c812

2 files changed

Lines changed: 50 additions & 34 deletions

File tree

src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import useThemeStyles from '@hooks/useThemeStyles';
1010
import Navigation from '@libs/Navigation/Navigation';
1111
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
1212
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
13+
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
1314
import {setPolicyCustomUnitDefaultCategory} from '@userActions/Policy/Category';
15+
import CONST from '@src/CONST';
1416
import ONYXKEYS from '@src/ONYXKEYS';
1517
import {DYNAMIC_ROUTES} from '@src/ROUTES';
1618
import type SCREENS from '@src/SCREENS';
@@ -38,24 +40,30 @@ function DynamicDefaultCategorySelectorPage({route}: DynamicDefaultCategorySelec
3840
};
3941

4042
return (
41-
<ScreenWrapper
42-
style={styles.pb0}
43-
enableEdgeToEdgeBottomSafeAreaPadding
44-
shouldEnableKeyboardAvoidingView={false}
45-
testID="DynamicDefaultCategorySelectorPage"
43+
<AccessOrNotFoundWrapper
44+
policyID={policyID}
45+
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
46+
featureName={CONST.POLICY.MORE_FEATURES.ARE_CATEGORIES_ENABLED}
4647
>
47-
<HeaderWithBackButton
48-
title={translate('workspace.common.defaultCategory')}
49-
shouldShowBackButton
50-
onBackButtonPress={() => Navigation.goBack(backPath)}
51-
/>
52-
<CategoryPicker
53-
policyID={policyID}
54-
selectedCategory={currentCategory}
55-
onSubmit={onCategorySelected}
56-
addBottomSafeAreaPadding
57-
/>
58-
</ScreenWrapper>
48+
<ScreenWrapper
49+
style={styles.pb0}
50+
enableEdgeToEdgeBottomSafeAreaPadding
51+
shouldEnableKeyboardAvoidingView={false}
52+
testID="DynamicDefaultCategorySelectorPage"
53+
>
54+
<HeaderWithBackButton
55+
title={translate('workspace.common.defaultCategory')}
56+
shouldShowBackButton
57+
onBackButtonPress={() => Navigation.goBack(backPath)}
58+
/>
59+
<CategoryPicker
60+
policyID={policyID}
61+
selectedCategory={currentCategory}
62+
onSubmit={onCategorySelected}
63+
addBottomSafeAreaPadding
64+
/>
65+
</ScreenWrapper>
66+
</AccessOrNotFoundWrapper>
5967
);
6068
}
6169

src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import useThemeStyles from '@hooks/useThemeStyles';
99
import Navigation from '@libs/Navigation/Navigation';
1010
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
1111
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
12+
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
1213
import {setWorkspaceDefaultSpendCategory} from '@userActions/Policy/Policy';
14+
import CONST from '@src/CONST';
1315
import ONYXKEYS from '@src/ONYXKEYS';
1416
import {DYNAMIC_ROUTES} from '@src/ROUTES';
1517
import type SCREENS from '@src/SCREENS';
@@ -38,24 +40,30 @@ function DynamicSpendCategorySelectorPage({route}: DynamicSpendCategorySelectorP
3840
};
3941

4042
return (
41-
<ScreenWrapper
42-
style={styles.pb0}
43-
enableEdgeToEdgeBottomSafeAreaPadding
44-
shouldEnableKeyboardAvoidingView={false}
45-
testID="DynamicSpendCategorySelectorPage"
43+
<AccessOrNotFoundWrapper
44+
policyID={policyID}
45+
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
46+
featureName={CONST.POLICY.MORE_FEATURES.ARE_CATEGORIES_ENABLED}
4647
>
47-
<HeaderWithBackButton
48-
title={label}
49-
shouldShowBackButton
50-
onBackButtonPress={() => Navigation.goBack(backPath)}
51-
/>
52-
<CategoryPicker
53-
policyID={policyID}
54-
selectedCategory={currentCategory}
55-
onSubmit={onCategorySelected}
56-
addBottomSafeAreaPadding
57-
/>
58-
</ScreenWrapper>
48+
<ScreenWrapper
49+
style={styles.pb0}
50+
enableEdgeToEdgeBottomSafeAreaPadding
51+
shouldEnableKeyboardAvoidingView={false}
52+
testID="DynamicSpendCategorySelectorPage"
53+
>
54+
<HeaderWithBackButton
55+
title={label}
56+
shouldShowBackButton
57+
onBackButtonPress={() => Navigation.goBack(backPath)}
58+
/>
59+
<CategoryPicker
60+
policyID={policyID}
61+
selectedCategory={currentCategory}
62+
onSubmit={onCategorySelected}
63+
addBottomSafeAreaPadding
64+
/>
65+
</ScreenWrapper>
66+
</AccessOrNotFoundWrapper>
5967
);
6068
}
6169

0 commit comments

Comments
 (0)