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 { ArchiveData } from "../utils/archives"; import LiteElement, { html } from "../utils/LiteElement"; import { needLogin } from "../utils/auth"; @needLogin @localized() export class Archives extends LiteElement { @property({ type: Object }) authState?: AuthState; @property({ type: Object }) userInfo?: CurrentUser; @state() private archiveList?: ArchiveData[]; async firstUpdated() { this.archiveList = await this.getArchives(); } render() { return html`

${msg("Archives")}


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

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

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