Code Cleanup™
This commit is contained in:
@@ -25,27 +25,28 @@ import type {Dayjs} from "dayjs";
|
||||
import {derived} from "svelte/store";
|
||||
|
||||
export interface CreateFight {
|
||||
spielmodus: string
|
||||
map: string
|
||||
blueTeam: number
|
||||
redTeam: number
|
||||
start: Dayjs
|
||||
kampfleiter: number | null
|
||||
group: string | null
|
||||
spielmodus: string;
|
||||
map: string;
|
||||
blueTeam: number;
|
||||
redTeam: number;
|
||||
start: Dayjs;
|
||||
kampfleiter: number | null;
|
||||
group: string | null;
|
||||
}
|
||||
|
||||
export interface UpdateFight {
|
||||
spielmodus: string | null
|
||||
map: string | null
|
||||
blueTeam: number | null
|
||||
redTeam: number | null
|
||||
start: Dayjs | null
|
||||
kampfleiter: number | null
|
||||
group: string | null
|
||||
spielmodus: string | null;
|
||||
map: string | null;
|
||||
blueTeam: number | null;
|
||||
redTeam: number | null;
|
||||
start: Dayjs | null;
|
||||
kampfleiter: number | null;
|
||||
group: string | null;
|
||||
}
|
||||
|
||||
export class FightRepo {
|
||||
constructor(private token: string) {}
|
||||
constructor(private token: string) {
|
||||
}
|
||||
|
||||
public async listFights(eventId: number): Promise<EventFight[]> {
|
||||
return await fetchWithToken(this.token, `/events/${eventId}/fights`)
|
||||
@@ -54,7 +55,7 @@ export class FightRepo {
|
||||
}
|
||||
|
||||
public async createFight(eventId: number, fight: CreateFight): Promise<EventFight> {
|
||||
return await fetchWithToken(this.token, `/fights`, {
|
||||
return await fetchWithToken(this.token, "/fights", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
event: eventId,
|
||||
@@ -64,10 +65,10 @@ export class FightRepo {
|
||||
redTeam: fight.redTeam,
|
||||
start: +fight.start,
|
||||
kampfleiter: fight.kampfleiter,
|
||||
group: fight.group
|
||||
})
|
||||
group: fight.group,
|
||||
}),
|
||||
}).then(value => value.json())
|
||||
.then(EventFightSchema.parse)
|
||||
.then(EventFightSchema.parse);
|
||||
}
|
||||
|
||||
public async updateFight(fightId: number, fight: UpdateFight): Promise<EventFight> {
|
||||
@@ -80,15 +81,15 @@ export class FightRepo {
|
||||
redTeam: fight.redTeam,
|
||||
start: fight.start?.valueOf(),
|
||||
kampfleiter: fight.kampfleiter,
|
||||
group: fight.group
|
||||
})
|
||||
group: fight.group,
|
||||
}),
|
||||
}).then(value => value.json())
|
||||
.then(EventFightSchema.parse)
|
||||
.then(EventFightSchema.parse);
|
||||
}
|
||||
|
||||
public async deleteFight(fightId: number): Promise<void> {
|
||||
const res = await fetchWithToken(this.token, `/fights/${fightId}`, {
|
||||
method: "DELETE"
|
||||
method: "DELETE",
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user