From 667fa7a9e3962c2348ed05b979bbb451f55a5b1d Mon Sep 17 00:00:00 2001 From: Daniel Hougaard <62331820+DanielHougaard@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:27:24 +0100 Subject: [PATCH] Chore: Optional 'invalidate' option for create org hook --- .../src/hooks/api/organization/queries.tsx | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/frontend/src/hooks/api/organization/queries.tsx b/frontend/src/hooks/api/organization/queries.tsx index 441aa591c..9e763c771 100644 --- a/frontend/src/hooks/api/organization/queries.tsx +++ b/frontend/src/hooks/api/organization/queries.tsx @@ -27,7 +27,8 @@ export const organizationKeys = { getOrgTaxIds: (orgId: string) => [{ orgId }, "organization-tax-ids"] as const, getOrgInvoices: (orgId: string) => [{ orgId }, "organization-invoices"] 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 () => { @@ -46,7 +47,7 @@ export const useGetOrganizations = () => { }); }; -export const useCreateOrg = () => { +export const useCreateOrg = (options: { invalidate: boolean } = { invalidate: true }) => { const queryClient = useQueryClient(); return useMutation({ @@ -60,7 +61,9 @@ export const useCreateOrg = () => { return organization; }, onSuccess: () => { - queryClient.invalidateQueries(organizationKeys.getUserOrganizations); + if (options?.invalidate) { + queryClient.invalidateQueries(organizationKeys.getUserOrganizations); + } } }); }; @@ -68,15 +71,9 @@ export const useCreateOrg = () => { export const useUpdateOrg = () => { const queryClient = useQueryClient(); return useMutation<{}, {}, UpdateOrgDTO>({ - mutationFn: ({ - name, - authEnforced, - scimEnabled, - slug, - orgId - }) => { - return apiRequest.patch(`/api/v1/organization/${orgId}`, { - name, + mutationFn: ({ name, authEnforced, scimEnabled, slug, orgId }) => { + return apiRequest.patch(`/api/v1/organization/${orgId}`, { + name, authEnforced, scimEnabled, slug