From a11d1952c6a79515f9fd4d11ea7a1a83478a5e11 Mon Sep 17 00:00:00 2001 From: hexastack Date: Wed, 23 Apr 2025 16:43:35 +0100 Subject: [PATCH] fix: auto navigate to new flow after creation --- frontend/src/components/categories/CategoryForm.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/categories/CategoryForm.tsx b/frontend/src/components/categories/CategoryForm.tsx index b69e18c6..16907b92 100644 --- a/frontend/src/components/categories/CategoryForm.tsx +++ b/frontend/src/components/categories/CategoryForm.tsx @@ -6,6 +6,7 @@ * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). */ +import { useRouter } from "next/router"; import { FC, Fragment, useEffect } from "react"; import { useForm } from "react-hook-form"; @@ -15,7 +16,7 @@ import { useCreate } from "@/hooks/crud/useCreate"; import { useUpdate } from "@/hooks/crud/useUpdate"; import { useToast } from "@/hooks/useToast"; import { useTranslate } from "@/hooks/useTranslate"; -import { EntityType } from "@/services/types"; +import { EntityType, RouterType } from "@/services/types"; import { ICategory, ICategoryAttributes } from "@/types/category.types"; import { ComponentFormProps } from "@/types/common/dialogs.types"; @@ -27,14 +28,16 @@ export const CategoryForm: FC> = ({ }) => { const { t } = useTranslate(); const { toast } = useToast(); + const router = useRouter(); const options = { onError: (error: Error) => { rest.onError?.(); toast.error(error || t("message.internal_server_error")); }, - onSuccess: () => { + onSuccess: (response: ICategory) => { rest.onSuccess?.(); toast.success(t("message.success_save")); + router.push(`/${RouterType.VISUAL_EDITOR}/flows/${response.id}`); }, }; const { mutate: createCategory } = useCreate(EntityType.CATEGORY, options);