using FrontOffice.Main.Utilities;

namespace FrontOffice.Main.Pages;

public partial class About
{
    private bool _loading = true;
    private SitePageDto? _page;
    private SitePageSectionDto? _visionSection;
    private SitePageSectionDto? _missionSection;
    private List<SitePageSectionDto> _valueSections = new();
    private List<SitePageSectionDto> _teamSections = new();

    protected override async Task OnInitializedAsync()
    {
        try
        {
            _page = await SitePageService.GetByKeyAsync("about");

            if (_page != null)
            {
                _visionSection = _page.GetSection("vision");
                _missionSection = _page.GetSection("mission");
                _valueSections = _page.GetSections("value-").ToList();
                _teamSections = _page.GetSections("team-").ToList();
            }
        }
        catch
        {
            // Fallback: page remains null → hardcoded content will render
        }
        finally
        {
            _loading = false;
        }
    }
}