import{_ as k,r as n,l as x,d as b,g as S,o as i,a as t,b as o,v as r,e as p,c,F as L,n as E,t as v,f as h,w as D}from"./index-DcK5qV02.js";import{b as C}from"./modules-DLxePyvQ.js";import{B as M}from"./BarberLayout-BsaeNXgD.js";import{L as U}from"./LoadingSpinner-Dgnv988R.js";import{E as B}from"./ErrorMessage-Tp1tOCV-.js";import{M as F}from"./ModalDialog-2xXepo5I.js";const N={class:"header-row"},q={key:2,class:"no-items"},T={key:3,class:"logs-list"},H={class:"log-top"},I={class:"log-time"},P={class:"log-price"},R={class:"log-desc"},j={key:0,class:"log-client"},z={class:"input-group"},A={class:"input-group"},O={class:"row-inputs"},G={class:"input-group"},J={class:"input-group"},K={class:"input-group"},Q={class:"input-group"},W={__name:"CustomServiceView",setup(X){const m=n(new Date().toISOString().split("T")[0]),u=n(!1),s=n(""),g=n([]),_=n(!1),l=n({description:"",client_name:"",service_date:"",start_time:"",end_time:"",price:0});x(f);async function f(){u.value=!0,s.value="";try{const d=await C.getCustomServiceLogs(m.value);g.value=d.data}catch{s.value="Error al cargar los registros"}finally{u.value=!1}}function V(){l.value={description:"",client_name:"",service_date:m.value,start_time:new Date().toTimeString().slice(0,5),end_time:"",price:0},_.value=!0}function y(){_.value=!1}async function w(){if(!l.value.description?.trim()){s.value="El detalle del servicio es obligatorio";return}if(!l.value.end_time||l.value.end_time<=l.value.start_time){s.value="La hora fin debe ser posterior a la hora inicio";return}if(l.value.price<0){s.value="El precio debe ser mayor o igual a 0";return}s.value="";try{await C.createCustomServiceLog(l.value),y(),await f()}catch(d){s.value=d.response?.data?.message||"Error al guardar"}}return(d,e)=>(i(),b(M,null,{default:S(()=>[e[14]||(e[14]=t("h2",{style:{margin:"0 0 20px 0","font-size":"20px"}},"Servicio especial / Sin cita",-1)),t("div",N,[o(t("input",{"onUpdate:modelValue":e[0]||(e[0]=a=>m.value=a),type:"date",onChange:f,class:"input-control date-input"},null,544),[[r,m.value]]),t("button",{class:"btn btn-add btn-gold",onClick:V},"+ Registrar")]),u.value?(i(),b(U,{key:0})):p("",!0),s.value?(i(),b(B,{key:1,message:s.value},null,8,["message"])):p("",!0),!u.value&&g.value.length===0?(i(),c("div",q,[...e[7]||(e[7]=[t("p",null,"No hay servicios especiales registrados para esta fecha",-1)])])):p("",!0),!u.value&&g.value.length>0?(i(),c("div",T,[(i(!0),c(L,null,E(g.value,a=>(i(),c("div",{key:a.id,class:"card log-card"},[t("div",H,[t("strong",I,v(a.start_time)+" – "+v(a.end_time),1),t("span",P,"₡"+v(Number(a.price).toLocaleString()),1)]),t("p",R,v(a.description),1),a.client_name?(i(),c("span",j,v(a.client_name),1)):p("",!0)]))),128))])):p("",!0),h(F,{show:_.value,title:"Registrar servicio especial",onClose:y,onConfirm:w},{default:S(()=>[t("form",{class:"custom-form",onSubmit:D(w,["prevent"])},[t("div",z,[e[8]||(e[8]=t("label",null,"Detalle del servicio *",-1)),o(t("textarea",{"onUpdate:modelValue":e[1]||(e[1]=a=>l.value.description=a),class:"input-control",rows:"3",placeholder:"Ej: Corte + barba, Cliente sin cita, Servicio especial..."},null,512),[[r,l.value.description]])]),t("div",A,[e[9]||(e[9]=t("label",null,"Nombre del cliente (opcional)",-1)),o(t("input",{"onUpdate:modelValue":e[2]||(e[2]=a=>l.value.client_name=a),type:"text",class:"input-control",placeholder:"Para clientes sin cita"},null,512),[[r,l.value.client_name]])]),t("div",O,[t("div",G,[e[10]||(e[10]=t("label",null,"Fecha *",-1)),o(t("input",{"onUpdate:modelValue":e[3]||(e[3]=a=>l.value.service_date=a),type:"date",class:"input-control",required:""},null,512),[[r,l.value.service_date]])]),t("div",J,[e[11]||(e[11]=t("label",null,"Hora inicio *",-1)),o(t("input",{"onUpdate:modelValue":e[4]||(e[4]=a=>l.value.start_time=a),type:"time",class:"input-control",required:""},null,512),[[r,l.value.start_time]])]),t("div",K,[e[12]||(e[12]=t("label",null,"Hora fin *",-1)),o(t("input",{"onUpdate:modelValue":e[5]||(e[5]=a=>l.value.end_time=a),type:"time",class:"input-control",required:""},null,512),[[r,l.value.end_time]])])]),t("div",Q,[e[13]||(e[13]=t("label",null,"Precio (₡) *",-1)),o(t("input",{"onUpdate:modelValue":e[6]||(e[6]=a=>l.value.price=a),type:"number",min:"0",step:"100",class:"input-control",placeholder:"0",required:""},null,512),[[r,l.value.price,void 0,{number:!0}]])])],32)]),_:1},8,["show"])]),_:1}))}},le=k(W,[["__scopeId","data-v-8a62d468"]]);export{le as default};
