using System.Text.Json;
using System.Text.Json.Nodes;
using GerbilManagerWebAPI.Models;

namespace GerbilManagerWebAPI.Dtos
{
    // Response DTOs ----------------------------------------------------------

    public record PageSummaryDto(Guid Id, string Slug, string Title, string? SeoDescription, PageStatus Status);

    public record PageDto(
        Guid Id, string Slug, string Title, string? SeoDescription, PageStatus Status,
        IReadOnlyList<BlockDto> Blocks);

    /// <summary>Block.Data is emitted as a parsed JSON object (not a string).</summary>
    public record BlockDto(Guid Id, int Order, BlockType Type, JsonNode? Data);

    // Request DTOs -----------------------------------------------------------

    public record PageInput(string Slug, string Title, string? SeoDescription, PageStatus? Status);

    /// <summary>Data is the type-specific JSON object (e.g. {"markdown":"…"} for RichText).</summary>
    public record BlockInput(BlockType Type, JsonElement Data, int? Order);

    public record BlockOrderInput(List<Guid> BlockIds);
}
