diff --git a/src/pages/POS/Clients/BillingRequestDetailModal.vue b/src/pages/POS/Clients/BillingRequestDetailModal.vue index 941c5b1..cb553e4 100644 --- a/src/pages/POS/Clients/BillingRequestDetailModal.vue +++ b/src/pages/POS/Clients/BillingRequestDetailModal.vue @@ -161,7 +161,6 @@ const sendInvoiceByWhatsapp = async () => { phone_number: request.client.phone, invoice_number: request.sale?.invoice_number || `SOL-${request.id}`, pdf_url: request.invoice_pdf_url, - xml_url: request.invoice_xml_url || null, customer_name: request.client.name }); diff --git a/src/services/whatsappService.js b/src/services/whatsappService.js index 51a7349..ec80290 100644 --- a/src/services/whatsappService.js +++ b/src/services/whatsappService.js @@ -1,4 +1,6 @@ -import { api, apiURL } from '@Services/Api'; +import { apiURL, token } from '@Services/Api'; +import { page } from '@Services/Page'; +import axios from 'axios'; /** * Servicio para enviar mensajes por WhatsApp @@ -9,15 +11,25 @@ const whatsappService = { * @param {Object} data - Datos de la factura * @returns {Promise} */ - async sendInvoice({ phone_number, invoice_number, pdf_url, xml_url, customer_name }) { + async sendInvoice({ phone_number, invoice_number, pdf_url, xml_url = null, customer_name }) { try { - const { data } = await window.axios.post(apiURL('whatsapp/send-invoice'), { - phone_number, - invoice_number, - pdf_url, - xml_url, - customer_name - }); + const { data } = await axios.post( + apiURL('whatsapp/send-invoice'), + { + phone_number, + invoice_number, + pdf_url, + xml_url, + customer_name + }, + { + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': `Bearer ${token.value}` + } + } + ); return data; } catch (error) { const errorData = error.response?.data?.data || error.response?.data; @@ -33,10 +45,20 @@ const whatsappService = { */ async sendMessage({ phone_number, message }) { try { - const { data } = await window.axios.post(apiURL('whatsapp/send-message'), { - phone_number, - message - }); + const { data } = await axios.post( + apiURL('whatsapp/send-message'), + { + phone_number, + message + }, + { + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': `Bearer ${token.value}` + } + } + ); return data; } catch (error) { const errorData = error.response?.data?.data || error.response?.data;