// ✅ Nouveau modèle pour l'envoi d'email avec CC/CCI
export interface EmailEnvoiRequest {
    destinataire: string
    cc?: string[]
    cci?: string[]
    sujet: string
    corps_html: string
    document_ids?: string[]
    type_document?: TypeDocument
}

// ✅ Mise à jour du SignatureRequest pour correspondre au backend
// export interface SignatureRequest {
//     doc_id: string
//     type_doc: TypeDocument
//     email_signataire: string
//     nom_signataire: string
// }

export interface SignatureRequest {
    sage_document_id: string
    sage_document_type: TypeDocument
    signer_email: string
    signer_name: string
    document_name: string
}

export interface EmailBatchRequest {
    destinataires: string[]
    sujet: string
    corps_html: string
    document_ids?: string[]
    type_document?: TypeDocument
}

// ... (reste des types inchangés)






export interface LigneDocument {
    article: string
    designation: string
    quantite: number
    prix_unitaire: number
    montant_ht: number
}

export enum TypeDocument {
    DEVIS = 0,
    BON_LIVRAISON = 1,
    BON_RETOUR = 2,
    COMMANDE = 3,
    PREPARATION = 4,
    FACTURE = 5,
}

export enum StatutSignature {
    EN_ATTENTE = "EN_ATTENTE",
    ENVOYE = "ENVOYE",
    SIGNE = "SIGNE",
    REFUSE = "REFUSE",
    EXPIRE = "EXPIRE",
}

export enum StatutEmail {
    EN_ATTENTE = "EN_ATTENTE",
    EN_COURS = "EN_COURS",
    ENVOYE = "ENVOYE",
    OUVERT = "OUVERT",
    ERREUR = "ERREUR",
    BOUNCE = "BOUNCE",
}

export interface EmailLog {
    id: string
    destinataire: string
    sujet: string
    statut: StatutEmail
    date_creation: string
    date_envoi?: string
    document_ids?: string
    nb_tentatives: number
    derniere_erreur?: string
}

export interface CacheInfo {
    clients: {
        count: number
        last_update: string | null
        age_minutes: number | null
    }
    articles: {
        count: number
        last_update: string | null
        age_minutes: number | null
    }
    ttl_minutes: number
}

export interface BaremeRemiseResponse {
    client_id: string
    remise_max_autorisee: number
    remise_demandee: number
    autorisee: boolean
    message: string
}

export interface TemplateEmail {
    id?: string
    nom: string
    sujet: string
    corps_html: string
    variables_disponibles: string[]
}

export interface TemplatePreview {
    template_id: string
    document_id: string
    sujet: string
    corps_html: string
    variables_utilisees: Record<string, string>
}

export interface TransformationResponse {
    success: boolean
    document_source: string
    document_cible: string
    nb_lignes: number
}



export interface responseDefault {
    success: boolean;
    message: string;
}




export interface pdfInterface {
    type_doc: number;
    numero: string;
}



export enum SageDocumentType {
  DEVIS = 0,
  BON_COMMANDE = 10,
  PREPARATION = 20,
  BON_LIVRAISON = 30,
  BON_RETOUR = 40,
  BON_AVOIR = 50,
  FACTURE = 60,
}

export interface StatusResponse {
  success: boolean;
  document_id: string;
  type_document_code: SageDocumentType;
  statut_ancien: number;
  statut_nouveau: number;
  message: string;
}

export interface StatusRequest {
    numero: string
    status: number
}



export enum StatusDocumentType {
  DEVIS,
  BON_COMMANDE,
  PREPARATION,
  BON_LIVRAISON,
  BON_RETOUR,
  BON_AVOIR,
  FACTURE,
}



export interface UniversignType {
    id: string,
    transaction_id: string;
    sage_document_id: string;
    sage_document_type: StatusDocumentType;
    universign_status: string;
    local_status: string;
    local_status_label: string;
    signer_url: string;
    document_url: string;
    created_at: string;
    sent_at: string;
    signed_at: string;
    last_synced_at: string;
    needs_sync: boolean;
    signers: Signer[];
}


export interface Signer {
    email: string,
    name: string;
    status: string;
    signed_at: string;
}

