Code Cleanup™

This commit is contained in:
2024-02-11 11:16:23 +01:00
parent 4b27eb76fe
commit 9fd8ddb9bd
62 changed files with 663 additions and 519 deletions

View File

@@ -25,24 +25,25 @@ import type {Dayjs} from "dayjs";
import {derived} from "svelte/store";
export interface CreateEvent {
name: string
start: Dayjs
end: Dayjs
name: string;
start: Dayjs;
end: Dayjs;
}
export interface UpdateEvent {
name: string
start: Dayjs
end: Dayjs
deadline: Dayjs
maxTeamMembers: number
schemType: string | null
publicSchemsOnly: boolean
spectateSystem: boolean
name: string;
start: Dayjs;
end: Dayjs;
deadline: Dayjs;
maxTeamMembers: number;
schemType: string | null;
publicSchemsOnly: boolean;
spectateSystem: boolean;
}
export class EventRepo {
constructor(private token: string) {}
constructor(private token: string) {
}
public async listEvents(): Promise<ShortEvent[]> {
return await fetchWithToken(this.token, "/events")
@@ -62,7 +63,7 @@ export class EventRepo {
body: JSON.stringify({
name: event.name,
start: +event.start,
end: +event.end
end: +event.end,
}),
}).then(value => value.json())
.then(SWEventSchema.parse);
@@ -79,18 +80,18 @@ export class EventRepo {
maxTeamMembers: event.maxTeamMembers,
schemType: event.schemType,
publicSchemsOnly: event.publicSchemsOnly,
spectateSystem: event.spectateSystem
spectateSystem: event.spectateSystem,
}),
headers: {
"Content-Type": "application/json"
}
"Content-Type": "application/json",
},
}).then(value => value.json())
.then(SWEventSchema.parse);
}
public async deleteEvent(id: string): Promise<boolean> {
const res = await fetchWithToken(this.token, `/events/${id}`, {
method: "DELETE"
method: "DELETE",
});
return res.ok;