From dc4db405d2991d3ec6a114f3b08d3fccd057d3ee Mon Sep 17 00:00:00 2001
From: Wolfgang Müller
Date: Thu, 13 Feb 2025 17:52:16 +0100
Subject: frontend: Migrate to Svelte 5

---
 frontend/src/lib/dialogs/AddCharacter.svelte | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

(limited to 'frontend/src/lib/dialogs/AddCharacter.svelte')

diff --git a/frontend/src/lib/dialogs/AddCharacter.svelte b/frontend/src/lib/dialogs/AddCharacter.svelte
index 23fea08..1585e34 100644
--- a/frontend/src/lib/dialogs/AddCharacter.svelte
+++ b/frontend/src/lib/dialogs/AddCharacter.svelte
@@ -1,30 +1,22 @@
 <script lang="ts">
-	import { addCharacter, type CharacterInput } from '$gql/Mutations';
+	import type { AddCharacterInput } from '$gql/graphql';
+	import { addCharacter } from '$gql/Mutations';
 	import Dialog from '$lib/components/Dialog.svelte';
-	import SubmitButton from '$lib/components/SubmitButton.svelte';
 	import CharacterForm from '$lib/forms/CharacterForm.svelte';
 	import { toastFinally } from '$lib/Toasts';
 	import { getContextClient } from '@urql/svelte';
-	import { closeModal } from 'svelte-modals';
+	import type { ModalProps } from 'svelte-modals';
 
 	const client = getContextClient();
 
-	export let isOpen: boolean;
+	let modal: ModalProps = $props();
+	const initial = { name: '' };
 
-	let character = { name: '' };
-
-	function add(event: CustomEvent<CharacterInput>) {
-		addCharacter(client, { input: event.detail }).then(closeModal).catch(toastFinally);
+	function submit(input: AddCharacterInput) {
+		addCharacter(client, { input }).then(modal.close).catch(toastFinally);
 	}
 </script>
 
-<Dialog {isOpen}>
-	<svelte:fragment slot="header">
-		<h2>Add Character</h2>
-	</svelte:fragment>
-	<CharacterForm bind:character on:submit={add}>
-		<div class="flex justify-end gap-4">
-			<SubmitButton active={character.name.length > 0} />
-		</div>
-	</CharacterForm>
+<Dialog title="Add Character" {...modal}>
+	<CharacterForm {initial} {submit} />
 </Dialog>
-- 
cgit v1.2.3-2-gb3c3

