Path: blob/main/components/dashboard/src/data/billing-mode/org-billing-mode-query.ts
2501 views
/**1* Copyright (c) 2023 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import { BillingMode } from "@gitpod/gitpod-protocol/lib/billing-mode";7import { useQuery } from "@tanstack/react-query";8import { getGitpodService } from "../../service/service";9import { useCurrentOrg } from "../organizations/orgs-query";1011type OrgBillingModeQueryResult = BillingMode;1213export const useOrgBillingMode = () => {14const organization = useCurrentOrg().data;1516return useQuery<OrgBillingModeQueryResult>({17queryKey: getOrgBillingModeQueryKey(organization?.id ?? ""),18queryFn: async () => {19if (!organization) {20throw new Error("No current organization selected");21}22return await getGitpodService().server.getBillingModeForTeam(organization.id);23},24enabled: !!organization,25});26};2728export const getOrgBillingModeQueryKey = (organizationId: string) => ["billing-mode", { organizationId }];293031