using Indotalent.ConfigBackEnd.Interfaces;
using Indotalent.ConfigFrontEnd.Models;
using Indotalent.ConfigFrontEnd.Service;
using MudBlazor;
using MudBlazor.Services;

namespace Indotalent.ConfigFrontEnd;

public static class DI
{
    public static IServiceCollection AddConfigFrontEndDI(this IServiceCollection services)
    {
        services.AddMudServices(config =>
        {
            config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.TopRight;
            config.SnackbarConfiguration.PreventDuplicates = true;
            config.SnackbarConfiguration.NewestOnTop = true;
            config.SnackbarConfiguration.ShowCloseIcon = true;
            config.SnackbarConfiguration.VisibleStateDuration = 5000;
            config.SnackbarConfiguration.HideTransitionDuration = 300;
            config.SnackbarConfiguration.ShowTransitionDuration = 300;
            config.SnackbarConfiguration.SnackbarVariant = Variant.Filled;
        });


        services.AddHttpClient("AppClient", client =>
        {
            client.Timeout = TimeSpan.FromMinutes(30);
            client.DefaultRequestHeaders.Add("Accept", "application/json");
        });

        services.AddScoped<CurrentUserState>();
        services.AddScoped<ICurrentUserService, CurrentUserService>();

        return services;
    }
}