Verified Commit ab51ee30 authored by Jakob Moser's avatar Jakob Moser
Browse files

Rely on agenda instance from model on page

parent 981da638
Loading
Loading
Loading
Loading
+3 −31
Changes for portal/static/js/components/pages/Fachschaftssitzung.mjs: 3 added lines, 31 removed lines.
Original line number Diff line number Diff line
import { Base } from "./Base.mjs"
import { Agenda } from "../pieces/Agenda.mjs"
import { getKey } from "../../account.mjs"
import { agenda } from "../../model/Agenda.mjs"
import { ButtonAndTextLink } from "../pieces/ButtonAndTextLink.mjs"
import {
    getLatestProtocolMetadata,
    getProtocolEditLink,
} from "../../gitlab.mjs"

const items = {
    all: null,
    message: "Wird geladen...",
    async fetch() {
        try {
            this.all = await m.request({
                method: "GET",
                url: "/api/v0/agendas/-/items",
                headers: getKey()
                    ? {
                          Authorization: `Bearer ${getKey().secret}`,
                      }
                    : {},
            })
        } catch (e) {
            if (e.code === 401) {
                this.message =
                    "Melde dich an Portal an, um die Tagesordnung anzuzeigen."
            } else {
                this.message = "Die Tagesordnung konnte nicht geladen werden."
            }
        }
    },
}

const latestProtocol = {
    meta: null,
    async fetch() {
@@ -45,15 +20,12 @@ export const Fachschaftssitzung = {
        document.title = "Fachschaftssitzung · FS Coli Portal"
    },
    async oninit() {
        items.fetch()
        agenda.fetch()
        latestProtocol.fetch()
    },
    view() {
        return m(Base, [
            m(Agenda, {
                items: items.all,
                message: items.message,
            }),
            m(Agenda, agenda),
            m("section", [
                m(
                    "p",