summaryrefslogtreecommitdiffstatshomepage
path: root/frontend/src/lib/dialogs/AddNamespace.svelte
blob: 45183f435d3d9cccb4afcf011e2a07e9b7bea64e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<script lang="ts">
	import type { AddNamespaceInput } from '$gql/graphql';
	import { addNamespace } from '$gql/Mutations';
	import Dialog from '$lib/components/Dialog.svelte';
	import NamespaceForm from '$lib/forms/NamespaceForm.svelte';
	import { toastFinally } from '$lib/Toasts';
	import { getContextClient } from '@urql/svelte';
	import type { ModalProps } from 'svelte-modals';

	const client = getContextClient();

	let modal: ModalProps = $props();
	const initial = { name: '' };

	function submit(input: AddNamespaceInput) {
		addNamespace(client, { input }).then(modal.close).catch(toastFinally);
	}
</script>

<Dialog title="Add Namespace" {...modal}>
	<NamespaceForm {initial} {submit} />
</Dialog>