// src/modules/contact/contacts.interface.ts

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

export interface IContactPhone {
  countryCode: number;
  number: number;
  isPrimary?: boolean;
}
export interface QueryFilter {
  search?: string;
  company?: string;
  companyId?: string;
  source?: string;
  createdBy?: string;
  ids?: string | string[];
  [key: string]: unknown;
}

export interface IContactBase {
  firstName: string;
  lastName: string;
  email: string;
  company: Types.ObjectId;
  phone?: IContactPhone[];
  addressLine1: string;
  addressLine2: string;
  country: Types.ObjectId | string;
  state: Types.ObjectId | string;
  city: Types.ObjectId | string;
  pinCode: number;
  source: Types.ObjectId | string;
  companyName: string;
  position: string;
  workPhoneNumber: string;
  workEmail: string;
  companyId: Types.ObjectId | string;
  shortlisted?: Types.ObjectId[];
  removed?: Types.ObjectId[];
  customFields?: {
    [key: string]: string;
  };
}

export interface IContact extends IContactBase, AuditFields {}

export interface IContactDoc extends IContact, Document {}

export interface IContactModel extends IPaginateModel<IContactDoc> {}

export type NewCreatedContact = IContactBase &
  Partial<Pick<AuditFields, 'createdBy' | 'updatedBy'>>;

/** Params for bulk/import contact upsert by primary phone */
export interface FindOrCreateByPhoneParams {
  firstName: string;
  lastName?: string;
  phone: string;
  secondaryPhone?: string;
  email?: string;
  secondaryEmail?: string;
  company: Types.ObjectId;
  createdBy?: Types.ObjectId;
  source?: Types.ObjectId | string;
}

export type UpdateContactBody = Partial<IContact>;
