import { ContactList, MarketingChannel } from "@prisma/client";

export type ContactListWithCount = ContactList & {
  _count: { memberships: number };
};

export type ContactListWithActiveCount = ContactList & {
  activeContactsCount: number;
};

export interface FindAllPaginatedByUserIdParams {
  userId: string;
  page: number;
  pageSize: number;
  search?: string;
  marketingChannel?: MarketingChannel;
  createdFrom?: Date;
  createdTo?: Date;
}

export interface FindAllPaginatedByUserIdResult {
  items: ContactListWithActiveCount[];
  total: number;
}

export interface ContactListsRepository {
  findAllByUserId(userId: string): Promise<ContactListWithCount[]>;
  findAllPaginatedByUserId(params: FindAllPaginatedByUserIdParams): Promise<FindAllPaginatedByUserIdResult>;
  findById(id: string): Promise<ContactList | null>;
  findByUserIdAndName(userId: string, name: string): Promise<ContactList | null>;
  create(data: {
    name: string;
    description?: string;
    userId: string;
    marketingChannel?: MarketingChannel;
  }): Promise<ContactList>;
  delete(id: string): Promise<void>;
  addContactsToLists(contactIds: string[], listIds: string[]): Promise<void>;
  removeContactFromList(contactId: string, listId: string): Promise<void>;
}
