Some Code Cleanup

This commit is contained in:
2023-12-27 19:16:54 +01:00
parent 3108d9bf20
commit 9a16c4b560
38 changed files with 87 additions and 105 deletions

View File

@ -18,10 +18,11 @@
*/
import type {EventFight} from "@type/event.js";
import {fetchWithToken} from "./repo";
import {fetchWithToken, tokenStore} from "./repo";
import {z} from "zod";
import {EventFightSchema} from "@type/event.js";
import type {Dayjs} from "dayjs";
import {derived} from "svelte/store";
export interface CreateFight {
spielmodus: string
@ -86,12 +87,14 @@ export class FightRepo {
}
public async deleteFight(fightId: number): Promise<void> {
let res = await fetchWithToken(this.token, `/fights/${fightId}`, {
const res = await fetchWithToken(this.token, `/fights/${fightId}`, {
method: "DELETE"
})
});
if (!res.ok) {
throw new Error("Could not delete fight: " + res.statusText);
}
}
}
export const fightRepo = derived(tokenStore, ($token) => new FightRepo($token));