diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 9d9e2f83e6..778c7f7be5 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -36,6 +36,7 @@ const INITIAL_FRONTEND_STATE = { hasAppPackage: false, libraries: null, appId: "", + routes: {}, } export const getFrontendStore = () => { @@ -120,6 +121,17 @@ export const getFrontendStore = () => { return state }) }, + routing: { + fetch: async () => { + const response = await api.get("/api/routing") + const json = await response.json() + + store.update(state => { + state.routes = json.routes + return state + }) + }, + }, screens: { select: screenId => { store.update(state => { diff --git a/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte b/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte index bd7341be93..3ecd8ce0dc 100644 --- a/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte +++ b/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte @@ -15,9 +15,10 @@ const deleteScreen = () => { const screenToDelete = $allScreens.find(scr => scr._id === screen) store.actions.screens.delete(screenToDelete) + store.actions.routing.fetch() // update the page if required store.update(state => { - if (state.currentPreviewItem._id === screen._id) { + if (state.currentPreviewItem._id === screen) { store.actions.pages.select($store.currentPageName) notifier.success(`Screen ${screenToDelete.name} deleted successfully.`) $goto(`./:page/page-layout`) diff --git a/packages/builder/src/components/userInterface/ComponentNavigationTree/index.svelte b/packages/builder/src/components/userInterface/ComponentNavigationTree/index.svelte index ef783b1afd..dbdfad0828 100644 --- a/packages/builder/src/components/userInterface/ComponentNavigationTree/index.svelte +++ b/packages/builder/src/components/userInterface/ComponentNavigationTree/index.svelte @@ -2,12 +2,10 @@ import { goto } from "@sveltech/routify" import { store } from "builderStore" import PathTree from "./PathTree.svelte" - - export let routes = {}