feat: Enhance event management with FightEdit and GroupEdit components, including improved data handling and new functionalities
This commit is contained in:
@@ -1,21 +1,32 @@
|
||||
<script lang="ts">
|
||||
import type { EventFight } from "@type/event";
|
||||
import type { EventFight, EventFightEdit, ResponseGroups, SWEvent } from "@type/event";
|
||||
import { Button } from "@components/ui/button";
|
||||
import { EditIcon, MenuIcon } from "lucide-svelte";
|
||||
import { EditIcon, MenuIcon, GroupIcon } from "lucide-svelte";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@components/ui/dialog";
|
||||
import FightEdit from "@components/moderator/components/FightEdit.svelte";
|
||||
import type { Team } from "@components/types/team";
|
||||
import { fightRepo } from "@components/repo/fight";
|
||||
|
||||
const { fight, teams }: { fight: EventFight; teams: Team[] } = $props();
|
||||
let { fight, teams, groups, event, onupdate }: { fight: EventFight; teams: Team[]; groups: ResponseGroups[]; event: SWEvent; onupdate: (update: EventFight) => void } = $props();
|
||||
|
||||
function handleSave(fightData) {
|
||||
// Handle the save action here
|
||||
console.log("Fight data saved:", fightData);
|
||||
let editOpen = $state(false);
|
||||
|
||||
async function handleSave(fightData: EventFightEdit) {
|
||||
let f = await $fightRepo.updateFight(event.id, fight.id, {
|
||||
...fightData,
|
||||
blueTeam: fightData.blueTeam.id,
|
||||
redTeam: fightData.redTeam.id,
|
||||
group: fightData.group ?? -1,
|
||||
});
|
||||
|
||||
onupdate(f);
|
||||
|
||||
editOpen = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<Dialog>
|
||||
<Dialog bind:open={editOpen}>
|
||||
<DialogTrigger>
|
||||
<Button variant="ghost" size="icon">
|
||||
<EditIcon />
|
||||
@@ -26,7 +37,7 @@
|
||||
<DialogTitle>Fight bearbeiten</DialogTitle>
|
||||
<DialogDescription>Hier kannst du die Daten des Kampfes bearbeiten.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<FightEdit {fight} {teams} onSave={handleSave}>
|
||||
<FightEdit {fight} {teams} {groups} {event} onSave={handleSave}>
|
||||
{#snippet actions(dirty, submit)}
|
||||
<DialogFooter>
|
||||
<Button disabled={!dirty} onclick={submit}>Speichern</Button>
|
||||
@@ -35,7 +46,4 @@
|
||||
</FightEdit>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<Button variant="ghost" size="icon">
|
||||
<MenuIcon />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user