Track HiveGrid Cloud planning reference

This commit is contained in:
david committed 2026-06-26 20:48:01 +02:00
1 parent b3d5ea6764
commit e341c5938a
5784 files changed
+1104929 -3

No files matched your search

@@ -0,0 +1,29 @@
import { appPath } from "~/utils/app/CanonicalUrlUtils";
type TenantSwitchLocation = {
pathname: string;
search?: string;
hash?: string;
};
type TenantSwitchOptions = {
currentTenant: {
id: string;
slug: string;
};
location: TenantSwitchLocation;
tenantSlug: string;
};
export function getTenantSwitchPath({ currentTenant, location, tenantSlug }: TenantSwitchOptions) {
const pathSegments = location.pathname.split("/").filter(Boolean);
let childPath = "";
if (pathSegments[0] === "app" && (pathSegments[1] === currentTenant.slug || pathSegments[1] === currentTenant.id)) {
childPath = pathSegments.slice(2).join("/");
} else if (pathSegments[0] === currentTenant.slug || pathSegments[0] === currentTenant.id) {
childPath = pathSegments.slice(1).join("/");
}
return appPath({ tenantSlug, path: childPath, mode: "host-aware" });
}