Files
dashboards/lib/managed-business.ts
T

30 lines
917 B
TypeScript

const MANAGED_BUSINESS_KEY = "marketplace_managed_business_id";
/**
* Superadmin-only: which Meshkee business is open on the shared business.* host.
* Regular business users ignore this and use `user.businesses` instead.
*/
export function getManagedBusinessId(): string | null {
if (typeof window === "undefined") return null;
return (
sessionStorage.getItem(MANAGED_BUSINESS_KEY) ||
localStorage.getItem(MANAGED_BUSINESS_KEY)
);
}
export function setManagedBusinessId(businessId: string | null) {
if (typeof window === "undefined") return;
if (!businessId) {
sessionStorage.removeItem(MANAGED_BUSINESS_KEY);
localStorage.removeItem(MANAGED_BUSINESS_KEY);
return;
}
const id = String(businessId);
sessionStorage.setItem(MANAGED_BUSINESS_KEY, id);
localStorage.setItem(MANAGED_BUSINESS_KEY, id);
}
export function clearManagedBusinessId() {
setManagedBusinessId(null);
}