mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 18:27:36 +00:00
Chore: Optional 'invalidate' option for create org hook
This commit is contained in:
@@ -27,7 +27,8 @@ export const organizationKeys = {
|
|||||||
getOrgTaxIds: (orgId: string) => [{ orgId }, "organization-tax-ids"] as const,
|
getOrgTaxIds: (orgId: string) => [{ orgId }, "organization-tax-ids"] as const,
|
||||||
getOrgInvoices: (orgId: string) => [{ orgId }, "organization-invoices"] as const,
|
getOrgInvoices: (orgId: string) => [{ orgId }, "organization-invoices"] as const,
|
||||||
getOrgLicenses: (orgId: string) => [{ orgId }, "organization-licenses"] as const,
|
getOrgLicenses: (orgId: string) => [{ orgId }, "organization-licenses"] as const,
|
||||||
getOrgIdentityMemberships: (orgId: string) => [{ orgId }, "organization-identity-memberships"] as const,
|
getOrgIdentityMemberships: (orgId: string) =>
|
||||||
|
[{ orgId }, "organization-identity-memberships"] as const
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchOrganizations = async () => {
|
export const fetchOrganizations = async () => {
|
||||||
@@ -46,7 +47,7 @@ export const useGetOrganizations = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useCreateOrg = () => {
|
export const useCreateOrg = (options: { invalidate: boolean } = { invalidate: true }) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
@@ -60,7 +61,9 @@ export const useCreateOrg = () => {
|
|||||||
return organization;
|
return organization;
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries(organizationKeys.getUserOrganizations);
|
if (options?.invalidate) {
|
||||||
|
queryClient.invalidateQueries(organizationKeys.getUserOrganizations);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -68,13 +71,7 @@ export const useCreateOrg = () => {
|
|||||||
export const useUpdateOrg = () => {
|
export const useUpdateOrg = () => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
return useMutation<{}, {}, UpdateOrgDTO>({
|
return useMutation<{}, {}, UpdateOrgDTO>({
|
||||||
mutationFn: ({
|
mutationFn: ({ name, authEnforced, scimEnabled, slug, orgId }) => {
|
||||||
name,
|
|
||||||
authEnforced,
|
|
||||||
scimEnabled,
|
|
||||||
slug,
|
|
||||||
orgId
|
|
||||||
}) => {
|
|
||||||
return apiRequest.patch(`/api/v1/organization/${orgId}`, {
|
return apiRequest.patch(`/api/v1/organization/${orgId}`, {
|
||||||
name,
|
name,
|
||||||
authEnforced,
|
authEnforced,
|
||||||
|
|||||||
Reference in New Issue
Block a user