<script>
    import { getContext } from "svelte";
    import { apiPost } from "../../helpers";

    const channel = getContext("channel");
    export let email;
    export let token;

    function login(e) {
        e.preventDefault();

        apiPost(channel.lucentUrl + "/verify", {
            email: email,
            token: token,
        })
            .then((response) => {
                window.location = channel.lucentUrl;
            })
            .catch((error) => {});
    }
</script>

<div class="scope-login">
    <div class="bg-image"></div>
    <div class="login-form">
        <div class="form">
            <h2 class="mb-5">Welcome to Lucent</h2>
            <form on:submit={login}>
                <button class="bt bt-primary">
                    Enter as {email}
                    <img
                        alt="indicator"
                        id="indicator"
                        class="htmx-indicator"
                        src="/img/spinner.svg"
                    />
                </button>
            </form>
            <div class="form-errors"></div>
        </div>
    </div>
</div>
