import type { ProjectDevelopmentStatus } from '@prisma/client';
import type { ProjectDevelopmentEntity } from '../entities/project-development.entity';

export const PROJECT_REPOSITORY = Symbol('PROJECT_REPOSITORY');

export interface ProjectSearchParams {
  query?: string;
  status?: ProjectDevelopmentStatus;
  city?: string;
  district?: string;
  developer?: string;
  isVerified?: boolean;
  /** When set, restrict results to projects owned by this user id. */
  ownerId?: string;
  page?: number;
  limit?: number;
}

export interface PaginatedResult<T> {
  data: T[];
  total: number;
  page: number;
  limit: number;
  totalPages: number;
}

export interface ProjectListItem {
  id: string;
  name: string;
  slug: string;
  developer: string;
  developerLogo: string | null;
  status: ProjectDevelopmentStatus;
  totalUnits: number;
  completedUnits: number;
  address: string;
  ward: string;
  district: string;
  city: string;
  minPrice: bigint | null;
  maxPrice: bigint | null;
  totalArea: number | null;
  tags: string[];
  suitableFor: string[];
  whyThisLocation: string | null;
  isVerified: boolean;
  ownerId: string | null;
  latitude: number;
  longitude: number;
  propertyCount: number;
  createdAt: Date;
}

export interface ProjectDetailData extends ProjectListItem {
  startDate: Date | null;
  completionDate: Date | null;
  description: string | null;
  amenities: Record<string, unknown> | null;
  masterPlanUrl: string | null;
  pricePerM2Range: Record<string, unknown> | null;
  buildingCount: number | null;
  floorCount: number | null;
  unitTypes: Record<string, unknown> | null;
  media: Record<string, unknown>[] | null;
  documents: Record<string, unknown>[] | null;
  updatedAt: Date;
}

export interface IProjectRepository {
  findById(id: string): Promise<ProjectDevelopmentEntity | null>;
  findBySlug(slug: string): Promise<ProjectDevelopmentEntity | null>;
  findDetailBySlug(slug: string): Promise<ProjectDetailData | null>;
  findDetailById(id: string): Promise<ProjectDetailData | null>;
  save(entity: ProjectDevelopmentEntity): Promise<void>;
  update(entity: ProjectDevelopmentEntity): Promise<void>;
  delete(id: string): Promise<void>;
  search(params: ProjectSearchParams): Promise<PaginatedResult<ProjectListItem>>;
}
