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

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

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

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

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

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