using SolutionErp.Domain.Contracts;

namespace SolutionErp.Application.Common.Interfaces;

// Service ghi ContractChangelog. KHÔNG SaveChanges — caller (CQRS handler)
// chịu trách nhiệm save atomic cùng với business changes. Pattern giống
// INotificationService.
public interface IChangelogService
{
    Task LogContractChangeAsync(
        Guid contractId,
        ChangelogAction action,
        string? summary = null,
        string? fieldChangesJson = null,
        string? contextNote = null,
        ContractPhase? phaseAtChange = null,
        CancellationToken ct = default);

    Task LogDetailChangeAsync(
        Guid contractId,
        Guid detailId,
        ChangelogAction action,
        string? summary = null,
        string? fieldChangesJson = null,
        ContractPhase? phaseAtChange = null,
        CancellationToken ct = default);

    Task LogWorkflowTransitionAsync(
        Guid contractId,
        ContractPhase fromPhase,
        ContractPhase toPhase,
        string? comment,
        CancellationToken ct = default);

    Task LogCommentAddedAsync(Guid contractId, string content, ContractPhase phase, CancellationToken ct = default);

    Task LogAttachmentAsync(
        Guid contractId,
        Guid attachmentId,
        ChangelogAction action,
        string fileName,
        ContractPhase phase,
        CancellationToken ct = default);
}
