namespace planli.frontend.Models;

// ── Auth ────────────────────────────────────────────────────────────────────

public record LoginRequest(string Email, string Password);
public record RegisterRequest(string Name, string Email, string Password);

/// <summary>Returned by login, register, and GET /api/Auth/me.</summary>
public record MeResponse(int Id, string Name, string Email);

// ── Boards ──────────────────────────────────────────────────────────────────

public record BoardResponse(int Id, string Name, List<MemberResponse> Members);
public record CreateBoardRequest(string Name);

// ── Members ─────────────────────────────────────────────────────────────────

// Role: Owner=0, Editor=1, Viewer=2
public record MemberResponse(int UserId, string Name, string Email, int Role);

// ── ToDos ────────────────────────────────────────────────────────────────────
// Priority:  anyTime=0  thisMonth=1  thisWeek=2  today=3
// Status:    NotStarted=0  InProgress=1  Completed=2  Cancelled=3
// Recurrence: Daily=0  Weekly=1  Monthly=2

public record ToDoResponse(
    int Id,
    string Title,
    string? Description,
    int Priority,
    int Status,
    int BoardId,
    int UserId,
    string CreatedAt,
    bool IsRecurring,
    int? Recurrence);

public record CreateToDoRequest(
    string Title,
    string? Description,
    int Priority,
    int BoardId,
    bool IsRecurring,
    int? Recurrence);

public record UpdateToDoRequest(
    string? Title,
    string? Description,
    int? Priority,
    int? Status,
    bool IsRecurring,
    int? Recurrence);

// ── Display helpers ──────────────────────────────────────────────────────────

public static class TodoPriority
{
    public const int AnyTime   = 0;
    public const int ThisMonth = 1;
    public const int ThisWeek  = 2;
    public const int Today     = 3;

    public static string Label(int p) => p switch
    {
        3 => "Today",
        2 => "This Week",
        1 => "This Month",
        _ => "Any Time"
    };

    public static string Color(int p) => p switch
    {
        3 => "#ef4444",
        2 => "#f97316",
        1 => "#eab308",
        _ => "#22c55e"
    };
}

public static class TodoStatus
{
    public const int NotStarted = 0;
    public const int InProgress = 1;
    public const int Completed  = 2;
    public const int Cancelled  = 3;
    public const int Backlog    = 4;

    public static string Label(int s) => s switch
    {
        1 => "In Progress",
        2 => "Completed",
        3 => "Cancelled",
        4 => "Backlog",
        _ => "Not Started"
    };
}
