import { pdfInterface } from "@/types/sageTypes"

export const API_CONFIG = {
    baseURL: import.meta.env.VITE_API_URL,
    timeout: 30000,
    headers: {
        'Content-Type': 'application/json',
    },
}

export const API_ENDPOINTS = {

    // ========= Authentification ==========
    auth: '/auth/me',
    login: '/auth/login',
    logout: '/auth/logout',
    refreshToken: '/auth/refresh',
    forgotPassword: '/auth/forgot-password',
    resetPassword: '/auth/reset-password',

    // entreprise
    searchEntreprise : (query: string) => `/entreprises/search?q=${query}`,

    // client
    clients: '/clients',
    clientById: (numero: string) => `/clients/${numero}`,


    // societe
    societe: '/societe/info',

    // gateways
    gateways: '/sage-gateways',
    gatewaysById: (id: string) => `/sage-gateways/${id}`,

     // contacts
    contactsClient:  (numero: string) => `/tiers/${numero}/contacts`,
    contactId: (numero: string, contact_numero: number) => `/tiers/${numero}/contacts/${contact_numero}`,

    // commercial
    commercials: '/collaborateurs',
    commercialsById: (numero: string) => `/collaborateurs/${numero}`,

    // Articles
    articles: '/articles',
    articleById: (reference: string) => `/articles/${reference}`,

    // stock
    addStock: '/stock/entree',

    // devis
    devis: '/devis',
    devisById: (id: string) => `/devis/${id}`,
    devisPDF: (id: string) => `/devis/${id}/pdf`,
    devisEnvoyer: (id: string) => `/devis/${id}/envoyer`,
    devisSigner: (id: string) => `/devis/${id}/signer`,
    devisStatut: (id: string) => `/devis/${id}/statut`,
    devisContact: (id: string) => `/devis/${id}/contact`,

    // fournisseur
    fournisseurs: '/fournisseurs',
    fournisseursById: (numero: string) => `/fournisseurs/${numero}`,

    // famille
    familles: '/familles',
    familleId: (code: string) => `/familles/${code}`,

    // uniersign 
    downloadSignedDocument: (transactionId: string) => `/universign/transactions/${transactionId}/document/download`,
    getTransaction: (transactionId: string) => `/universign/transactions/${transactionId}`,


    // Bon de Livraison
    bl: '/livraisons',
    blById: (id: string) => `/livraisons/${id}`,

    // client
    avoirs: '/avoirs',
    avoirsById: (numero: string) => `/avoirs/${numero}`,

     // reglements
    reglement: "/reglements",
    reglementById: (id: string) => `/reglements/facture/${id}`,
    reglerFacture : '/reglements/multiple',
    mode: '/reglements/modes',
    devises: '/devises',
    tresorerie: '/journaux/tresorerie',
    compte_generaux: '/comptes-generaux',
    taux: '/tva/taux',
    encaissement : '/parametres/encaissement',

    // US-A2 - Workflow
    devisToFacture: (id: string) => `/workflow/devis/${id}/to-facture`,
    devisToCommande: (id: string) => `/workflow/devis/${id}/to-commande`,
    commandeToBL: (id: string) => `/workflow/commande/${id}/to-livraison`,
    commandeToFacture: (id: string) => `/workflow/commande/${id}/to-facture`,
    blToFacture: (id: string) => `/workflow/livraison/${id}/to-facture`,
    commandes: '/commandes',
    commandeById: (id: string) => `/commandes/${id}`,

    // factures
    factures: '/factures',
    factureValider: (numero_facture: string) => `/factures/${numero_facture}/valider`,
    factureById: (id: string) => `/factures/${id}`,

    // US-A3 - Signature
    signatureSend: '/signature/universign/send',
    signatureStatus: '/signature/universign/status',

    // US-A4/A8 - Emails
    emailBatch: '/emails/send-batch',
    emailLogs: '/emails/logs',
    emailLogsExport: '/emails/logs/export',

    // US-A5 - Remises
    devisValiderRemise: '/devis/valider-remise',

    // US-A6 - Relance Devis
    devisRelancerSignature: (id: string) => `/devis/${id}/relancer-signature`,

    // US-A7 - Relance Facture
    factureRelancer: (id: string) => `/factures/${id}/relancer`,

    // US-A10 - Templates
    templates: '/templates/emails',
    templateById: (id: string) => `/templates/emails/${id}`,
    templatePreview: '/templates/emails/preview',

    // Admin
    cacheInfo: '/admin/cache/info',
    cacheRefresh: '/admin/cache/refresh',
    queueStatus: '/admin/queue/status',
    health: '/health',
}

