using SolutionErp.Domain.Hrm;

namespace SolutionErp.Application.Hrm.Dtos;

// Phase 10.1 G-H1 Task 4 (S33) — DTO bundle cho Hồ sơ Nhân sự CQRS.
// 1 list item + 1 detail full + 5 satellite read DTO (inline GetDetail).
// Satellite WRITE DTO defer Phase 1.5 — Task 4 chỉ read.

// ========== List item (paged) ==========

// JOIN Users + Departments LEFT (User.DepartmentId nullable per Identity entity).
// FullName + Email từ User; DepartmentId + DepartmentName từ User → Department.
public record EmployeeProfileListItemDto(
    Guid Id,
    string EmployeeCode,
    Guid UserId,
    string? FullName,
    string? Email,
    Guid? DepartmentId,
    string? DepartmentName,
    EmployeeStatus Status,
    string? Phone,
    DateOnly? HireDate,
    DateTime CreatedAt,
    DateTime? UpdatedAt);

// ========== Detail (full + 5 satellite collection) ==========

public record EmployeeProfileDetailDto(
    Guid Id,
    string EmployeeCode,
    Guid UserId,
    string? FullName,
    string? Email,
    Guid? DepartmentId,
    string? DepartmentName,
    EmployeeStatus EmployeeStatus,
    Gender? Gender,
    MaritalStatus? MaritalStatus,
    EmployeeType? EmployeeType,
    DateOnly? DateOfBirth,
    string? BirthPlace,
    string? Hometown,
    string? Phone,
    string? PersonalEmail,
    string? InternalPhone,
    string? Ethnicity,
    string? Religion,
    string? Nationality,
    string? IdCardNumber,
    DateOnly? IdCardIssueDate,
    string? IdCardIssuePlace,
    string? TaxCode,
    string? SocialInsuranceNumber,
    string? PassportNumber,
    string? PermanentAddressText,
    string? StreetAddressPermanent,
    string? TemporaryAddressText,
    string? StreetAddressTemporary,
    DateOnly? HireDate,
    DateOnly? ResignDate,
    string? EmergencyContactName,
    string? EmergencyContactPhone,
    string? EmergencyContactAddress,
    string? Qualification,
    string? AcademicTitle,
    string? WorkLocation,
    string? TimekeepingCode,
    string? BankAccount,
    string? BankName,
    string? BankBranch,
    int? HeightCm,
    int? WeightKg,
    string? BloodType,
    decimal? BaseSalary,
    decimal? TotalSalary,
    decimal? AnnualLeaveDays,
    decimal? RemainingLeaveDays,
    decimal? CompensatoryLeaveDays,
    decimal? SeniorityLeaveDays,
    DateOnly? SocialInsuranceStartDate,
    string? MedicalRegistrationPlace,
    bool IsCommunistParty,
    DateOnly? CommunistPartyJoinDate,
    bool IsYouthUnion,
    DateOnly? YouthUnionJoinDate,
    bool IsTradeUnion,
    DateOnly? TradeUnionJoinDate,
    string? PhotoUrl,
    string? Notes,
    DateTime CreatedAt,
    DateTime? UpdatedAt,
    List<EmployeeWorkHistoryDto> WorkHistories,
    List<EmployeeEducationDto> Educations,
    List<EmployeeFamilyRelationDto> FamilyRelations,
    List<EmployeeSkillDto> Skills,
    List<EmployeeDocumentDto> Documents);

// ========== Satellite read DTOs (inline GetDetail bundle) ==========

public record EmployeeWorkHistoryDto(
    Guid Id,
    string CompanyName,
    string? CompanyAddress,
    string? Industry,
    DateOnly? FromDate,
    DateOnly? ToDate,
    string? JobTitle,
    string? JobDescription,
    string? ResignReason);

public record EmployeeEducationDto(
    Guid Id,
    string SchoolName,
    string? Major,
    DegreeLevel? DegreeLevel,
    EducationMode? EducationMode,
    GradeLevel? GradeLevel,
    DateOnly? FromDate,
    DateOnly? ToDate,
    DateOnly? CertificateIssueDate,
    string? Notes);

public record EmployeeFamilyRelationDto(
    Guid Id,
    string FullName,
    FamilyRelationKind Relationship,
    int? BirthYear,
    string? Occupation,
    string? CurrentAddress,
    string? Phone);

// Polymorphic — Kind discriminator. Computer/Language/Other (semantic xem
// EmployeeSkill.cs comment header).
public record EmployeeSkillDto(
    Guid Id,
    SkillKind Kind,
    string Name,
    string? LanguageId,
    string? Level);

public record EmployeeDocumentDto(
    Guid Id,
    EmployeeDocumentType DocumentType,
    string FileName,
    string FilePath,
    long FileSize,
    string ContentType,
    DateOnly? IssueDate,
    DateOnly? ExpiryDate,
    string? Notes);
