using System.ComponentModel.DataAnnotations;

namespace ROLAC.API.DTOs.Invitations;

/// <summary>
/// Admin request to generate a first-login invitation link for a member. If the member has no
/// account yet, one is auto-created (no password) using <see cref="Email"/> or the member's email.
/// </summary>
public class CreateInvitationRequest
{
    [Required]
    public int MemberId { get; set; }

    /// <summary>Optional override for the login email when the member has none on file.</summary>
    public string? Email { get; set; }

    /// <summary>Roles to assign when an account is created. Defaults to ["member"].</summary>
    public List<string>? Roles { get; set; }
}

/// <summary>Result of generating an invitation — the raw token is returned ONCE.</summary>
public class CreateInvitationResult
{
    public string   Token     { get; set; } = null!;
    public DateTime ExpiresAt { get; set; }
}

/// <summary>Admin request to e-mail an already-generated invitation link to the member.</summary>
public class SendInvitationRequest
{
    [Required]
    public int MemberId { get; set; }

    [Required]
    public string Link { get; set; } = null!;
}

/// <summary>Public result describing whether an invitation token can still be used.</summary>
public class ValidateInvitationResult
{
    public bool    Valid      { get; set; }
    public bool    Expired    { get; set; }
    public string? MemberName { get; set; }
    public string? Email      { get; set; }
}

/// <summary>Public request to consume an invitation and set the account password.</summary>
public class AcceptInvitationRequest
{
    [Required]
    public string Token { get; set; } = null!;

    [Required]
    [StringLength(128, MinimumLength = 8)]
    public string NewPassword { get; set; } = null!;
}
