diff --git a/club/static/bundled/club/components/ajax-select-index.ts b/club/static/bundled/club/components/ajax-select-index.ts index 56c93760..9515b6f0 100644 --- a/club/static/bundled/club/components/ajax-select-index.ts +++ b/club/static/bundled/club/components/ajax-select-index.ts @@ -1,7 +1,6 @@ -import type { TomOption } from "tom-select/dist/types/types"; -import type { escape_html } from "tom-select/dist/types/utils"; -import { AjaxSelect } from "#core:core/components/ajax-select-base.ts"; -import { registerComponent } from "#core:utils/web-components.ts"; +import type { escape_html } from "tom-select/src/utils"; +import { AjaxSelect } from "#core:core/components/ajax-select-base"; +import { registerComponent } from "#core:utils/web-components"; import { type ClubSchema, clubSearchClub } from "#openapi"; @registerComponent("club-ajax-select") @@ -10,7 +9,7 @@ export class ClubAjaxSelect extends AjaxSelect { protected labelField = "name"; protected searchField = ["code", "name"]; - protected async search(query: string): Promise { + protected async search(query: string) { const resp = await clubSearchClub({ query: { search: query } }); if (resp.data) { return resp.data.results; diff --git a/com/static/bundled/com/components/ics-calendar-index.ts b/com/static/bundled/com/components/ics-calendar-index.ts index 8eb159c1..04a46ae2 100644 --- a/com/static/bundled/com/components/ics-calendar-index.ts +++ b/com/static/bundled/com/components/ics-calendar-index.ts @@ -1,4 +1,9 @@ -import { Calendar, type EventClickArg, type EventContentArg } from "@fullcalendar/core"; +import { + Calendar, + type EventClickArg, + type EventContentArg, + type EventInput, +} from "@fullcalendar/core"; import type { EventImpl } from "@fullcalendar/core/internal"; import enLocale from "@fullcalendar/core/locales/en-gb"; import frLocale from "@fullcalendar/core/locales/fr"; @@ -6,8 +11,8 @@ import dayGridPlugin from "@fullcalendar/daygrid"; import iCalendarPlugin from "@fullcalendar/icalendar"; import listPlugin from "@fullcalendar/list"; import { type HTMLTemplateResult, html, render } from "lit-html"; -import { makeUrl } from "#core:utils/api.ts"; -import { inheritHtmlElement, registerComponent } from "#core:utils/web-components.ts"; +import { type GenericEndpoint, makeUrl } from "#core:utils/api"; +import { inheritHtmlElement, registerComponent } from "#core:utils/web-components"; import { calendarCalendarInternal, calendarCalendarUnpublished, @@ -19,11 +24,11 @@ import { @registerComponent("ics-calendar") export class IcsCalendar extends inheritHtmlElement("div") { static observedAttributes = ["locale", "can_moderate", "can_delete", "ics-help-url"]; - private calendar: Calendar; - private locale = "en"; - private canModerate = false; - private canDelete = false; - private helpUrl = ""; + private calendar!: Calendar; + private locale? = "en"; + private canModerate? = false; + private canDelete? = false; + private helpUrl? = ""; // Hack variable to detect recurring events // The underlying ics library doesn't include any info about rrules @@ -35,10 +40,12 @@ export class IcsCalendar extends inheritHtmlElement("div") { this.locale = newValue; } if (name === "can_moderate") { - this.canModerate = newValue.toLowerCase() === "true"; + this.canModerate = + typeof newValue === "string" && newValue.toLowerCase() === "true"; } if (name === "can_delete") { - this.canDelete = newValue.toLowerCase() === "true"; + this.canDelete = + typeof newValue === "string" && newValue.toLowerCase() === "true"; } if (name === "ics-help-url") { @@ -94,7 +101,7 @@ export class IcsCalendar extends inheritHtmlElement("div") { .toString() .split("/") .filter((s) => s) // Remove blank characters - .pop(), + .pop() as string, 10, ); } @@ -159,7 +166,7 @@ export class IcsCalendar extends inheritHtmlElement("div") { this.refreshEvents(); } - async getEventSources() { + async getEventSources(): Promise { const tagRecurringEvents = (eventData: EventImpl) => { // This functions tags events with a similar event url // We rely on the fact that the event url is always the same @@ -173,14 +180,14 @@ export class IcsCalendar extends inheritHtmlElement("div") { }; return [ { - url: `${await makeUrl(calendarCalendarInternal)}`, + url: `${await makeUrl(calendarCalendarInternal as GenericEndpoint)}`, format: "ics", className: "internal", cache: false, eventDataTransform: tagRecurringEvents, }, { - url: `${await makeUrl(calendarCalendarUnpublished)}`, + url: `${await makeUrl(calendarCalendarUnpublished as GenericEndpoint)}`, format: "ics", color: "red", className: "unpublished", @@ -213,7 +220,7 @@ export class IcsCalendar extends inheritHtmlElement("div") { ${event.title} - ${this.formatDate(event.start)} - ${this.formatDate(event.end)} + ${this.formatDate(event.start as Date)} - ${this.formatDate(event.end as Date)} `; @@ -251,7 +258,7 @@ export class IcsCalendar extends inheritHtmlElement("div") { const buttons = [] as HTMLTemplateResult[]; if (this.canModerate) { - if (event.source.internalEventSource.ui.classNames.includes("unpublished")) { + if (event.source?.internalEventSource.ui.classNames.includes("unpublished")) { const button = html`