diff --git a/app/write/new/page.tsx b/app/write/new/page.tsx index 73506f0..915d501 100644 --- a/app/write/new/page.tsx +++ b/app/write/new/page.tsx @@ -1,12 +1,12 @@ "use client"; -import { useEffect, useState } from "react"; +import { useEffect, useState, Suspense } from "react"; import { useSearchParams } from "next/navigation"; import { invoke } from "@tauri-apps/api/core"; import TextEditor from "@/components/text-editor"; -import { HomelabApp } from "@/types"; // Adjust path if needed +import { HomelabApp } from "@/types"; -export default function WritePage() { +function WritePageContent() { const searchParams = useSearchParams(); const appQuery = searchParams.get("app"); @@ -21,12 +21,13 @@ export default function WritePage() { } try { - // Fetch apps to find the one matching the query parameter string const apps = (await invoke("get_app")) as HomelabApp[]; + + // Match checking both UUID structure and sanitized string names const matchedApp = apps.find( (app) => app.id === appQuery || - app.name.toLowerCase() === appQuery.toLowerCase(), + app.name.toLowerCase().trim() === appQuery.toLowerCase().trim(), ); if (matchedApp) { @@ -56,13 +57,28 @@ export default function WritePage() { ); } + return ( + + ); +} + +// 2. Main Page export wrapped in a Suspense boundary +export default function WritePage() { return (
- + + Loading router state... +
+ } + > + + ); } diff --git a/components/action-menu.tsx b/components/action-menu.tsx index 3c9935b..f93a29c 100644 --- a/components/action-menu.tsx +++ b/components/action-menu.tsx @@ -11,6 +11,7 @@ import { } from "@/components/ui/tooltip"; import DeleteDialog from "./delete-dialog"; import { useState } from "react"; +import { useRouter } from "next/navigation"; type Props = { id: string; @@ -22,6 +23,8 @@ export default function ActionMenu({ id }: Props) { const [open, setOpen] = useState(false); + const router = useRouter(); + return ( <> @@ -69,7 +72,9 @@ export default function ActionMenu({ id }: Props) {