using FluentValidation;
using MktXService.API.Application.Commands;

namespace MktXService.API.Application.Validations;

/// <summary>
/// EN: Validator for SendMessageCommand.
/// VI: Validator cho SendMessageCommand.
/// </summary>
public class SendMessageCommandValidator : AbstractValidator<SendMessageCommand>
{
    public SendMessageCommandValidator()
    {
        RuleFor(x => x.ConversationId)
            .NotEmpty()
            .WithMessage("Conversation ID is required / Conversation ID là bắt buộc");

        RuleFor(x => x.Content)
            .NotEmpty()
            .WithMessage("Message content is required / Nội dung tin nhắn là bắt buộc")
            .MaximumLength(10000)
            .WithMessage("Message content must be less than 10000 characters / Nội dung tin nhắn phải ít hơn 10000 ký tự");

        RuleFor(x => x.MediaUrls)
            .Must(urls => urls == null || urls.Count <= 4)
            .WithMessage("Maximum 4 media attachments allowed / Tối đa 4 tệp đính kèm");
    }
}

/// <summary>
/// EN: Validator for CloseConversationCommand.
/// VI: Validator cho CloseConversationCommand.
/// </summary>
public class CloseConversationCommandValidator : AbstractValidator<CloseConversationCommand>
{
    public CloseConversationCommandValidator()
    {
        RuleFor(x => x.ConversationId)
            .NotEmpty()
            .WithMessage("Conversation ID is required / Conversation ID là bắt buộc");

        RuleFor(x => x.Reason)
            .MaximumLength(500)
            .WithMessage("Reason must be less than 500 characters / Lý do phải ít hơn 500 ký tự")
            .When(x => x.Reason != null);
    }
}

/// <summary>
/// EN: Validator for AssignConversationCommand.
/// VI: Validator cho AssignConversationCommand.
/// </summary>
public class AssignConversationCommandValidator : AbstractValidator<AssignConversationCommand>
{
    public AssignConversationCommandValidator()
    {
        RuleFor(x => x.ConversationId)
            .NotEmpty()
            .WithMessage("Conversation ID is required / Conversation ID là bắt buộc");

        RuleFor(x => x.UserId)
            .NotEmpty()
            .WithMessage("User ID is required / User ID là bắt buộc");
    }
}

/// <summary>
/// EN: Validator for ReopenConversationCommand.
/// VI: Validator cho ReopenConversationCommand.
/// </summary>
public class ReopenConversationCommandValidator : AbstractValidator<ReopenConversationCommand>
{
    public ReopenConversationCommandValidator()
    {
        RuleFor(x => x.ConversationId)
            .NotEmpty()
            .WithMessage("Conversation ID is required / Conversation ID là bắt buộc");
    }
}

/// <summary>
/// EN: Validator for MarkConversationPendingCommand.
/// VI: Validator cho MarkConversationPendingCommand.
/// </summary>
public class MarkConversationPendingCommandValidator : AbstractValidator<MarkConversationPendingCommand>
{
    public MarkConversationPendingCommandValidator()
    {
        RuleFor(x => x.ConversationId)
            .NotEmpty()
            .WithMessage("Conversation ID is required / Conversation ID là bắt buộc");
    }
}
