import{_ as A,r as c,l as I,d as _,g as b,h as B,o as r,a as s,b as V,v as E,e as d,c as u,F as L,n as N,q as y,t as m,f as S,j as D}from"./index-BjuSGa5E.js";import{b as h}from"./modules-n_9BHTn9.js";import{B as M}from"./BarberLayout-BJ9zeVq-.js";import{L as F}from"./LoadingSpinner-BwucH-rm.js";import{E as P}from"./ErrorMessage-DdwsDJ1D.js";const T={class:"agenda-header"},z={key:2,class:"no-appointments"},$={key:3,class:"appointments-list"},j={class:"card-top"},q={class:"card-time"},H={class:"client-name"},O={class:"service-name"},U={class:"card-actions"},G=["onClick","disabled"],J={__name:"AgendaView",setup(K){const f=c(new Date().toISOString().split("T")[0]),l=c(!1),i=c(""),o=c([]),p=c(!1);function k(a,e){if(a.status==="completed")return"Completado";if(a.status==="cancelled")return"Cancelado";const n=o.value.findIndex(t=>t.status==="confirmed");return n===e?"En Progreso":n>=0&&e===n+1?"Próximo":"Pendiente"}function C(a,e){if(a.status==="completed")return"badge-green";if(a.status==="cancelled")return"";const n=o.value.findIndex(t=>t.status==="confirmed");return n===e?"badge-green":n>=0&&e===n+1?"badge-gold":""}function x(a,e){if(a.status==="completed"||a.status==="cancelled")return"card-muted";const n=o.value.findIndex(t=>t.status==="confirmed");return n===e?"card-progress":n>=0&&e===n+1?"card-next":"card-pending"}I(g);async function g(){l.value=!0,i.value="";try{const a=await h.getAgenda(f.value);o.value=a.data}catch{i.value="Error al cargar la agenda"}finally{l.value=!1}}async function w(a){p.value=!0;try{await h.completeAppointment(a),await g()}catch{i.value="Error al completar la cita"}finally{p.value=!1}}return(a,e)=>{const n=B("router-link");return r(),_(M,null,{default:b(()=>[e[3]||(e[3]=s("h2",{style:{margin:"0 0 20px 0","font-size":"20px"}},"Agenda de Hoy",-1)),s("div",T,[V(s("input",{"onUpdate:modelValue":e[0]||(e[0]=t=>f.value=t),type:"date",onChange:g,class:"input-control date-input"},null,544),[[E,f.value]])]),l.value?(r(),_(F,{key:0})):d("",!0),i.value?(r(),_(P,{key:1,message:i.value},null,8,["message"])):d("",!0),!l.value&&o.value.length===0?(r(),u("div",z,[...e[1]||(e[1]=[s("p",null,"No hay citas para esta fecha",-1)])])):d("",!0),!l.value&&o.value.length>0?(r(),u("div",$,[(r(!0),u(L,null,N(o.value,(t,v)=>(r(),u("div",{key:t.id,class:y(["card appointment-card",x(t,v)])},[s("div",j,[s("span",{class:y(["badge",C(t,v)])},m(k(t,v)),3),s("strong",q,m(t.start_time),1)]),s("strong",H,m(t.client?.name),1),s("span",O,m(t.service?.name),1),s("div",U,[S(n,{to:`/barber/photo/${t.id}`,class:"btn btn-outline btn-sm"},{default:b(()=>[...e[2]||(e[2]=[D("Fotos",-1)])]),_:1},8,["to"]),t.status==="confirmed"?(r(),u("button",{key:0,onClick:Q=>w(t.id),disabled:p.value,class:"btn btn-success btn-sm"}," Marcar completada ",8,G)):d("",!0)])],2))),128))])):d("",!0)]),_:1})}}},ee=A(J,[["__scopeId","data-v-fe8e39bd"]]);export{ee as default};
