import { type ListingStatus, type TransactionType, type PropertyType, type Direction } from '@prisma/client';

/** Returned by findByIdWithProperty — full listing detail with property, seller, agent */
export interface ListingDetailData {
  id: string;
  status: ListingStatus;
  transactionType: TransactionType;
  priceVND: string;
  pricePerM2: number | null;
  rentPriceMonthly: string | null;
  commissionPct: number | null;
  viewCount: number;
  saveCount: number;
  inquiryCount: number;
  isFeatured: boolean;
  featuredUntil: string | null;
  publishedAt: string | null;
  createdAt: string;
  property: {
    id: string;
    propertyType: PropertyType;
    title: string;
    description: string;
    address: string;
    ward: string;
    district: string;
    city: string;
    latitude: number;
    longitude: number;
    areaM2: number;
    bedrooms: number | null;
    bathrooms: number | null;
    floors: number | null;
    direction: Direction | null;
    yearBuilt: number | null;
    legalStatus: string | null;
    amenities: unknown;
    projectName: string | null;
    media: ListingMediaData[];
  };
  seller: {
    id: string;
    fullName: string;
    phone: string;
  };
  agent: {
    id: string;
    userId: string;
    agency: string | null;
  } | null;
}

export interface ListingMediaData {
  id: string;
  url: string;
  type: string;
  order: number;
  caption: string | null;
}

/** Returned by search / findByStatus — listing summary with thumbnail */
export interface ListingSearchItem {
  id: string;
  status: ListingStatus;
  transactionType: TransactionType;
  priceVND: string;
  pricePerM2: number | null;
  isFeatured: boolean;
  featuredUntil: string | null;
  viewCount: number;
  publishedAt: string | null;
  property: {
    id: string;
    propertyType: PropertyType;
    title: string;
    address: string;
    district: string;
    city: string;
    latitude: number;
    longitude: number;
    areaM2: number;
    bedrooms: number | null;
    bathrooms: number | null;
    thumbnail: string | null;
    media: ListingMediaData[];
  };
  seller: {
    id: string;
    fullName: string;
  };
}

/** Returned by findBySellerId — compact listing for seller dashboard */
export interface ListingSellerItem {
  id: string;
  status: ListingStatus;
  transactionType: TransactionType;
  priceVND: string;
  isFeatured: boolean;
  featuredUntil: string | null;
  property: {
    id: string;
    title: string;
    district: string;
    city: string;
    areaM2: number;
    thumbnail: string | null;
    media: ListingMediaData[];
  };
}
