import{_ as k,u as R,r as u,b as v,c as b,j as z,d as a,T as L,q as O,v as C,a7 as Q,t as n,i as h,g as f,f as T,l as B,R as I,L as V}from"./main.37e79106.js";import{e as M,b as N,a as S}from"./OrdenLavanderiaRepository.ed098771.js";const j={class:"layout-px-spacing"},A={class:"row layout-top-spacing"},q={class:"col-xl-12 col-lg-12 col-sm-12 layout-spacing"},F={class:"panel p-3"},K={class:"row mt-4"},U={class:"col-md-6 offset-md-3"},P={class:"card"},$={class:"card-body"},G={class:"form-group mb-3"},H=["disabled"],J={key:0,class:"card mt-3"},W={class:"card-body"},X={class:"card-title text-success"},Y={class:"mb-1"},Z={class:"mb-1"},D={class:"mb-1"},aa={class:"badge bg-info ms-1"},ea={key:0,class:"mb-2"},sa={class:"text-warning"},ta=["disabled"],oa={key:1,class:"alert alert-danger mt-3"},na={__name:"escanear",setup(la){R({title:"Escanear QR Lavander\xEDa"});const l=u(""),p=u(!1),d=u(!1),s=u(null),r=u(""),m=u(!1),w=t=>({recepcion:"Recepci\xF3n",lavado:"Lavado",secado:"Secado",planchado:"Planchado",terminado:"Terminado",entregado:"Entregado"})[t]||t,_=(t="",e="success")=>{window.Swal.mixin({toast:!0,position:"top",showConfirmButton:!1,timer:3e3}).fire({icon:e,title:t,padding:"10px 20px"})},g=async()=>{var t,e,c,y,x;if(!l.value.trim()){_("Ingrese un c\xF3digo QR o folio","warning");return}p.value=!0,d.value=!0,r.value="",s.value=null;try{let o;try{o=await M(l.value.trim())}catch{o=await N(l.value.trim())}o.data&&o.encontrada?(s.value=o.data,_("Orden encontrada","success")):r.value=((e=(t=o.errors)==null?void 0:t.orden)==null?void 0:e[0])||"Orden no encontrada o inv\xE1lida"}catch(o){if(I.isAxiosError(o)){const i=(c=o.response)==null?void 0:c.data;r.value=((x=(y=i==null?void 0:i.errors)==null?void 0:y.orden)==null?void 0:x[0])||(i==null?void 0:i.message)||"Error al escanear la orden"}else r.value="Error inesperado al escanear"}finally{p.value=!1,d.value=!1}},E=async()=>{if(!!s.value){m.value=!0,d.value=!0;try{await S(s.value.id),_("Orden avanzada correctamente","success"),setTimeout(()=>{l.value="",s.value=null,r.value=""},2e3)}catch(t){console.error(t),_("Error al avanzar la orden","error")}finally{m.value=!1,d.value=!1}}};return(t,e)=>(v(),b("div",j,[(v(),z(L,{to:"#breadcrumb"},[e[2]||(e[2]=a("ul",{class:"navbar-nav flex-row"},[a("li",null,[a("div",{class:"page-header"},[a("nav",{class:"breadcrumb-one","aria-label":"breadcrumb"},[a("ol",{class:"breadcrumb"},[a("li",{class:"breadcrumb-item"},[a("a",{href:"javascript:;"},"Lavander\xEDa")]),a("li",{class:"breadcrumb-item active","aria-current":"page"},[a("span",null,"Escanear QR")])])])])])],-1))])),a("div",A,[a("div",q,[a("div",F,[e[8]||(e[8]=a("div",{class:"row"},[a("div",{class:"col-xl-12 col-lg-12 col-sm-12"},[a("div",{class:"text-center titulo-dorado"},[a("h3",{class:"pull-left"},"Escanear Orden de Lavander\xEDa")])])],-1)),a("div",K,[a("div",U,[a("div",P,[a("div",$,[a("div",G,[e[3]||(e[3]=a("label",null,"C\xF3digo QR o Folio",-1)),O(a("input",{type:"text",class:"form-control form-control-lg text-center",placeholder:"Escanee el c\xF3digo QR o ingrese el folio","onUpdate:modelValue":e[0]||(e[0]=c=>l.value=c),onKeyup:Q(g,["enter"]),autofocus:""},null,544),[[C,l.value]])]),a("button",{type:"button",class:"btn btn-primary btn-lg w-100",onClick:g,disabled:!l.value||p.value},n(p.value?"Escaneando...":"Escanear e Iniciar"),9,H)])]),s.value?(v(),b("div",J,[a("div",W,[a("h5",X," \u2713 Orden encontrada: "+n(s.value.folio_unico),1),a("p",Y,[e[4]||(e[4]=a("strong",null,"Cliente:",-1)),h(" "+n(s.value.cliente_nombre),1)]),a("p",Z,[e[5]||(e[5]=a("strong",null,"Servicio:",-1)),h(" "+n(s.value.tipo_servicio),1)]),a("p",D,[e[6]||(e[6]=a("strong",null,"Etapa actual:",-1)),a("span",aa,n(w(s.value.current_step)),1)]),s.value.instrucciones?(v(),b("p",ea,[e[7]||(e[7]=a("strong",null,"Instrucciones:",-1)),a("span",sa,n(s.value.instrucciones),1)])):f("",!0),a("button",{type:"button",class:"btn btn-success btn-lg w-100 mt-2",onClick:E,disabled:m.value},n(m.value?"Avanzando...":"Iniciar/Avanzar Etapa"),9,ta)])])):f("",!0),r.value?(v(),b("div",oa,n(r.value),1)):f("",!0)])])])])]),T(B(V),{active:d.value,"onUpdate:active":e[1]||(e[1]=c=>d.value=c),"can-cancel":!1,"is-full-page":!0},null,8,["active"])]))}},ia=k(na,[["__scopeId","data-v-8f30ebe1"]]);export{ia as default};
