@inject IInstallationService InstallationService

@if (_initialized)
{
    @if (!_installation.Success)
    {
        <Installer />
    }
    else
    {
        @if (string.IsNullOrEmpty(_installation.Message))
        {
            <CascadingAuthenticationState>
                <CascadingValue Value="@PageState">
                    <SiteRouter OnStateChange="@ChangeState" />
                </CascadingValue>
            </CascadingAuthenticationState>
        }
        else
        {
            <div class="app-alert">
                @_installation.Message
            </div> 
        }
    }
}

@code {
    private Installation _installation;
    private bool _initialized;

    private PageState PageState { get; set; }

    protected override async Task OnParametersSetAsync()
    {
        _installation = await InstallationService.IsInstalled();
        _initialized = true;
    }

    private void ChangeState(PageState pageState)
    {
        PageState = pageState;
        StateHasChanged();
    }
}
