#nullable enable
using System.Globalization;
using Baya.Application.Models.Booking;

namespace Baya.Application.Features.Booking;

/// <summary>
/// Maps the role-agnostic detail projection to the wire DTO. <paramref name="includeFullAddress"/> is the
/// stage-1 disclosure switch: the owning customer (and admin) get the full decrypted address; the nurse
/// gets only the coarse city/district location plus <c>customer_notes</c>, never the encrypted address line.
/// </summary>
internal static class BookingRequestMapper
{
    public static BookingRequestDto ToDto(BookingRequestDetailProjection p, bool includeFullAddress)
        => new(
            p.Id,
            p.Status,
            p.NurseId,
            p.NurseName,
            p.NurseRating,
            p.NurseTotalReviews,
            p.PatientId,
            p.PatientName,
            p.VariantId,
            p.VariantLabel,
            p.VariantPriceUnit,
            p.CustomerAddressId,
            p.AddressTitle,
            p.CityId,
            p.CityNameFa,
            p.CityNameEn,
            p.DistrictId,
            p.DistrictNameFa,
            p.DistrictNameEn,
            includeFullAddress ? p.AddressLine : null,
            includeFullAddress ? p.PostalCode : null,
            includeFullAddress ? p.RecipientName : null,
            includeFullAddress ? p.RecipientPhone : null,
            p.RequiredCaregiverGender,
            p.RequestedDate,
            p.RequestedTimeStart,
            p.RequestedTimeEnd,
            p.CustomerNotes,
            p.NurseResponseDeadlineAt,
            p.PaymentDeadlineAt,
            p.NurseRejectionReason,
            p.CreatedAt,
            p.VariantPrice.ToString(CultureInfo.InvariantCulture),
            p.NurseAvatarUrl,
            p.BookingId);
}
