From b3a2e80a84c53e26ce35bdc639f86e312b1fa29d Mon Sep 17 00:00:00 2001 From: Qiwei Yang Date: Wed, 23 Oct 2024 22:30:53 +0800 Subject: [PATCH] fix next path --- components/telemetry-dashboard.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/telemetry-dashboard.tsx b/components/telemetry-dashboard.tsx index 62a4895..1d37152 100644 --- a/components/telemetry-dashboard.tsx +++ b/components/telemetry-dashboard.tsx @@ -1,6 +1,7 @@ "use client"; import { useState, useEffect, useCallback, useRef } from "react"; +import { useRouter } from "next/navigation"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { @@ -37,6 +38,8 @@ export default function TelemetryDashboard() { const [nodeInfo, setNodeInfo] = useState([]); const intervalsRef = useRef<{ [key: string]: NodeJS.Timeout }>({}); + const router = useRouter(); + const setNodeConnected = useCallback( (endpoint: string, connected: boolean) => { setNodeInfo((prev) => @@ -273,14 +276,11 @@ export default function TelemetryDashboard() { ? "" : "bg-red-100 dark:bg-red-500 text-black dark:text-white" }`} - onClick={() => - window.open( - `${ - window.location.pathname - }/node/?endpoint=${encodeURIComponent(node.endpoint)}`, - "_blank" - ) - } + onClick={() => { + router.push( + `/node?endpoint=${encodeURIComponent(node.endpoint)}` + ); + }} > {node.name || "-"}