import { DASHBOARD_ROUTE } from "../routes"; import LiteElement from "../utils/LiteElement"; import type { AuthState } from "../utils/AuthService"; import type { CurrentUser } from "../types/user"; /** * Block rendering and dispatch event if user is not logged in * * Usage example: * ```ts * @needLogin * MyComponent extends LiteElement {} * ``` */ export function needLogin( constructor: T ) { return class extends constructor { authState?: AuthState; static get properties() { return { authState: { type: Object }, }; } update(changedProperties: Map) { if (this.authState) { super.update(changedProperties); } else { this.dispatchEvent(new CustomEvent("need-login")); } } }; }