<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;
	}
</script>

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