package pl.polskalokalnie.listing;

import java.math.BigDecimal;
import java.time.Instant;
import java.util.List;

/**
 * Pelna reprezentacja ogloszenia dla widoku szczegolow - zawiera wszystkie pola z formularza
 * dodawania oraz cala galerie zdjec (data URL).
 */
public record ListingDetailResponse(
        Long id,
        String title,
        String description,
        OfferType offerType,
        PropertyType propertyType,
        String city,
        String district,
        String street,
        String building,
        String address,
        BigDecimal price,
        Double area,
        Integer rooms,
        String floor,
        String buildingFloors,
        String market,
        Integer yearBuilt,
        String condition,
        String ownership,
        String contactName,
        String contactPhone,
        String contactEmail,
        BigDecimal rentExtra,
        String availableFrom,
        String furnishing,
        String buildingType,
        String buildingMaterial,
        String windows,
        String exposure,
        String roomHeight,
        Double lat,
        Double lng,
        List<String> media,
        List<String> amenities,
        List<String> photos,
        String ownerEmail,
        ListingStatus status,
        Instant createdAt,
        Long viewsCount
) {
    public static ListingDetailResponse from(PropertyListing listing) {
        return new ListingDetailResponse(
                listing.getId(),
                listing.getTitle(),
                listing.getDescription(),
                listing.getOfferType(),
                listing.getPropertyType(),
                listing.getCity(),
                listing.getDistrict(),
                listing.getStreet(),
                listing.getBuilding(),
                listing.getAddress(),
                listing.getPrice(),
                listing.getArea(),
                listing.getRooms(),
                listing.getFloor(),
                listing.getBuildingFloors(),
                listing.getMarket(),
                listing.getYearBuilt(),
                listing.getCondition(),
                listing.getOwnership(),
                listing.getContactName(),
                listing.getContactPhone(),
                listing.getContactEmail(),
                listing.getRentExtra(),
                listing.getAvailableFrom(),
                listing.getFurnishing(),
                listing.getBuildingType(),
                listing.getBuildingMaterial(),
                listing.getWindows(),
                listing.getExposure(),
                listing.getRoomHeight(),
                listing.getLat(),
                listing.getLng(),
                List.copyOf(listing.getMedia()),
                List.copyOf(listing.getAmenities()),
                List.copyOf(listing.getPhotos()),
                listing.getOwnerEmail(),
                listing.getStatus(),
                listing.getCreatedAt(),
                listing.getViewsCount()
        );
    }
}
