mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 16:27:40 +00:00
Fix: Invalidate after selecting organization
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
import SecurityClient from "@app/components/utilities/SecurityClient";
|
import SecurityClient from "@app/components/utilities/SecurityClient";
|
||||||
import { apiRequest } from "@app/config/request";
|
import { apiRequest } from "@app/config/request";
|
||||||
import { setAuthToken } from "@app/reactQuery";
|
import { setAuthToken } from "@app/reactQuery";
|
||||||
|
|
||||||
|
import { organizationKeys } from "../organization/queries";
|
||||||
import {
|
import {
|
||||||
ChangePasswordDTO,
|
ChangePasswordDTO,
|
||||||
CompleteAccountDTO,
|
CompleteAccountDTO,
|
||||||
@@ -66,6 +67,7 @@ export const selectOrganization = async (data: { organizationId: string }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const useSelectOrganization = () => {
|
export const useSelectOrganization = () => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (details: { organizationId: string }) => {
|
mutationFn: async (details: { organizationId: string }) => {
|
||||||
const data = await selectOrganization(details);
|
const data = await selectOrganization(details);
|
||||||
@@ -74,6 +76,9 @@ export const useSelectOrganization = () => {
|
|||||||
SecurityClient.setProviderAuthToken("");
|
SecurityClient.setProviderAuthToken("");
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries(organizationKeys.getUserOrganizations);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user