Path: blob/main/components/dashboard/src/data/oidc-clients/activate-oidc-client-mutation.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 { useMutation, useQueryClient } from "@tanstack/react-query";7import { oidcService } from "../../service/public-api";8import { useCurrentOrg } from "../organizations/orgs-query";9import { getOIDCClientsQueryKey } from "./oidc-clients-query";10import { SetClientConfigActivationResponse } from "@gitpod/public-api/lib/gitpod/experimental/v1/oidc_pb";1112type ActivateOIDCClientArgs = {13id: string;14};15export const useActivateOIDCClientMutation = () => {16const client = useQueryClient();17const { data: org } = useCurrentOrg();1819return useMutation<SetClientConfigActivationResponse, Error, ActivateOIDCClientArgs>({20mutationFn: async ({ id }) => {21if (!org) {22throw new Error("No current organization selected");23}2425return await oidcService.setClientConfigActivation({ id, organizationId: org.id, activate: true });26},27onSuccess: () => {28if (!org) {29return;30}3132client.invalidateQueries(getOIDCClientsQueryKey(org.id));33},34});35};363738