import { state, property } from "lit/decorators.js"; import { msg, localized } from "@lit/localize"; import type { AuthState } from "../utils/AuthService"; import type { CurrentUser } from "../types/user"; import type { OrgData } from "../utils/orgs"; import LiteElement, { html } from "../utils/LiteElement"; import { needLogin } from "../utils/auth"; import type { APIPaginatedList } from "../types/api"; @needLogin @localized() export class Orgs extends LiteElement { @property({ type: Object }) authState?: AuthState; @property({ type: Object }) userInfo?: CurrentUser; @state() private orgList?: OrgData[]; async firstUpdated() { this.orgList = await this.getOrgs(); } render() { return html`

${msg("Organizations")}


${this.orgList ? this.renderOrgs() : html`
`}
`; } private renderOrgs() { if (!this.orgList?.length) { return html`

${msg("You don't have any organizations.")}

`; } return html` `; } private async getOrgs(): Promise { const data: APIPaginatedList = await this.apiFetch( "/orgs", this.authState! ); return data.items; } }