<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 = "";
	export let route: "login" | "signup" = "login"

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

	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}