refactor: unify UserProfileDto and add plan helpers

This commit is contained in:
2026-05-11 18:05:51 +00:00
parent b0875a095b
commit a3ded70977
@@ -1,24 +1,32 @@
using NexusReader.Application.Constants;
namespace NexusReader.Application.DTOs.User; namespace NexusReader.Application.DTOs.User;
public record UserProfileDto public record UserProfileDto
{ {
public string Email { get; init; } = string.Empty; public string Email { get; init; } = string.Empty;
public int AITokensUsed { get; init; }
public Guid TenantId { get; init; } public Guid TenantId { get; init; }
/// <summary>
/// Relational data for the current subscription plan.
/// </summary>
public SubscriptionPlanDto Plan { get; init; } = new(); public SubscriptionPlanDto Plan { get; init; } = new();
public int AITokensUsed { get; init; }
public int AverageQuizScore { get; init; } public string[] Roles { get; init; } = Array.Empty<string>();
/// <summary> // Statistics for Dashboard
/// Summary of the last read book. public int TotalBooksRead { get; init; }
/// </summary> public int AverageQuizScore { get; init; }
public LastReadBookDto? LastReadBook { get; init; } public LastReadBookDto? LastReadBook { get; init; }
public string[] Roles { get; init; } = Array.Empty<string>(); // UI Helpers
public string CurrentPlan => Plan.Name ?? PlanConstants.Free;
public int AITokenLimit => Plan.AITokenLimit > 0 ? Plan.AITokenLimit : PlanConstants.GetTokenLimit(CurrentPlan);
public string LastReadBookTitle => LastReadBook?.Title ?? "Brak aktywności";
}
public record SubscriptionPlanDto
{
public int Id { get; init; }
public string Name { get; init; } = string.Empty;
public int AITokenLimit { get; init; }
public decimal MonthlyPrice { get; init; }
} }
public record LastReadBookDto public record LastReadBookDto
@@ -27,7 +35,13 @@ public record LastReadBookDto
public string Title { get; init; } = string.Empty; public string Title { get; init; } = string.Empty;
public AuthorDto Author { get; init; } = new(); public AuthorDto Author { get; init; } = new();
public string? CoverUrl { get; init; } public string? CoverUrl { get; init; }
public double Progress { get; init; } public int Progress { get; init; }
public string? LastChapter { get; init; } public string LastChapter { get; init; } = string.Empty;
public int LastChapterIndex { get; init; } public int LastChapterIndex { get; init; }
} }
public record AuthorDto
{
public Guid Id { get; init; }
public string Name { get; init; } = string.Empty;
}