From 9b5e025863a274bd825153fa464e01ef7802bc1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frane=20Poli=C4=87?= <16856471+fPolic@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:31:42 +0200 Subject: [PATCH] fix: close create form on success (#7011) --- .../create-location-form/create-location-form.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/admin-next/dashboard/src/v2-routes/locations/location-create/components/create-location-form/create-location-form.tsx b/packages/admin-next/dashboard/src/v2-routes/locations/location-create/components/create-location-form/create-location-form.tsx index aff83be824..45e64cecd6 100644 --- a/packages/admin-next/dashboard/src/v2-routes/locations/location-create/components/create-location-form/create-location-form.tsx +++ b/packages/admin-next/dashboard/src/v2-routes/locations/location-create/components/create-location-form/create-location-form.tsx @@ -5,7 +5,10 @@ import { useTranslation } from "react-i18next" import * as zod from "zod" import { CountrySelect } from "../../../../../components/common/country-select" import { Form } from "../../../../../components/common/form" -import { RouteFocusModal } from "../../../../../components/route-modal" +import { + RouteFocusModal, + useRouteModal, +} from "../../../../../components/route-modal" import { useCreateStockLocation } from "../../../../../hooks/api/stock-locations" const CreateLocationSchema = zod.object({ @@ -24,6 +27,7 @@ const CreateLocationSchema = zod.object({ export const CreateLocationForm = () => { const { t } = useTranslation() + const { handleSuccess } = useRouteModal() const form = useForm>({ defaultValues: { @@ -51,7 +55,9 @@ export const CreateLocationForm = () => { address: values.address, }, { - onSuccess: () => {}, + onSuccess: () => { + handleSuccess("/settings/locations") + }, } ) })