From 1fcb820e562863d5b9d6649569a837e78da847e0 Mon Sep 17 00:00:00 2001 From: seaerchin Date: Tue, 30 Jul 2024 04:34:55 +0800 Subject: [PATCH] chore: autonav --- .../CreatePageWizardContext.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/studio/src/features/editing-experience/components/CreatePageModal/CreatePageWizardContext.tsx b/apps/studio/src/features/editing-experience/components/CreatePageModal/CreatePageWizardContext.tsx index 33c2d18a77..b7831c66e4 100644 --- a/apps/studio/src/features/editing-experience/components/CreatePageModal/CreatePageWizardContext.tsx +++ b/apps/studio/src/features/editing-experience/components/CreatePageModal/CreatePageWizardContext.tsx @@ -2,6 +2,7 @@ import type { UseDisclosureReturn } from "@chakra-ui/react" import type { IsomerSchema } from "@opengovsg/isomer-components" import type { PropsWithChildren } from "react" import { createContext, useContext, useMemo, useState } from "react" +import { useRouter } from "next/router" import { merge } from "lodash" import articleLayoutPreview from "~/features/editing-experience/data/articleLayoutPreview.json" @@ -76,6 +77,7 @@ const useCreatePageWizardContext = ({ }, [layout, title]) const utils = trpc.useUtils() + const router = useRouter() const { mutate, isLoading } = trpc.page.createPage.useMutation({ onSuccess: async () => { @@ -86,11 +88,18 @@ const useCreatePageWizardContext = ({ }) const handleCreatePage = formMethods.handleSubmit((values) => { - mutate({ - siteId, - folderId, - ...values, - }) + mutate( + { + siteId, + folderId, + ...values, + }, + { + onSuccess: ({ pageId }) => { + router.push(`/sites/${siteId}/pages/${pageId}`) + }, + }, + ) }) const handleNextToDetailScreen = () => {