@page "/account/login"
@using PanoptesFrontend.Data.Account;
@using PanoptesFrontend.Services;
@inject IAccountService AccountService


<div class="card">
    <h4 class="card-header">Login</h4>
    <div class="card-body">
        <EditForm Model="@model" OnValidSubmit="@OnValidSubmit">
            <DataAnnotationsValidator />
            <div class="form-group">
                <label>Username</label>
                <InputText @bind-Value="@model.Username" class="form-control" />
                <ValidationMessage For="@(() => model.Username)" />
            </div>
            <div class="form-group">
                <label>Password</label>
                <InputText @bind-Value="@model.Password" type="password" class="form-control" />
                <ValidationMessage For="@(() => model.Password)" />
            </div>
            <button class="btn btn-primary" type="submit">
                Login
            </button>
            <NavLink href="account/register" class="btn btn-link">Register</NavLink>
        </EditForm>
    </div>
</div>

@code {
    private LoginUser model = new LoginUser();

    private async void OnValidSubmit()
    {
        Console.WriteLine("Method called");
        await AccountService.Login(model);
    }
}