import{_ as k,r as n,m as x,G as S,f as b,i as C,o as i,b as t,e as o,v as r,g as p,c,F as L,x as h,t as v,h as E,w as D}from"./index-BGUTfEkg.js";import{B as M}from"./BarberLayout-CKZaf4Xb.js";import{L as U}from"./LoadingSpinner-CQSESjI3.js";import{E as B}from"./ErrorMessage-CQom7-l-.js";import{M as F}from"./ModalDialog-BUeC3obb.js";import"./LogoutButton-Cuyr-ugP.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"},G={class:"row-inputs"},O={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),l=n(""),g=n([]),_=n(!1),a=n({description:"",client_name:"",service_date:"",start_time:"",end_time:"",price:0});x(f);async function f(){u.value=!0,l.value="";try{const d=await S.getCustomServiceLogs(m.value);g.value=d.data}catch{l.value="Error al cargar los registros"}finally{u.value=!1}}function V(){a.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(!a.value.description?.trim()){l.value="El detalle del servicio es obligatorio";return}if(!a.value.end_time||a.value.end_time<=a.value.start_time){l.value="La hora fin debe ser posterior a la hora inicio";return}if(a.value.price<0){l.value="El precio debe ser mayor o igual a 0";return}l.value="";try{await S.createCustomServiceLog(a.value),y(),await f()}catch(d){l.value=d.response?.data?.message||"Error al guardar"}}return(d,e)=>(i(),b(M,null,{default:C(()=>[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]=s=>m.value=s),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),l.value?(i(),b(B,{key:1,message:l.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,h(g.value,s=>(i(),c("div",{key:s.id,class:"card log-card"},[t("div",H,[t("strong",I,v(s.start_time)+" – "+v(s.end_time),1),t("span",P,"₡"+v(Number(s.price).toLocaleString()),1)]),t("p",R,v(s.description),1),s.client_name?(i(),c("span",j,v(s.client_name),1)):p("",!0)]))),128))])):p("",!0),E(F,{show:_.value,title:"Registrar servicio especial",onClose:y,onConfirm:w},{default:C(()=>[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]=s=>a.value.description=s),class:"input-control",rows:"3",placeholder:"Ej: Corte + barba, Cliente sin cita, Servicio especial..."},null,512),[[r,a.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]=s=>a.value.client_name=s),type:"text",class:"input-control",placeholder:"Para clientes sin cita"},null,512),[[r,a.value.client_name]])]),t("div",G,[t("div",O,[e[10]||(e[10]=t("label",null,"Fecha *",-1)),o(t("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>a.value.service_date=s),type:"date",class:"input-control",required:""},null,512),[[r,a.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]=s=>a.value.start_time=s),type:"time",class:"input-control",required:""},null,512),[[r,a.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]=s=>a.value.end_time=s),type:"time",class:"input-control",required:""},null,512),[[r,a.value.end_time]])])]),t("div",Q,[e[13]||(e[13]=t("label",null,"Precio (₡) *",-1)),o(t("input",{"onUpdate:modelValue":e[6]||(e[6]=s=>a.value.price=s),type:"number",min:"0",step:"100",class:"input-control",placeholder:"0",required:""},null,512),[[r,a.value.price,void 0,{number:!0}]])])],32)]),_:1},8,["show"])]),_:1}))}},ae=k(W,[["__scopeId","data-v-8a62d468"]]);export{ae as default};
