Skip to content

Commit

Permalink
refactor: rename method and add admin check
Browse files Browse the repository at this point in the history
  • Loading branch information
mananjadhav committed Jul 16, 2024
1 parent c3b1ff2 commit 46d367d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/ConnectToNetSuiteButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useNetwork from '@hooks/useNetwork';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import {removePolicyConnection} from '@libs/actions/connections';
import {getPoliciesConnectedToNetSuite} from '@libs/actions/Policy/Policy';
import {getAdminPoliciesConnectedToNetSuite} from '@libs/actions/Policy/Policy';
import Navigation from '@libs/Navigation/Navigation';
import type {AnchorPosition} from '@styles/index';
import CONST from '@src/CONST';
Expand All @@ -23,7 +23,7 @@ function ConnectToNetSuiteButton({policyID, shouldDisconnectIntegrationBeforeCon

const [isDisconnectModalOpen, setIsDisconnectModalOpen] = useState(false);

const hasPoliciesConnectedToNetSuite = !!getPoliciesConnectedToNetSuite()?.length;
const hasPoliciesConnectedToNetSuite = !!getAdminPoliciesConnectedToNetSuite()?.length;
const {isSmallScreenWidth} = useWindowDimensions();
const [isReuseConnectionsPopoverOpen, setIsReuseConnectionsPopoverOpen] = useState(false);
const [reuseConnectionPopoverPosition, setReuseConnectionPopoverPosition] = useState<AnchorPosition>({horizontal: 0, vertical: 0});
Expand Down
6 changes: 3 additions & 3 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3075,8 +3075,8 @@ function getAdminPoliciesConnectedToSageIntacct(): Policy[] {
return Object.values(allPolicies ?? {}).filter<Policy>((policy): policy is Policy => !!policy && policy.role === CONST.POLICY.ROLE.ADMIN && !!policy?.connections?.intacct);
}

function getPoliciesConnectedToNetSuite(): Policy[] {
return Object.values(allPolicies ?? {}).filter<Policy>((policy): policy is Policy => !!policy && !!policy?.connections?.netsuite);
function getAdminPoliciesConnectedToNetSuite(): Policy[] {
return Object.values(allPolicies ?? {}).filter<Policy>((policy): policy is Policy => !!policy && policy.role === CONST.POLICY.ROLE.ADMIN && !!policy?.connections?.netsuite);
}

export {
Expand Down Expand Up @@ -3148,7 +3148,7 @@ export {
upgradeToCorporate,
openPolicyExpensifyCardsPage,
requestExpensifyCardLimitIncrease,
getPoliciesConnectedToNetSuite,
getAdminPoliciesConnectedToNetSuite,
getAdminPoliciesConnectedToSageIntacct,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import MenuItemList from '@components/MenuItemList';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import {copyExistingPolicyConnection} from '@libs/actions/connections';
import {getPoliciesConnectedToNetSuite} from '@libs/actions/Policy/Policy';
import {getAdminPoliciesConnectedToNetSuite} from '@libs/actions/Policy/Policy';
import Navigation from '@libs/Navigation/Navigation';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import * as ReportUtils from '@libs/ReportUtils';
Expand All @@ -19,7 +19,7 @@ type ExistingConnectionsPageProps = StackScreenProps<SettingsNavigatorParamList,
function NetSuiteExistingConnectionsPage({route}: ExistingConnectionsPageProps) {
const {translate, datetimeToRelative} = useLocalize();
const styles = useThemeStyles();
const policiesConnectedToSageNetSuite = getPoliciesConnectedToNetSuite();
const policiesConnectedToSageNetSuite = getAdminPoliciesConnectedToNetSuite();
const policyID: string = route.params.policyID;

const menuItems = policiesConnectedToSageNetSuite.map((policy) => {
Expand Down

0 comments on commit 46d367d

Please sign in to comment.