using Microsoft.AspNetCore.Components;
using Server.Data;
using Server.Model;

namespace Server.Components.Pages
{
    public partial class SettingsPage : ComponentBase
    {
        #region Override SetParametersAsync

        //// <inheritdoc />
        public override async Task SetParametersAsync(ParameterView parameters)
        {
            parameters.SetParameterProperties(this);

            await SettingsData.LoadAsync();

            await base.SetParametersAsync(ParameterView.Empty);
        }

        #endregion

        #region Private Method Save

        /// <summary>
        ///     Asynchronously saves the current settings to a JSON file.
        /// </summary>
        /// <returns>A task that represents the asynchronous save operation.</returns>
        private async Task Save() => await SettingsData.SaveAsync();

        #endregion
    }
}