<script lang="ts">
	import { enhance } from "$app/forms";
	import type { PageProps } from "./$types";
	let { data, form }: PageProps = $props();
</script>

<svelte:head>
	<title>Log ind</title>
</svelte:head>

<!-- If login completed successfully and we dont have ?redirectTo -->
{#if form?.success}
	<p>Du er nu logget ind!</p>
{/if}

<form method="POST" use:enhance>
	{#if form?.failure}<p class="error">{form?.error}</p>{/if}
	<label>
		Email
		<input name="email" type="email" />
	</label>
	<label>
		Kodeord
		<input name="password" type="password" />
	</label>
	<button>Log ind</button>
</form>

<style>
	label {
		display: block;
	}
</style>
