import{c as k}from"./modules-n_9BHTn9.js";import{C as E}from"./ClientLayout-CInqszsu.js";import{L as h}from"./LoadingSpinner-BwucH-rm.js";import{E as B}from"./ErrorMessage-DdwsDJ1D.js";import{S as N}from"./StatusBadge-D3hMSVIw.js";import{M as S}from"./ModalDialog-CkqQASQi.js";import{_ as V,l as $,d as y,g as f,r as d,h as H,o,a as e,e as l,c as r,f as _,j as b,F as L,n as T,t as p,p as R}from"./index-BjuSGa5E.js";const F={key:2,class:"no-appointment"},z={key:3,class:"appointments-list"},I={class:"appointment-header"},j={class:"appointment-service"},q={class:"appointment-barber"},O={class:"appointment-details"},U={class:"detail-row"},G={class:"detail-value"},J={class:"detail-row"},K={class:"detail-value"},P={class:"detail-row"},Q={class:"detail-value"},W=["onClick"],X={key:4,class:"reserve-link"},Y={__name:"MyAppointmentView",setup(Z){const i=d(!0),u=d(""),C=d([]),c=d(null),m=d(!1),g=new Date;g.setHours(0,0,0,0);const v=R(()=>C.value.filter(s=>{const t=s.status,a=new Date(s.appointment_date);return a.setHours(0,0,0,0),(t==="pending"||t==="confirmed")&&a>=g}).sort((s,t)=>{const a=new Date(`${s.appointment_date}T${s.start_time}`),n=new Date(`${t.appointment_date}T${t.start_time}`);return a-n}));function D(s){const t=s.status,a=new Date(s.appointment_date);return a.setHours(0,0,0,0),(t==="pending"||t==="confirmed")&&a>=g}function x(s){c.value=s,m.value=!0}$(w);async function w(){i.value=!0,u.value="";try{const s=await k.getAppointments();C.value=s.data||[]}catch{u.value="Error al cargar las citas"}finally{i.value=!1}}function A(s){return new Date(s).toLocaleDateString("es-ES",{weekday:"long",year:"numeric",month:"long",day:"numeric"})}async function M(){if(!c.value)return;m.value=!1;const s=c.value.id;c.value=null;try{await k.cancelAppointment(s),await w()}catch(t){u.value=t.response?.data?.message||"Error al cancelar la cita"}}return(s,t)=>{const a=H("router-link");return o(),y(E,null,{default:f(()=>[t[10]||(t[10]=e("h2",{style:{margin:"0 0 5px 0","font-size":"22px"}},"Mis Citas",-1)),t[11]||(t[11]=e("p",{class:"title-sm",style:{"margin-top":"0"}},"Todas tus citas próximas",-1)),i.value?(o(),y(h,{key:0})):l("",!0),u.value?(o(),y(B,{key:1,message:u.value},null,8,["message"])):l("",!0),!i.value&&v.value.length===0?(o(),r("div",F,[t[2]||(t[2]=e("div",{class:"no-appointment-icon"},[e("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[e("path",{d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})])],-1)),t[3]||(t[3]=e("p",{class:"no-appointment-text"},"No tenés citas próximas",-1)),_(a,{to:"/client/book",class:"btn btn-gold"},{default:f(()=>[...t[1]||(t[1]=[b("Reservar Cita",-1)])]),_:1})])):l("",!0),!i.value&&v.value.length>0?(o(),r("div",z,[(o(!0),r(L,null,T(v.value,n=>(o(),r("div",{key:n.id,class:"card appointment-card"},[e("div",I,[e("div",null,[e("h3",j,p(n.service?.name),1),e("p",q,p(n.barber?.user?.name),1)]),_(N,{status:n.status},null,8,["status"])]),t[7]||(t[7]=e("div",{class:"appointment-divider"},null,-1)),e("div",O,[e("div",U,[t[4]||(t[4]=e("span",{class:"title-sm"},"FECHA",-1)),e("span",G,p(A(n.appointment_date)),1)]),e("div",J,[t[5]||(t[5]=e("span",{class:"title-sm"},"HORA",-1)),e("span",K,p(n.start_time),1)]),e("div",P,[t[6]||(t[6]=e("span",{class:"title-sm"},"DURACIÓN",-1)),e("span",Q,p(n.service?.duration_minutes)+" min",1)])]),D(n)?(o(),r("button",{key:0,onClick:tt=>x(n),class:"btn btn-danger cancel-btn"}," Cancelar Cita ",8,W)):l("",!0)]))),128))])):l("",!0),!i.value&&v.value.length>0?(o(),r("div",X,[_(a,{to:"/client/book",class:"btn btn-outline"},{default:f(()=>[...t[8]||(t[8]=[b("Reservar otra cita",-1)])]),_:1})])):l("",!0),_(S,{show:m.value,title:"Cancelar Cita",onClose:t[0]||(t[0]=n=>m.value=!1),onConfirm:M},{default:f(()=>[...t[9]||(t[9]=[e("p",{class:"modal-text"},"¿Estás seguro de que deseas cancelar esta cita?",-1)])]),_:1},8,["show"])]),_:1})}}},rt=V(Y,[["__scopeId","data-v-99e6fc22"]]);export{rt as default};
