using Microsoft.AspNetCore.Components;
using SessionZeroClient.Components;
using SessionZeroClient.PageData;

namespace SessionZeroClient.Pages;

public partial class Home : ComponentBase
{
    private RenderFragment? _state;

    private AccountPageData _data;

    private void LoadAccountPage()
    {
        LoadPage(typeof(AccountPage));
    }
    
    private void LoadPage(Type pageType)
    {
        _state = builder =>
        {
            builder.OpenComponent(0, pageType);
            builder.AddAttribute(1, "Data", _data);
            builder.CloseComponent();
        };
        
        StateHasChanged();
    }

    protected override void OnInitialized()
    {
        _data = new()
        {
            UserName = "Hagrid",
        };
        //LoadAccountPage();
        base.OnInitialized();
    }
}