From 6ee7aa95a93a4d9f6a23e252c1d0e626bbfa876d Mon Sep 17 00:00:00 2001 From: Carter Date: Thu, 13 Feb 2025 13:28:39 -0600 Subject: [PATCH] checking if groupID is undefined before trying to use it --- src/device/DeviceOverview.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/device/DeviceOverview.tsx b/src/device/DeviceOverview.tsx index d4c84c3..32e0e6f 100644 --- a/src/device/DeviceOverview.tsx +++ b/src/device/DeviceOverview.tsx @@ -78,12 +78,18 @@ export default function DeviceOverview(props: Props) { }, [components, prevComponents]); const pathToDevice = () => { - const groupID = parseInt(useParams().groupID ?? "0", 10); - console.log(groupID) + if (useParams().groupID) { + const groupID = parseInt(useParams().groupID ?? "0", 10); + const groupPath: string = groupID > 0 ? "/groups/" + groupID.toString() : ""; + const devicePath: string = "/devices/" + device.settings.deviceId.toString(); + return groupPath + devicePath; + } + // const groupID = parseInt(useParams().groupID ?? "0", 10); + // console.log(groupID) // const groupID: number = parseInt(match.params.groupID, 10); - const groupPath: string = groupID > 0 ? "/groups/" + groupID.toString() : ""; + // const groupPath: string = groupID > 0 ? "/groups/" + groupID.toString() : ""; const devicePath: string = "/devices/" + device.settings.deviceId.toString(); - return groupPath + devicePath; + return devicePath; }; const copySim = (sim: string) => {