using SolutionErp.Application.Budgets.Dtos;
using SolutionErp.Domain.Contracts;

namespace SolutionErp.Application.Contracts.Dtos;

public record ContractListItemDto(
    Guid Id,
    string? MaHopDong,
    string? TenHopDong,
    ContractType Type,
    ContractPhase Phase,
    Guid SupplierId,
    string SupplierName,
    Guid ProjectId,
    string ProjectName,
    decimal GiaTri,
    DateTime? SlaDeadline,
    DateTime CreatedAt);

public record ContractDetailDto(
    Guid Id,
    string? MaHopDong,
    string? TenHopDong,
    string? NoiDung,
    ContractType Type,
    ContractPhase Phase,
    Guid SupplierId,
    string SupplierName,
    Guid ProjectId,
    string ProjectName,
    Guid? DepartmentId,
    string? DepartmentName,
    Guid? DrafterUserId,
    string? DrafterName,
    Guid? TemplateId,
    decimal GiaTri,
    bool BypassProcurementAndCCM,
    DateTime? SlaDeadline,
    string? DraftData,
    DateTime CreatedAt,
    DateTime? UpdatedAt,
    Guid? BudgetId,
    BudgetSummaryDto? Budget,
    string? BudgetManualName,
    decimal? BudgetManualAmount,
    List<ContractApprovalDto> Approvals,
    List<ContractCommentDto> Comments,
    List<ContractAttachmentDto> Attachments,
    WorkflowSummaryDto Workflow);

// Policy snapshot for the FE — lets UI render next-phase buttons dynamically
// without hardcoding the transition map (single source of truth in BE).
public record WorkflowSummaryDto(
    string PolicyName,
    string PolicyDescription,
    List<ContractPhase> ActivePhases,
    List<ContractPhase> NextPhases);

public record ContractApprovalDto(
    Guid Id,
    ContractPhase FromPhase,
    ContractPhase ToPhase,
    Guid? ApproverUserId,
    string? ApproverName,
    ApprovalDecision Decision,
    string? Comment,
    DateTime ApprovedAt);

public record ContractCommentDto(
    Guid Id,
    Guid UserId,
    string UserName,
    ContractPhase Phase,
    string Content,
    DateTime CreatedAt);

public record ContractAttachmentDto(
    Guid Id,
    string FileName,
    string StoragePath,
    long FileSize,
    string ContentType,
    AttachmentPurpose Purpose,
    string? Note,
    DateTime CreatedAt);
