using ConversationMetadata = Noctalk.Shared.Chat.Api.Json.Admin_client__to__server.Command.Conversation__metadata;

namespace Noctalk_client.Admin;

public sealed class Conversation_metadata_view_model
{
    public Guid Conversation_guid { get; set; }

    public string Conversation__metadata__date__created__local { get; set; } = string.Empty;

    public int Pending_messages__count { get; set; }

    public string Pending_messages__display => Pending_messages__count == 0 ? string.Empty : Pending_messages__count.ToString();

    public int Client_A__pending_message_count { get; set; }

    public string Client_A__last_sent__date__local { get; set; } = string.Empty;

    public int Client_B__pending_message_count { get; set; }

    public string Client_B__last_sent__date__local { get; set; } = string.Empty;

    public static Conversation_metadata_view_model From__metadata(ConversationMetadata The_metadata)
    {
        return new Conversation_metadata_view_model
        {
            Conversation_guid = The_metadata.Conversation_guid,
            Conversation__metadata__date__created__local = The_metadata.Conversation__metadata__date__created.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"),
            Pending_messages__count = The_metadata.Pending_messages__count,
            Client_A__pending_message_count = The_metadata.Client_A__pending_message_count,
            Client_A__last_sent__date__local = The_metadata.Client_A__last_sent__date?.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") ?? string.Empty,
            Client_B__pending_message_count = The_metadata.Client_B__pending_message_count,
            Client_B__last_sent__date__local = The_metadata.Client_B__last_sent__date?.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") ?? string.Empty
        };
    }
}
