using System.Windows.Controls;
using Microsoft.Extensions.DependencyInjection;
using SharepointToolbox.Core.Models;
using SharepointToolbox.ViewModels.Tabs;
using SharepointToolbox.Views.Dialogs;

namespace SharepointToolbox.Views.Tabs;

public partial class PermissionsView : UserControl
{
    public PermissionsView(IServiceProvider serviceProvider)
    {
        InitializeComponent();
        var vm = serviceProvider.GetRequiredService<PermissionsViewModel>();
        DataContext = vm;
        vm.OpenSitePickerDialog = () =>
        {
            var factory = serviceProvider.GetRequiredService<Func<TenantProfile, SitePickerDialog>>();
            return factory(vm.CurrentProfile ?? new TenantProfile());
        };
    }
}
