import { Document, Types } from 'mongoose';
import { IPaginateModel } from '@/shared/interfaces/model.interface';
import { AuditFields } from '@/shared/types/common';
import { LeadInterestType } from '@/shared/constants/enum.constant';
import { IProperty } from '../individualProperties/individualProperties.interface';
import { IContact } from '../contacts/contacts.interface';

// Enum for Lead Routing Type
export enum LeadRoutingType {
  USER = 'user',
  TEAM = 'team',
  ROUNDROBIN = 'round-robin',
}

// Contact Number Type
export interface IContactNumber {
  dialCode: number;
  number: number;
}

// Base WebSiteBuilder Interface
export interface IWebSiteBuilderBase {
  template: string;
  leadRoutingType: LeadRoutingType;
  userId?: Types.ObjectId; // Only if leadRoutingType is 'user'
  teamId?: Types.ObjectId; // Only if leadRoutingType is 'team'
  companyName: string;
  companyLogo: string;
  contactNumber: IContactNumber;
  whatsappNumber: IContactNumber;
  heroBannerTitle: string;
  heroBannerDesc: string;
  bannerImg: string;
  aboutTitle: string;
  aboutDesc: string;
  aboutImg: string;
  serviceTitle: string;
  serviceDesc: string;
  subdomainName: string;
  company: Types.ObjectId;
  leadNotifyAdmin: boolean;
  isPublished: boolean;
  findPropertyTitle: string;
  findPropertyDesc: string;
  sellPropertyTitle: string;
  sellPropertyDesc: string;
  rentPropertyTitle: string;
  rentPropertyDesc: string;
}

// Full WebSiteBuilder Interface with Audit Fields
export interface IWebSiteBuilder extends IWebSiteBuilderBase, AuditFields {}

// Mongoose Document
export interface IWebSiteBuilderDoc extends IWebSiteBuilder, Document {}

// Mongoose Model with Pagination and Custom Statics
export interface IWebSiteBuilderModel
  extends IPaginateModel<IWebSiteBuilderDoc> {}

// Types for Creating and Updating
export type NewWebSiteBuilder = IWebSiteBuilderBase &
  Partial<Pick<AuditFields, 'createdAt' | 'updatedAt'>>;

export type UpdateWebSiteBuilder = Partial<IWebSiteBuilderDoc>;

//Types for response of isWebsite is created or not
export type IsWebsiteCreated = {
  isWebsiteCreated: boolean;
};

export interface QueryFilter {
  search?: string;
  company?: string;
  [key: string]: unknown;
}

export interface IOptions {
  label: string;
  value: string;
}

export interface IPropertyFilter {
  category: IOptions[];
  subcategory: IOptions[];
  configuration: IOptions[];
  buyingType: IOptions[];
  propertyAge: IOptions[];
  avgPrice: IOptions[];
  SqFtOptions: IOptions[];
}

export interface IInquiryBody {
  name: string;
  email: string;
  phone: number;
  countryCode: number;
  listingId: string;
  message: string;
}

export interface IMakanifyLead extends IInquiryBody {
  company: Types.ObjectId;
  listing: IProperty & { companyId: { id: Types.ObjectId } };
  interestType: LeadInterestType;
  project: Types.ObjectId;
  unit: Types.ObjectId;
  source: Types.ObjectId;
  contactId: Types.ObjectId;
  contactInfo: IContact & { id: Types.ObjectId };
  leadStageId: Types.ObjectId;
  assignedTo: Types.ObjectId;
  assignedBy: Types.ObjectId;
}

