<script lang="ts">
	import { loginClient } from "#lib/login.js";
	import EmbeddedLoginModule from "./EmbeddedLoginModule.svelte"
	import EmbeddedRegisterModule from "./EmbeddedRegisterModule.svelte"

	export let onLogin: (response: Awaited<ReturnType<typeof loginClient>>) => any;
	export let email: string = "";
	export let password: string = "";

	let route: "login" | "signup" = "login"

	const navigate = (target: typeof route) => {
		route = target
	}

	const loginData = {
		email,
		passwort: "",
	}
</script>

{#if route == "login"}
	<EmbeddedLoginModule onLogin={onLogin} bind:email bind:password {navigate} />
{:else}
	<EmbeddedRegisterModule bind:email bind:password onRegister={(response) => {
		email = response.email
		navigate("login")
	}} {navigate} />
{/if}