Path: blob/main/components/dashboard/src/data/auth-providers/update-user-auth-provider-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 { UpdateAuthProviderRequest } from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb";8import { authProviderClient } from "../../service/public-api";9import { getUserAuthProvidersQueryKey } from "./user-auth-providers-query";1011type UpdateAuthProviderArgs = {12provider: {13id: string;14clientId: string;15clientSecret: string;16authorizationUrl?: string;17tokenUrl?: string;18};19};20export const useUpdateUserAuthProviderMutation = () => {21const queryClient = useQueryClient();2223return useMutation({24mutationFn: async ({ provider }: UpdateAuthProviderArgs) => {25const response = await authProviderClient.updateAuthProvider(26new UpdateAuthProviderRequest({27authProviderId: provider.id,28clientId: provider.clientId,29clientSecret: provider.clientSecret,30authorizationUrl: provider.authorizationUrl,31tokenUrl: provider.tokenUrl,32}),33);34return response.authProvider!;35},36onSuccess(provider) {37const userId = provider?.owner?.value;38if (!userId) {39return;40}4142queryClient.invalidateQueries({ queryKey: getUserAuthProvidersQueryKey(userId) });43},44});45};464748