using PowderCoating.Core.Entities;
using PowderCoating.Core.Enums;

namespace PowderCoating.Core.Interfaces.Repositories;

/// <summary>
/// Typed repository for <see cref="NotificationLog"/> that adds IgnoreQueryFilters-based lookups
/// by entity FK (InvoiceId, QuoteId, JobId) on top of the generic CRUD interface.
/// All methods bypass soft-delete and tenant filters so notification history is always visible
/// regardless of whether the linked entity has been soft-deleted.
/// </summary>
public interface INotificationLogRepository : IRepository<NotificationLog>
{
    /// <summary>Returns the most recent notification log entry for the given invoice, or null.</summary>
    Task<NotificationLog?> GetLatestForInvoiceAsync(int invoiceId, int companyId);

    /// <summary>Returns all notification log entries for the given invoice, newest-first.</summary>
    Task<List<NotificationLog>> GetAllForInvoiceAsync(int invoiceId, int companyId);

    /// <summary>Returns the most recent notification log entry for the given quote, or null.</summary>
    Task<NotificationLog?> GetLatestForQuoteAsync(int quoteId, int companyId);

    /// <summary>Returns all notification log entries for the given quote, newest-first.</summary>
    Task<List<NotificationLog>> GetAllForQuoteAsync(int quoteId, int companyId);

    /// <summary>Returns the most recent notification log entry for the given job, or null.</summary>
    Task<NotificationLog?> GetLatestForJobAsync(int jobId, int companyId);

    /// <summary>Returns all notification log entries for the given job, newest-first.</summary>
    Task<List<NotificationLog>> GetAllForJobAsync(int jobId, int companyId);

    /// <summary>
    /// Returns a paginated, filtered, and sorted page of notification log entries with Customer,
    /// Job, and Quote navigations loaded. All filter parameters are optional — omit to include all.
    /// Used by the company-scoped notification log index view.
    /// </summary>
    Task<(List<NotificationLog> Items, int TotalCount)> GetPagedFilteredAsync(
        int pageNumber, int pageSize,
        string? searchTerm = null,
        NotificationChannel? channel = null,
        NotificationStatus? status = null,
        NotificationType? type = null,
        int? jobId = null,
        string sortColumn = "SentAt",
        string sortDirection = "desc");
}
