1
1
import { useFocusEffect , useIsFocused } from '@react-navigation/native' ;
2
+ import type { StackScreenProps } from '@react-navigation/stack' ;
2
3
import React , { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
3
4
import { ActivityIndicator , View } from 'react-native' ;
4
5
import { useOnyx } from 'react-native-onyx' ;
5
- import type { OnyxEntry } from 'react-native-onyx' ;
6
6
import Button from '@components/Button' ;
7
7
import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu' ;
8
8
import type { DropdownOption } from '@components/ButtonWithDropdownMenu/types' ;
@@ -28,30 +28,24 @@ import {deleteWorkspaceCategories, setWorkspaceCategoryEnabled} from '@libs/acti
28
28
import * as DeviceCapabilities from '@libs/DeviceCapabilities' ;
29
29
import localeCompare from '@libs/LocaleCompare' ;
30
30
import Navigation from '@libs/Navigation/Navigation' ;
31
+ import type { WorkspacesCentralPaneNavigatorParamList } from '@libs/Navigation/types' ;
31
32
import * as PolicyUtils from '@libs/PolicyUtils' ;
32
33
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper' ;
33
- import type { WithPolicyConnectionsProps } from '@pages/workspace/withPolicyConnections' ;
34
- import withPolicyConnections from '@pages/workspace/withPolicyConnections' ;
35
34
import * as Policy from '@userActions/Policy' ;
36
35
import CONST from '@src/CONST' ;
37
36
import ONYXKEYS from '@src/ONYXKEYS' ;
38
37
import ROUTES from '@src/ROUTES' ;
39
- import type * as OnyxTypes from '@src/types/onyx ' ;
38
+ import type SCREENS from '@src/SCREENS ' ;
40
39
import type DeepValueOf from '@src/types/utils/DeepValueOf' ;
41
40
42
41
type PolicyOption = ListItem & {
43
42
/** Category name is used as a key for the selectedCategories state */
44
43
keyForList : string ;
45
44
} ;
46
45
47
- type WorkspaceCategoriesPageOnyxProps = {
48
- /** The policy the user is accessing. */
49
- policy : OnyxEntry < OnyxTypes . Policy > ;
50
- } ;
51
-
52
- type WorkspaceCategoriesPageProps = WithPolicyConnectionsProps & WorkspaceCategoriesPageOnyxProps ;
46
+ type WorkspaceCategoriesPageProps = StackScreenProps < WorkspacesCentralPaneNavigatorParamList , typeof SCREENS . WORKSPACE . CATEGORIES > ;
53
47
54
- function WorkspaceCategoriesPage ( { policy , route} : WorkspaceCategoriesPageProps ) {
48
+ function WorkspaceCategoriesPage ( { route} : WorkspaceCategoriesPageProps ) {
55
49
const { isSmallScreenWidth} = useWindowDimensions ( ) ;
56
50
const styles = useThemeStyles ( ) ;
57
51
const theme = useTheme ( ) ;
@@ -62,6 +56,7 @@ function WorkspaceCategoriesPage({policy, route}: WorkspaceCategoriesPageProps)
62
56
const isFocused = useIsFocused ( ) ;
63
57
const { environmentURL} = useEnvironment ( ) ;
64
58
const policyId = route . params . policyID ?? '' ;
59
+ const [ policy ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY } ${ policyId } ` ) ;
65
60
const [ policyCategories ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY_CATEGORIES } ${ policyId } ` ) ;
66
61
67
62
const fetchCategories = useCallback ( ( ) => {
@@ -329,4 +324,4 @@ function WorkspaceCategoriesPage({policy, route}: WorkspaceCategoriesPageProps)
329
324
330
325
WorkspaceCategoriesPage . displayName = 'WorkspaceCategoriesPage' ;
331
326
332
- export default withPolicyConnections ( WorkspaceCategoriesPage ) ;
327
+ export default WorkspaceCategoriesPage ;
0 commit comments