import { AttachmentProps, AuthorClientProps } from './legal-agreements.types';

// Define pagination link structure
export interface PaginationLink {
  url: string | null;
  label: string;
  active: boolean;
}

export interface DocumentItemProps {
  id: number;
  client_id: number;
  doc_type: string;
  name: string;
  description: string;
  type: string;
  upload_as: string;
  result_id: number;
  location: string;
  id_location: string;
  unique_account_id: number;
  document_sequence_id: string;
  date_created: string;
  manage_result_tags: string;
  is_active: string;
  doc_flag: number;
  document_flag: number;
  insert_flag: number;
  updated_at: string;
  author: string;
  flag: string;
}

export interface SegmentConditions {
  combinator: 'AND' | 'OR'; // based on typical values
  not: number;
  count_repeat: number;
  relation: string;
  rules: SegmentRule[];
}

export interface SegmentRule {
  field: string;
  count_repeat: number;
  relation: string;
  operator: '=' | '!=' | '>' | '<' | '>=' | '<=' | 'IN' | 'NOT IN'; // guessing common ones
  value: string;
}

export interface ClientAttributes {
  Id: string;
  FirstName: string;
  MiddleName: string;
  LastName: string;
  Email: string;
}

export interface ClientSegment {
  id: number;
  type: string;
  name: string;
  description: string;
  conditions: SegmentConditions;
  is_active: boolean;
  is_archive: boolean;
  clients_count: number;
  negative_items_count: number;
  usage_count: number;
  created_at: string; // ISO date string
  updated_at: string; // ISO date string
}

export interface ClientProps {
  id: number;
  salesforce_id: number;
  ssn: number;
  email: string;
  mobile_phone: string;
  joint_customer_sf_id: string;
  client_key: string;
  attributes: ClientAttributes;
  segments: ClientSegment;
}

export interface DocumentDataProps {
  type: string;
  subtype: string;
  attachment: AttachmentProps;
  client: ClientProps;
  author: AuthorClientProps;
}

export interface DocumentsResultDataProps {
  status: string;
  message: string;
  code: number;
  results: {
    current_page: number;
    data: DocumentDataProps[];
    first_page_url: string;
    from: number;
    last_page: number;
    last_page_url: string;
    links: PaginationLink[];
    next_page_url: string;
    path: string;
    per_page: number;
    prev_page_url: string | null;
    to: number;
    total: number;
  };
}

export interface DeleteDocumentResponseTypes {
  status: string;
  message: string;
  code: number;
}
