<script lang="ts">

import { AdminAuth } from '../wailsjs/go/main/Admin.js'
import { adminLogin } from './global';

var username = "", password = ""
var loginFail = false

function login() {
    AdminAuth(username, password).then((result) => {
        if(result) {
            $adminLogin = true
        } else {
            loginFail = true
        }
    })
}

</script>
<main>
    <div class="container">
        <input type="text" placeholder="Username" bind:value={username} />
        <input type="password" placeholder="Password" bind:value={password} />
    </div>
    {#if loginFail}
        <p>Login Failed!</p>
    {/if}
    <button on:click={login}>Login</button>

</main>
<style>
* {
   box-sizing: border-box;
    font-family: sans-serif;
    --text-primary: #b6b6b6;
		--text-secondary: #ececec;
		--bg-primary: #23232e;
		--bg-secondary: #141418;
        
}
p {
    color: red;
    font-weight: bold;
}

.container{
    display: flex;
    justify-content: center;
    margin: 3rem;
}
</style>
