package pl.polskalokalnie.report;

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

public record ListingReportResponse(
        Long id,
        Long listingId,
        String listingTitle,
        String listingCity,
        String listingOwnerEmail,
        String reasonId,
        String reasonTitle,
        String details,
        List<String> attachmentNames,
        List<ListingReportAttachmentResponse> attachments,
        String reporterEmail,
        String reporterName,
        ListingReportStatus status,
        boolean listingDeleted,
        Instant createdAt,
        Instant resolvedAt,
        String resolvedByEmail,
        String resolutionNote
) {
    public static ListingReportResponse from(ListingReport report) {
        return new ListingReportResponse(
                report.getId(),
                report.getListingId(),
                report.getListingTitle(),
                report.getListingCity(),
                report.getListingOwnerEmail(),
                report.getReasonId(),
                report.getReasonTitle(),
                report.getDetails(),
                report.getAttachments().stream().map(ListingReportAttachment::getFileName).toList(),
                report.getAttachments().stream().map(ListingReportAttachmentResponse::from).toList(),
                report.getReporterEmail(),
                report.getReporterName(),
                report.getStatus(),
                report.isListingDeleted(),
                report.getCreatedAt(),
                report.getResolvedAt(),
                report.getResolvedByEmail(),
                report.getResolutionNote()
        );
    }
}
