Skip to content

Commit

Permalink
refactor: change & rename logic isCollectPolicy to isPaidPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
ArekChr committed Feb 20, 2024
1 parent 729abf6 commit 7d3eadd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ function isExpensifyGuideTeam(email: string): boolean {
*/
const isPolicyAdmin = (policy: OnyxEntry<Policy> | EmptyObject): boolean => policy?.role === CONST.POLICY.ROLE.ADMIN;

const isCollectPolicy = (policy: OnyxEntry<Policy> | EmptyObject): boolean => policy?.type === CONST.POLICY.TYPE.TEAM;

const isFreePolicy = (policy: OnyxEntry<Policy> | EmptyObject): boolean => policy?.type === CONST.POLICY.TYPE.FREE;
/**
* Checks if the policy is a free group policy.
*/
const isFreeGroupPolicy = (policy: OnyxEntry<Policy> | EmptyObject): boolean => policy?.type === CONST.POLICY.TYPE.FREE;

const isPolicyMember = (policyID: string, policies: OnyxCollection<Policy>): boolean => Object.values(policies ?? {}).some((policy) => policy?.id === policyID);

Expand Down Expand Up @@ -262,8 +263,7 @@ export {
isExpensifyTeam,
isExpensifyGuideTeam,
isInstantSubmitEnabled,
isCollectPolicy,
isFreePolicy,
isFreeGroupPolicy,
isPolicyAdmin,
isSubmitAndClose,
getMemberAccountIDsForWorkspace,
Expand Down
8 changes: 4 additions & 4 deletions src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r
const hasGeneralSettingsError = !isEmptyObject(policy?.errorFields?.generalSettings ?? {}) || !isEmptyObject(policy?.errorFields?.avatar ?? {});

const shouldShowProtectedItems = PolicyUtils.isPolicyAdmin(policy);
const isCollectPolicy = PolicyUtils.isCollectPolicy(policy);
const isFreePolicy = PolicyUtils.isFreePolicy(policy);
const isPaidGroupPolicy = PolicyUtils.isPaidGroupPolicy(policy);
const isFreeGroupPolicy = PolicyUtils.isFreeGroupPolicy(policy);

const protectedFreePolicyMenuItems: WorkspaceMenuItem[] = [
{
Expand Down Expand Up @@ -168,8 +168,8 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r
brickRoadIndicator: hasGeneralSettingsError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
routeName: SCREENS.WORKSPACE.PROFILE,
},
...(isCollectPolicy && shouldShowProtectedItems ? protectedCollectPolicyMenuItems : []),
...(isFreePolicy && shouldShowProtectedItems ? protectedFreePolicyMenuItems : []),
...(isPaidGroupPolicy && shouldShowProtectedItems ? protectedCollectPolicyMenuItems : []),
...(isFreeGroupPolicy && shouldShowProtectedItems ? protectedFreePolicyMenuItems : []),
];

const prevPolicy = usePrevious(policy);
Expand Down

0 comments on commit 7d3eadd

Please sign in to comment.