@page "/inventur"

@inject NavigationManager Nav

<h3>Inventur</h3>

<div style="display:grid;gap:.6rem;max-width:320px">
    <button class="inventur-btn" @onclick='() => Nav.NavigateTo("/inventur/vorbereiten")'>1. Vorbereiten</button>
    <button class="inventur-btn" @onclick='() => Nav.NavigateTo("/inventur/starten")'>2. Starten</button>
    <button class="inventur-btn" @onclick='() => Nav.NavigateTo("/inventur/liste")'>3. Liste</button>
    <button class="inventur-btn" @onclick='() => Nav.NavigateTo("/inventur/abschliessen")'>4. Abschließen</button>
</div>

<style>
    .inventur-btn {
        height: 60px;
        font-size: 18px;
        width: 100%;
    }
</style>

@code {
    protected override void OnAfterRender(bool firstRender)
    {
        if (firstRender)
        {
            // Event registrieren
            _ = JS.InvokeVoidAsync("initMenuHotkeys", DotNetObjectReference.Create(this));
        }
    }

    [Inject] IJSRuntime JS { get; set; } = default!;

    [JSInvokable]
    public void HandleKey(string key)
    {
        switch (key)
        {
            case "1": Nav.NavigateTo("/inventur/vorbereiten"); break;
            case "2": Nav.NavigateTo("/inventur/starten"); break;
            case "3": Nav.NavigateTo("/inventur/liste"); break;
            case "4": Nav.NavigateTo("/inventur/abschliessen"); break;
        }
    }

}
