import { Document, Types } from 'mongoose';
import { IPaginateModel } from '@/shared/interfaces/model.interface';
import { AuditFields } from '@/shared/types/common';

export interface IBudgetRange {
  min: number;
  max: number;
}

export interface ICampaignBase {
  name: string;
  description?: string;
  trackingLink?: string;
  type: 'project' | 'property';
  project?:  Types.ObjectId;
  property?:  Types.ObjectId;

  targetedCity?: Types.ObjectId[];
  targetedAreas?: Types.ObjectId[];

  budgetRange?: IBudgetRange;

  category?: Types.ObjectId;
  subCategories?: Types.ObjectId[];

  leadIds?:  Types.ObjectId[];

  channel?: ('whatsapp' | 'email' | 'sms')[];
  whatsappTemplates?: string;
  emailTemplates?: string;
  smsTemplates?: string;

  team?: Types.ObjectId;

  targetStrategy?: 'all' | 'spread';
  sendToAll?: boolean;
  spreadDuration?: 2 | 5 | 7;

  launchTime?: 'immediate' | 'schedule';
  scheduleTime?: Date;
  company?: Types.ObjectId;
  status?: 'running' | 'draft' | 'pending' | 'scheduled';
}

export interface ICampaign extends ICampaignBase, AuditFields {}

export interface ICampaignDoc extends ICampaign, Document {}

export interface ICampaignModel extends IPaginateModel<ICampaignDoc> {}
export type NewCreatedCampaign = ICampaignBase & Partial<Pick<AuditFields, 'createdBy' | 'updatedBy'>>;
export type UpdateCampaignBody = Partial<ICampaign>;


export type PopulatedCampaign = {
  _id: Types.ObjectId;
  createdBy: { firstName: string; lastName: string, email: string };
  company: { name: string };
  name: string;
  spreadDuration: number;
  status: string;
};
