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/AddWorld.svelte | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

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

diff --git a/frontend/src/lib/dialogs/AddWorld.svelte b/frontend/src/lib/dialogs/AddWorld.svelte
index ceb946e..075d872 100644
--- a/frontend/src/lib/dialogs/AddWorld.svelte
+++ b/frontend/src/lib/dialogs/AddWorld.svelte
@@ -1,30 +1,22 @@
 <script lang="ts">
-	import { addWorld, type WorldInput } from '$gql/Mutations';
+	import type { AddWorldInput } from '$gql/graphql';
+	import { addWorld } from '$gql/Mutations';
 	import Dialog from '$lib/components/Dialog.svelte';
-	import SubmitButton from '$lib/components/SubmitButton.svelte';
 	import WorldForm from '$lib/forms/WorldForm.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 world = { name: '' };
-
-	function add(event: CustomEvent<WorldInput>) {
-		addWorld(client, { input: event.detail }).then(closeModal).catch(toastFinally);
+	function submit(input: AddWorldInput) {
+		addWorld(client, { input }).then(modal.close).catch(toastFinally);
 	}
 </script>
 
-<Dialog {isOpen}>
-	<svelte:fragment slot="header">
-		<h2>Add World</h2>
-	</svelte:fragment>
-	<WorldForm bind:world on:submit={add}>
-		<div class="flex justify-end gap-4">
-			<SubmitButton active={world.name.length > 0} />
-		</div>
-	</WorldForm>
+<Dialog title="Add World" {...modal}>
+	<WorldForm {initial} {submit} />
 </Dialog>
-- 
cgit v1.2.3-2-gb3c3

