Skip to content

Commit

Permalink
Merge pull request #6125 from pavinduLakshan/fix_subscription_calls_s…
Browse files Browse the repository at this point in the history
…uborg
  • Loading branch information
pavinduLakshan authored May 2, 2024
2 parents aa98983 + 476b16b commit 0518004
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-baboons-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/features": patch
---

Prevent subscription calls being sent inside suborganizations
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2023-2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand All @@ -16,14 +16,14 @@
* under the License.
*/

import { HttpMethods } from "@wso2is/core/models";
import { OrganizationType } from "features/admin.organizations.v1/constants";
import { Config, store } from "../../../../admin.core.v1";
import useRequest, {
RequestConfigInterface,
RequestErrorInterface,
RequestResultInterface
} from "../../../../admin.core.v1/hooks/use-request";
import { HttpMethods } from "@wso2is/core/models";
import { Config } from "../../../../admin.core.v1";
import { useGetCurrentOrganizationType } from "../../../../admin.organizations.v1/hooks/use-get-organization-type";
import { getDomainQueryParam } from "../../tenants/api/tenants";
import { getTenantResourceEndpoints } from "../../tenants/configs";
import { TenantTierRequestResponse } from "../models/subscription";
Expand All @@ -36,7 +36,7 @@ import { TenantTierRequestResponse } from "../models/subscription";
const useTenantTier = <Data = TenantTierRequestResponse,
Error = RequestErrorInterface> (): RequestResultInterface<Data, Error> => {

const { isFirstLevelOrganization } = useGetCurrentOrganizationType();
const organizationType: OrganizationType = store.getState().organization.organizationType;

const requestConfig: RequestConfigInterface = {
headers: {
Expand All @@ -48,7 +48,8 @@ const useTenantTier = <Data = TenantTierRequestResponse,
};

const { data, error, isValidating, mutate } = useRequest<Data, Error>(
Config.getDeploymentConfig().extensions?.subscriptionApiPath && isFirstLevelOrganization()
organizationType === OrganizationType.FIRST_LEVEL_ORGANIZATION
&& Config.getDeploymentConfig().extensions?.subscriptionApiPath
? requestConfig
: null,
{
Expand Down

0 comments on commit 0518004

Please sign in to comment.