From 835c36d1613d7ad9f1985c3acd6a49a414787c5c Mon Sep 17 00:00:00 2001 From: Daniel Hougaard <62331820+DanielHougaard@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:29:29 +0100 Subject: [PATCH] Fix: Select org after creation --- .../src/views/Org/components/CreateOrgModal.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/Org/components/CreateOrgModal.tsx b/frontend/src/views/Org/components/CreateOrgModal.tsx index b806b2089..e7a17bb0b 100644 --- a/frontend/src/views/Org/components/CreateOrgModal.tsx +++ b/frontend/src/views/Org/components/CreateOrgModal.tsx @@ -6,7 +6,7 @@ import z from "zod"; import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2"; -import { useCreateOrg } from "@app/hooks/api"; +import { useCreateOrg, useSelectOrganization } from "@app/hooks/api"; const schema = z .object({ @@ -37,14 +37,21 @@ export const CreateOrgModal: FC = ({ isOpen, onClose }) => } }); - const { mutateAsync } = useCreateOrg(); + const { mutateAsync: createOrg } = useCreateOrg({ + invalidate: false + }); + const { mutateAsync: selectOrg } = useSelectOrganization(); const onFormSubmit = async ({ name }: FormData) => { try { - const organization = await mutateAsync({ + const organization = await createOrg({ name }); + await selectOrg({ + organizationId: organization.id + }); + createNotification({ text: "Successfully created organization", type: "success"