PageSourceSearch

https://repuestos-d6c3d.firebaseapp.com/_nuxt/COuDId2h.js

js repuestos-d6c3d.firebaseapp.com collected 2026-10-03 08:14:13 UTC 15,018 bytes, 1 lines download raw bytes

1import{_ as M}from"./BsqTxom4.js";import{_ as H}from"./WWy_r-EY.js";import{a9 as O,u as U,r as p,l as q,q as G,c as n,b as e,e as u,f as P,v as J,z as I,d as D,F as A,x as L,t as a,p as N,a as k,i as E,j as S,o as d}from"#entry";import{u as K}from"./DHwOP2XV.js";const Q={class:"bg-white rounded-xl shadow-lg p-6 mb-8"},W={class:"grid grid-cols-1 md:grid-cols-4 gap-4"},X={class:"bg-white rounded-xl shadow-lg overflow-hidden"},Y={class:"overflow-x-auto"},Z={class:"w-full"},ee={class:"divide-y divide-gray-200"},te={class:"py-4 px-6"},oe={class:"text-sm font-medium text-gray-900"},se={key:0,class:"text-xs text-gray-500"},ae={class:"py-4 px-6"},le={class:"text-sm font-medium text-gray-900"},ne={key:0,class:"text-xs text-gray-500"},de={class:"py-4 px-6"},re={class:"text-sm font-medium text-gray-900"},ie={key:0,class:"text-xs text-gray-500"},ue={class:"py-4 px-6"},ce={class:"py-4 px-6"},pe={key:0,class:"text-green-600 font-medium inline-flex items-center gap-1"},me={key:1,class:"text-red-600"},ge={key:2,class:"text-xs text-orange-600 mt-1"},xe={class:"inline-flex items-center gap-1"},ve={class:"py-4 px-6 text-sm text-gray-500"},ye={class:"py-4 px-6"},fe={class:"flex space-x-2"},be=["onClick"],_e={key:0,class:"text-center py-12"},he={key:0,class:"fixed inset-0 bg-black bg-opacity-60 flex items-center justify-center z-50 p-4"},we={class:"bg-white rounded-2xl max-w-4xl w-full max-h-[90vh] overflow-hidden shadow-2xl"},Pe={class:"bg-gradient-to-r from-blue-600 to-blue-700 px-8 py-6"},ke={class:"flex items-center justify-between"},Ee={class:"text-blue-100 mt-1"},Ce={class:"p-8 overflow-y-auto max-h-[calc(90vh-160px)]"},Ie={class:"mb-6 flex space-x-3"},Ve=["disabled"],ze={key:0,class:"animate-spin h-5 w-5",fill:"none",viewBox:"0 0 24 24"},Me={class:"mb-6"},De={class:"grid grid-cols-2 gap-4 bg-gray-50 p-4 rounded-lg"},Ae={class:"font-medium"},Le={key:0},Ne={class:"font-medium"},Se={class:"mb-6"},je={class:"space-y-3"},Fe={class:"flex-1"},Re={class:"font-medium"},$e={class:"text-sm text-gray-600"},Te={class:"text-sm text-gray-600"},Be={class:"font-bold text-lg"},He={class:"mt-4 text-right"},Oe={class:"text-2xl font-bold text-blue-600"},Ue={class:"mb-6"},qe={class:"grid grid-cols-2 gap-4 bg-gray-50 p-4 rounded-lg"},Ge={class:"font-medium mt-1"},Je={key:0,class:"text-green-600 inline-flex items-center gap-1"},Ke={key:1,class:"text-red-600"},Qe={key:0},We={class:"font-medium font-mono text-sm"},Xe={key:1},Ye={class:"font-medium"},Ze={class:"mb-6"},et={class:"flex space-x-3"},tt=["disabled"],ot={class:"text-xs text-gray-500 mt-2"},st={class:"inline-flex items-center gap-2"},at={key:0,class:"mb-6"},lt={key:0,class:"bg-gray-900 text-green-400 p-4 rounded-lg overflow-x-auto"},nt={class:"text-xs"},dt={key:1,class:"bg-gray-100 p-4 rounded-lg text-center text-gray-600"},rt={key:1,class:"mb-6"},it={class:"bg-gray-900 text-blue-400 p-4 rounded-lg overflow-x-auto"},ut={class:"text-xs"},vt=O({__name:"ventas",setup(ct){U({title:"Gestión de Ventas - AutoPiezas360",meta:[{name:"robots",content:"noindex, nofollow"}]});const g=p([]),l=p(null),x=p(""),f=p(""),v=p(""),b=p(!1),h=p(!1),r=p(""),y=p(!1),w=p(null),V=q(()=>g.value.filter(s=>{const t=!x.value||s.email.toLowerCase().includes(x.value.toLowerCase())||s.id.toLowerCase().includes(x.value.toLowerCase())||s.mercadopagoPaymentId&&s.mercadopagoPaymentId.includes(x.value),c=!f.value||s.estado===f.value,o=!v.value||v.value==="true"&&s.isPaid||v.value==="false"&&!s.isPaid;return t&&c&&o})),j=s=>s?(s instanceof Date?s:new Date(s)).toLocaleDateString("es-CL",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"N/A",z=s=>({approved:"bg-green-100 text-green-800",pending:"bg-yellow-100 text-yellow-800",in_process:"bg-blue-100 text-blue-800",rejected:"bg-red-100 text-red-800",refunded:"bg-purple-100 text-purple-800",cancelled:"bg-gray-100 text-gray-800"})[s]||"bg-gray-100 text-gray-800",C=s=>({approved:"Aprobado",pending:"Pendiente",in_process:"En Proceso",rejected:"Rechazado",refunded:"Reembolsado",cancelled:"Cancelado"})[s]||s,F=()=>{x.value="",f.value="",v.value=""},R=s=>{l.value={...s},r.value=s.estado,y.value=!1,w.value=null},$=async s=>{if(!s.mercadopagoPaymentId||!s.mercadopagoPreferenceId){alert("Esta venta no tiene información de MercadoPago");return}try{b.value=!0;const{$firebaseFunctions:t}=S(),{httpsCallable:c}=await M(async()=>{const{httpsCallable:m}=await import("#entry").then(_=>_.aE);return{httpsCallable:m}},[],import.meta.url),i=await c(t,"verifyPayment")({paymentId:s.mercadopagoPaymentId,preferenceId:s.mercadopagoPreferenceId});if(w.value=i.data,i.data.order){l.value={...i.data.order},r.value=i.data.order.estado;const m=g.value.findIndex(_=>_.id===s.id);m!==-1&&(g.value[m]={...i.data.order})}alert("Pago verificado en MercadoPago. Los datos se han actualizado.")}catch(t){console.error("Error verificando pago:",t),alert("Error al verificar el pago: "+(t.message||"Intenta nuevamente"))}finally{b.value=!1}},T=async s=>{if(confirm(`¿Estás seguro de cambiar el estado a "${C(r.value)}"?`))try{h.value=!0;const{$firebaseFunctions:t}=S(),{httpsCallable:c}=await M(async()=>{const{httpsCallable:m}=await import("#entry").then(_=>_.aE);return{httpsCallable:m}},[],import.meta.url);await c(t,"updateVentaEstado")({ventaId:s,nuevoEstado:r.value}),l.value&&(l.value.estado=r.value,r.value==="approved"&&(l.value.isPaid=!0));const i=g.value.findIndex(m=>m.id===s);i!==-1&&(g.value[i].estado=r.value,r.value==="approved"&&(g.value[i].isPaid=!0)),alert("Estado actualizado correctamente"),r.value==="approved"&&alert("Se ha enviado un email de confirmación al cliente")}catch(t){console.error("Error actualizando estado:",t),alert("Error al actualizar el estado: "+(t.message||"Intenta nuevamente"))}finally{h.value=!1}},B=async()=>{try{const{obtenerTodasVentas:s}=K();g.value=await s()}catch(s){console.error("Error cargando ventas:",s)}};return G(()=>{B()}),(s,t)=>{const c=H;
1return d(),n("div",null,[t[36]||(t[36]=e("div",{class:"mb-8"},[e("div",{class:"flex justify-between items-center"},[e("div",null,[e("h1",{class:"text-3xl font-bold text-gray-900"},"Gestión de Ventas - MercadoPago"),e("p",{class:"text-gray-600 mt-2"},"Administra las ventas automáticas procesadas por MercadoPago")])])],-1)),e("div",Q,[e("div",W,[e("div",null,[t[8]||(t[8]=e("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"Buscar",-1)),P(e("input",{"onUpdate:modelValue":t[0]||(t[0]=o=>x.value=o),type:"text",placeholder:"Email, ID de pago...",class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500"},null,512),[[J,x.value]])]),e("div",null,[t[10]||(t[10]=e("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"Estado",-1)),P(e("select",{"onUpdate:modelValue":t[1]||(t[1]=o=>f.value=o),class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500"},[...t[9]||(t[9]=[D('<option value="">Todos</option><option value="pending">Pendiente</option><option value="approved">Aprobado</option><option value="rejected">Rechazado</option><option value="in_process">En Proceso</option><option value="refunded">Reembolsado</option><option value="cancelled">Cancelado</option>',7)])],512),[[I,f.value]])]),e("div",null,[t[12]||(t[12]=e("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"Pagado",-1)),P(e("select",{"onUpdate:modelValue":t[2]||(t[2]=o=>v.value=o),class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500"},[...t[11]||(t[11]=[e("option",{value:""},"Todos",-1),e("option",{value:"true"},"Sí",-1),e("option",{value:"false"},"No",-1)])],512),[[I,v.value]])]),e("div",{class:"flex items-end"},[e("button",{onClick:F,class:"w-full px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50"}," Limpiar ")])])]),e("div",X,[e("div",Y,[e("table",Z,[t[15]||(t[15]=e("thead",{class:"bg-gray-50"},[e("tr",null,[e("th",{class:"text-left py-4 px-6 font-medium text-gray-700"},"ID"),e("th",{class:"text-left py-4 px-6 font-medium text-gray-700"},"Cliente"),e("th",{class:"text-left py-4 px-6 font-medium text-gray-700"},"Total"),e("th",{class:"text-left py-4 px-6 font-medium text-gray-700"},"Estado"),e("th",{class:"text-left py-4 px-6 font-medium text-gray-700"},"Pagado"),e("th",{class:"text-left py-4 px-6 font-medium text-gray-700"},"Fecha"),e("th",{class:"text-left py-4 px-6 font-medium text-gray-700"},"Acciones")])],-1)),e("tbody",ee,[(d(!0),n(A,null,L(V.value,o=>(d(),n("tr",{key:o.id,class:"hover:bg-gray-50"},[e("td",te,[e("div",oe,a(o.id.substring(0,8)),1),o.mercadopagoPaymentId?(d(),n("div",se," MP: "+a(o.mercadopagoPaymentId),1)):u("",!0)]),e("td",ae,[e("div",le,a(o.email),1),o.nombre&&o.apellido?(d(),n("div",ne,a(o.nombre)+" "+a(o.apellido),1)):u("",!0)]),e("td",de,[e("div",re,"$"+a(o.total.toLocaleString()),1),o.items?(d(),n("div",ie,a(o.items.length)+" producto(s) ",1)):u("",!0)]),e("td",ue,[e("span",{class:N([z(o.estado),"px-2 py-1 text-xs font-medium rounded-full"])},a(C(o.estado)),3)]),e("td",ce,[o.isPaid?(d(),n("span",pe,[k(c,{name:"check-circle",size:"sm"}),t[13]||(t[13]=E(" Sí ",-1))])):(d(),n("span",me,"✗ No")),o.isPartialPayment?(d(),n("div",ge,[e("span",xe,[k(c,{name:"exclamation-triangle",size:"sm"}),t[14]||(t[14]=E(" Pago parcial ",-1))])])):u("",!0)]),e("td",ve,a(j(o.createdAt)),1),e("td",ye,[e("div",fe,[e("button",{onClick:i=>R(o),class:"text-blue-600 hover:text-blue-800 text-sm font-medium"}," Ver Detalles ",8,be)])])]))),128))])]),V.value.length===0?(d(),n("div",_e,[...t[16]||(t[16]=[e("svg",{class:"w-16 h-16 text-gray-400 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"})],-1),e("h3",{class:"text-lg font-medium text-gray-900 mb-2"},"No hay ventas",-1),e("p",{class:"text-gray-500"},"No se encontraron ventas con los filtros seleccionados",-1)])])):u("",!0)])]),l.value?(d(),n("div",he,[e("div",we,[e("div",Pe,[e("div",ke,[e("div",null,[t[17]||(t[17]=e("h2",{class:"text-2xl font-bold text-white"},"Detalles de la Venta",-1)),e("p",Ee,"ID: "+a(l.value.id),1)]),e("button",{onClick:t[3]||(t[3]=o=>l.value=null),class:"w-10 h-10 bg-white bg-opacity-20 hover:bg-opacity-30 rounded-xl flex items-center justify-center"}
1,[...t[18]||(t[18]=[e("svg",{class:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])])])]),e("div",Ce,[e("div",Ie,[e("button",{onClick:t[4]||(t[4]=o=>$(l.value)),disabled:b.value||!l.value.mercadopagoPaymentId,class:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg font-medium disabled:bg-gray-400 disabled:cursor-not-allowed flex items-center space-x-2"},[b.value?(d(),n("svg",ze,[...t[19]||(t[19]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):u("",!0),e("span",null,a(b.value?"Verificando...":"Verificar en MercadoPago"),1)],8,Ve),e("button",{onClick:t[5]||(t[5]=o=>y.value=!y.value),class:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg font-medium"},a(y.value?"Ocultar":"Mostrar")+" Datos Raw ",1)]),e("div",Me,[t[22]||(t[22]=e("h3",{class:"text-lg font-semibold mb-3 text-gray-800"},"Información del Cliente",-1)),e("div",De,[e("div",null,[t[20]||(t[20]=e("p",{class:"text-sm text-gray-600"},"Email",-1)),e("p",Ae,a(l.value.email),1)]),l.value.nombre&&l.value.a
1pellido?(d(),n("div",Le,[t[21]||(t[21]=e("p",{class:"text-sm text-gray-600"},"Nombre",-1)),e("p",Ne,a(l.value.nombre)+" "+a(l.value.apellido),1)])):u("",!0)])]),e("div",Se,[t[23]||(t[23]=e("h3",{class:"text-lg font-semibold mb-3 text-gray-800"},"Productos",-1)),e("div",je,[(d(!0),n(A,null,L(l.value.items,(o,i)=>(d(),n("div",{key:i,class:"flex justify-between items-center bg-gray-50 p-4 rounded-lg"},[e("div",Fe,[e("p",Re,a(o.nombre),1),e("p",$e,a(o.marca)+" "+a(o.modelo)+" "+a(o.anio),1),e("p",Te,"Cantidad: "+a(o.cantidad)+" × $"+a(o.precio.toLocaleString()),1)]),e("p",Be,"$"+a(o.subtotal.toLocaleString()),1)]))),128))]),e("div",He,[e("p",Oe,"Total: $"+a(l.value.total.toLocaleString()),1)])]),e("div",Ue,[t[29]||(t[29]=e("h3",{class:"text-lg font-semibold mb-3 text-gray-800"},"Estado y Pago",-1)),e("div",qe,[e("div",null,[t[24]||(t[24]=e("p",{class:"text-sm text-gray-600"},"Estado Actual",-1)),e("span",{class:N([z(l.value.estado),"inline-block px-3 py-1 text-sm font-medium rounded-full mt-1"])},a(C(l.value.estado)),3)]),e("div",null,[t[26]||(t[26]=e("p",{class:"text-sm text-gray-600"},"Pagado",-1)),e("p",Ge,[l.value.isPaid?(d(),n("span",Je,[k(c,{name:"check-circle",size:"sm"}),t[25]||(t[25]=E(" Sí ",-1))])):(d(),n("span",Ke,"✗ No"))])]),l.value.mercadopagoPaymentId?(d(),n("div",Qe,[t[27]||(t[27]=e("p",{class:"text-sm text-gray-600"},"ID de Pago MP",-1)),e("p",We,a(l.value.mercadopagoPaymentId),1)])):u("",!0),l.value.paymentMethod?(d(),n("div",Xe,[t[28]||(t[28]=e("p",{class:"text-sm text-gray-600"},"Método de Pago",-1)),e("p",Ye,a(l.value.paymentMethod),1)])):u("",!0)])]),e("div",Ze,[t[32]||(t[32]=e("h3",{class:"text-lg font-semibold mb-3 text-gray-800"},"Cambiar Estado",-1)),e("div",et,[P(e("select",{"onUpdate:modelValue":t[6]||(t[6]=o=>r.value=o),class:"flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500"},[...t[30]||(t[30]=[D('<option value="pending">Pendiente</option><option value="approved">Aprobado</option><option value="rejected">Rechazado</option><option value="in_process">En Proceso</option><option value="refunded">Reembolsado</option><option value="cancelled">Cancelado</option>',6)])],512),[[I,r.value]]),e("button",{onClick:t[7]||(t[7]=o=>T(l.value.id)),disabled:h.value||r.value===l.value.estado,class:"px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium disabled:bg-gray-400 disabled:cursor-not-allowed"},a(h.value?"Actualizando...":"Actualizar"),9,tt)]),e("p",ot,[e("span",st,[k(c,{name:"exclamation-triangle",size:"sm"}),t[31]||(t[31]=E(' Al cambiar a "Aprobado", se enviará un email de confirmación al cliente ',-1))])])]),y.value?(d(),n("div",at,[t[34]||(t[34]=e("h3",{class:"text-lg font-semibold mb-3 text-gray-800"},"Datos Raw (MercadoPago)",-1)),w.value?(d(),n("div",lt,[e("pre",nt,a(JSON.stringify(w.value,null,2)),1)])):(d(),n("div",dt,[...t[33]||(t[33]=[e("p",null,'Haz clic en "Verificar en MercadoPago" para cargar los datos',-1)])]))])):u("",!0),y.value?(d(),n("div",rt,[t[35]||(t[35]=e("h3",{class:"text-lg font-semibold mb-3 text-gray-800"},"Datos Raw (Firestore)",-1)),e("div",it,[e("pre",ut,a(JSON.stringify(l.value,null,2)),1)])])):u("",!0)])])])):u("",!0)])}}});export{vt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.