Skip to content

Commit

Permalink
Merge pull request #38135 from rezkiy37/feature/37366-OpenPolicyMoreF…
Browse files Browse the repository at this point in the history
…eaturesPage-command

Integrate OpenPolicyMoreFeaturesPage command
  • Loading branch information
mountiny authored Mar 13, 2024
2 parents 5ab989b + 9d5fed6 commit 54b0a7c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/libs/API/parameters/OpenPolicyMoreFeaturesPageParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type OpenPolicyMoreFeaturesPageParams = {
policyID: string;
};

export default OpenPolicyMoreFeaturesPageParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,5 @@ export type {default as DeclineJoinRequestParams} from './DeclineJoinRequest';
export type {default as JoinPolicyInviteLinkParams} from './JoinPolicyInviteLink';
export type {default as OpenPolicyWorkflowsPageParams} from './OpenPolicyWorkflowsPageParams';
export type {default as OpenPolicyDistanceRatesPageParams} from './OpenPolicyDistanceRatesPageParams';
export type {default as OpenPolicyMoreFeaturesPageParams} from './OpenPolicyMoreFeaturesPageParams';
export type {default as CreatePolicyTagsParams} from './CreatePolicyTagsParams';
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ const READ_COMMANDS = {
OPEN_DRAFT_WORKSPACE_REQUEST: 'OpenDraftWorkspaceRequest',
OPEN_POLICY_WORKFLOWS_PAGE: 'OpenPolicyWorkflowsPage',
OPEN_POLICY_DISTANCE_RATES_PAGE: 'OpenPolicyDistanceRatesPage',
OPEN_POLICY_MORE_FEATURES_PAGE: 'OpenPolicyMoreFeaturesPage',
} as const;

type ReadCommand = ValueOf<typeof READ_COMMANDS>;
Expand Down Expand Up @@ -418,6 +419,7 @@ type ReadCommandParameters = {
[READ_COMMANDS.OPEN_DRAFT_WORKSPACE_REQUEST]: Parameters.OpenDraftWorkspaceRequestParams;
[READ_COMMANDS.OPEN_POLICY_WORKFLOWS_PAGE]: Parameters.OpenPolicyWorkflowsPageParams;
[READ_COMMANDS.OPEN_POLICY_DISTANCE_RATES_PAGE]: Parameters.OpenPolicyDistanceRatesPageParams;
[READ_COMMANDS.OPEN_POLICY_MORE_FEATURES_PAGE]: Parameters.OpenPolicyMoreFeaturesPageParams;
};

const SIDE_EFFECT_REQUEST_COMMANDS = {
Expand Down
8 changes: 8 additions & 0 deletions src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type {
OpenDraftWorkspaceRequestParams,
OpenPolicyCategoriesPageParams,
OpenPolicyDistanceRatesPageParams,
OpenPolicyMoreFeaturesPageParams,
OpenPolicyTagsPageParams,
OpenPolicyWorkflowsPageParams,
OpenWorkspaceInvitePageParams,
Expand Down Expand Up @@ -3492,6 +3493,12 @@ function setPolicyRequiresTag(policyID: string, requiresTag: boolean) {
API.write(WRITE_COMMANDS.SET_POLICY_REQUIRES_TAG, parameters, onyxData);
}

function openPolicyMoreFeaturesPage(policyID: string) {
const params: OpenPolicyMoreFeaturesPageParams = {policyID};

API.read(READ_COMMANDS.OPEN_POLICY_MORE_FEATURES_PAGE, params);
}

export {
removeMembers,
updateWorkspaceMembersRole,
Expand Down Expand Up @@ -3561,6 +3568,7 @@ export {
enablePolicyTaxes,
enablePolicyWorkflows,
openPolicyDistanceRatesPage,
openPolicyMoreFeaturesPage,
createPolicyTag,
clearWorkspaceReimbursementErrors,
deleteWorkspaceCategories,
Expand Down
14 changes: 13 additions & 1 deletion src/pages/workspace/WorkspaceMoreFeaturesPage.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type {StackScreenProps} from '@react-navigation/stack';
import React, {useCallback} from 'react';
import React, {useCallback, useEffect} from 'react';
import {View} from 'react-native';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import * as Illustrations from '@components/Icon/Illustrations';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
import Section from '@components/Section';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import type {WorkspacesCentralPaneNavigatorParamList} from '@libs/Navigation/types';
Expand Down Expand Up @@ -141,6 +142,17 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
[isSmallScreenWidth, styles, renderItem, translate],
);

function fetchFeatures() {
Policy.openPolicyMoreFeaturesPage(route.params.policyID);
}

useNetwork({onReconnect: fetchFeatures});

useEffect(() => {
fetchFeatures();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<AdminPolicyAccessOrNotFoundWrapper policyID={route.params.policyID}>
<PaidPolicyAccessOrNotFoundWrapper policyID={route.params.policyID}>
Expand Down

0 comments on commit 54b0a7c

Please sign in to comment.