namespace SharepointToolbox.Core.Models;

public record SiteInfo(string Url, string Title)
{
    public long StorageUsedMb { get; init; }
    public long StorageQuotaMb { get; init; }
    public string Template { get; init; } = string.Empty;

    public SiteKind Kind => SiteKindHelper.FromTemplate(Template);
}

public enum SiteKind
{
    Unknown,
    TeamSite,
    CommunicationSite,
    Classic
}

public static class SiteKindHelper
{
    public static SiteKind FromTemplate(string template)
    {
        if (string.IsNullOrEmpty(template)) return SiteKind.Unknown;
        if (template.StartsWith("GROUP#", StringComparison.OrdinalIgnoreCase)) return SiteKind.TeamSite;
        if (template.StartsWith("SITEPAGEPUBLISHING#", StringComparison.OrdinalIgnoreCase)) return SiteKind.CommunicationSite;
        if (template.StartsWith("STS#", StringComparison.OrdinalIgnoreCase)) return SiteKind.Classic;
        return SiteKind.Unknown;
    }

    public static string DisplayName(SiteKind kind)
    {
        var key = kind switch
        {
            SiteKind.TeamSite => "sitepicker.kind.teamsite",
            SiteKind.CommunicationSite => "sitepicker.kind.communication",
            SiteKind.Classic => "sitepicker.kind.classic",
            _ => "sitepicker.kind.other"
        };
        return Localization.TranslationSource.Instance[key];
    }
}
