Skip to content

Commit

Permalink
call method
Browse files Browse the repository at this point in the history
  • Loading branch information
luacmartins committed Feb 28, 2024
1 parent 85c7119 commit 9c0f565
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/libs/API/parameters/OpenPolicyCategoriesPageParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type OpenPolicyCategoriesPageParams = {
policyID: string;
};

export default OpenPolicyCategoriesPageParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export type {default as OpenWorkspaceViewParams} from './OpenWorkspaceViewParams
export type {default as OpenWorkspaceReimburseViewParams} from './OpenWorkspaceReimburseViewParams';
export type {default as OpenWorkspaceInvitePageParams} from './OpenWorkspaceInvitePageParams';
export type {default as OpenWorkspaceMembersPageParams} from './OpenWorkspaceMembersPageParams';
export type {default as OpenPolicyCategoriesPageParams} from './OpenPolicyCategoriesPageParams';
export type {default as OpenDraftWorkspaceRequestParams} from './OpenDraftWorkspaceRequestParams';
export type {default as UpdateWorkspaceCustomUnitAndRateParams} from './UpdateWorkspaceCustomUnitAndRateParams';
export type {default as CreateWorkspaceFromIOUPaymentParams} from './CreateWorkspaceFromIOUPaymentParams';
Expand Down
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ const READ_COMMANDS = {
OPEN_WORKSPACE_REIMBURSE_VIEW: 'OpenWorkspaceReimburseView',
OPEN_WORKSPACE: 'OpenWorkspace',
OPEN_WORKSPACE_MEMBERS_PAGE: 'OpenWorkspaceMembersPage',
OPEN_POLICY_CATEGORIES_PAGE: 'OpenPolicyCategoriesPage',
OPEN_WORKSPACE_INVITE_PAGE: 'OpenWorkspaceInvitePage',
OPEN_DRAFT_WORKSPACE_REQUEST: 'OpenDraftWorkspaceRequest',
} as const;
Expand Down Expand Up @@ -364,6 +365,7 @@ type ReadCommandParameters = {
[READ_COMMANDS.OPEN_WORKSPACE_REIMBURSE_VIEW]: Parameters.OpenWorkspaceReimburseViewParams;
[READ_COMMANDS.OPEN_WORKSPACE]: Parameters.OpenWorkspaceParams;
[READ_COMMANDS.OPEN_WORKSPACE_MEMBERS_PAGE]: Parameters.OpenWorkspaceMembersPageParams;
[READ_COMMANDS.OPEN_POLICY_CATEGORIES_PAGE]: Parameters.OpenPolicyCategoriesPageParams;
[READ_COMMANDS.OPEN_WORKSPACE_INVITE_PAGE]: Parameters.OpenWorkspaceInvitePageParams;
[READ_COMMANDS.OPEN_DRAFT_WORKSPACE_REQUEST]: Parameters.OpenDraftWorkspaceRequestParams;
};
Expand Down
15 changes: 15 additions & 0 deletions src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
OpenDraftWorkspaceRequestParams,
OpenWorkspaceInvitePageParams,
OpenWorkspaceMembersPageParams,
OpenPolicyCategoriesPageParams,
OpenWorkspaceParams,
OpenWorkspaceReimburseViewParams,
SetWorkspaceApprovalModeParams,
Expand Down Expand Up @@ -1673,6 +1674,19 @@ function openWorkspaceMembersPage(policyID: string, clientMemberEmails: string[]
API.read(READ_COMMANDS.OPEN_WORKSPACE_MEMBERS_PAGE, params);
}

function openPolicyCategoriesPage(policyID: string) {
if (!policyID) {
Log.warn('openPolicyCategoriesPage invalid params', {policyID});
return;
}

const params: OpenPolicyCategoriesPageParams = {
policyID,
};

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

function openWorkspaceInvitePage(policyID: string, clientMemberEmails: string[]) {
if (!policyID || !clientMemberEmails) {
Log.warn('openWorkspaceInvitePage invalid params', {policyID, clientMemberEmails});
Expand Down Expand Up @@ -2264,6 +2278,7 @@ export {
generatePolicyID,
createWorkspace,
openWorkspaceMembersPage,
openPolicyCategoriesPage,
openWorkspaceInvitePage,
openWorkspace,
removeWorkspace,
Expand Down
8 changes: 7 additions & 1 deletion src/pages/workspace/categories/WorkspaceCategoriesPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {StackScreenProps} from '@react-navigation/stack';
import React, {useMemo, useState} from 'react';
import React, {useMemo, useState, useEffect} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
Expand All @@ -25,6 +25,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';
import * as Policy from '@userActions/Policy';

type PolicyForList = {
value: string;
Expand All @@ -48,6 +49,11 @@ function WorkspaceCategoriesPage({policyCategories, route}: WorkspaceCategoriesP
const {translate} = useLocalize();
const [selectedCategories, setSelectedCategories] = useState<Record<string, boolean>>({});

useEffect(() => {
Policy.openPolicyCategoriesPage(route.params.policyID);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const categoryList = useMemo<PolicyForList[]>(
() =>
Object.values(policyCategories ?? {}).map((value) => ({
Expand Down

0 comments on commit 9c0f565

Please sign in to comment.