namespace HistoryView.Converters;

public class AuthorityToVis : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is not UserAuthority user)
            return Visibility.Collapsed;

        if (parameter is not string aquired)
            return Visibility.Collapsed;

        UserAuthority requriedAuthority = aquired switch
        {
            "Guest" => UserAuthority.Guest,
            "Operator" => UserAuthority.Operator,
            "Engineer" => UserAuthority.Engineer,
            _ => UserAuthority.God
        };

        if (user >= requriedAuthority)
            return Visibility.Visible;

        return Visibility.Collapsed;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
