fixed linking between groups and devices

This commit is contained in:
Carter 2025-01-07 14:53:43 -06:00
parent 77fb5a6bcf
commit 8fc8745862
3 changed files with 12 additions and 5 deletions

View file

@ -200,13 +200,21 @@ export default function Devices() {
setLimit(event.target.value);
};
const appendToUrl = (appendage: number | string) => {
// const appendToUrl = (appendage: number | string) => {
// const basePath = location.pathname.replace(/\/$/, "");
// return(`${basePath}/${appendage}`);
// };
const prependToUrl = (prependage: number | string) => {
console.log(location.pathname)
const basePath = location.pathname.replace(/\/$/, "");
return(`${basePath}/${appendage}`);
return(`/${prependage}/${basePath}`.replace(/\/{2,}/g, "/").replace(/(\/[^/]+)\/\1+/g, "$1"));
};
const toDevice = (device: Device) => {
navigate(appendToUrl(or(device.settings?.deviceId, "")), { state: {device: device} })
let url = prependToUrl(getGroup() ? "groups/" + getGroup().id() : "")
url = url + "/" + device.id()
navigate(url, { replace: true, state: {device: device} })
};
const handleTabChange = (_event: React.SyntheticEvent, newValue: string) => {