using FrontOffice.Main.Utilities;

namespace FrontOffice.Main.Pages;

public partial class About
{
    private bool _loading = true;
    private PageSettingsDto? _page;
    private AboutSettings? _settings;
    private List<PageSettingsImageDto> _valueImages = new();
    private List<PageSettingsImageDto> _teamImages = new();

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

            if (_page != null)
            {
                _settings = _page.GetSettings<AboutSettings>();
                _valueImages = _page.GetImages("values");
                _teamImages = _page.GetImages("team");
            }
        }
        catch
        {
            // Fallback: page remains null → hardcoded content will render
        }
        finally
        {
            _loading = false;
        }
    }

    private class AboutSettings
    {
        public string? VisionTitle { get; set; }
        public string? VisionText { get; set; }
        public string? VisionIcon { get; set; }
        public string? MissionTitle { get; set; }
        public string? MissionText { get; set; }
        public string? MissionIcon { get; set; }
        public string? ValuesTitle { get; set; }
        public string? TeamTitle { get; set; }
    }
}