import{_ as g,n as y,E as _,f as c,i as h,r as d,o as l,b as t,g as m,c as i,F as b,s as k,t as u}from"./index-DvnNK70g.js";import{B as C}from"./BarberLayout-BnpYFoTb.js";import{L as x}from"./LoadingSpinner-CcZdsFCN.js";import{E as B}from"./ErrorMessage-DzpWWAPX.js";import"./LogoutButton-DrzvB6m_.js";const V={key:2,class:"card empty-card"},E={key:3,class:"card table-wrap"},L={class:"data-table"},A={__name:"ClientesView",setup(N){const n=d(!1),r=d(""),o=d([]);function f(a){if(!a)return"—";const e=String(a).slice(0,10),[s,p,v]=e.split("-");return v&&p&&s?`${v}/${p}/${s}`:e}return y(async()=>{n.value=!0,r.value="";try{const a=await _.getClientHistory();o.value=Array.isArray(a.data)?a.data:[]}catch(a){r.value=a.response?.data?.message||"No se pudo cargar el historial",o.value=[]}finally{n.value=!1}}),(a,e)=>(l(),c(C,null,{default:h(()=>[e[2]||(e[2]=t("h2",{style:{margin:"0 0 8px 0","font-size":"20px"}},"Clientes",-1)),e[3]||(e[3]=t("p",{class:"intro"},"Clientes con al menos una cita contigo (activas o históricas, sin canceladas).",-1)),n.value?(l(),c(x,{key:0})):m("",!0),r.value?(l(),c(B,{key:1,message:r.value},null,8,["message"])):m("",!0),!n.value&&!r.value&&o.value.length===0?(l(),i("div",V,[...e[0]||(e[0]=[t("p",null,"Todavía no hay movimiento registrado.",-1)])])):!n.value&&o.value.length?(l(),i("div",E,[t("table",L,[e[1]||(e[1]=t("thead",null,[t("tr",null,[t("th",null,"Cliente"),t("th",null,"Teléfono"),t("th",null,"Visitas"),t("th",null,"Última cita")])],-1)),t("tbody",null,[(l(!0),i(b,null,k(o.value,s=>(l(),i("tr",{key:s.client?.id},[t("td",null,u(s.client?.name||"—"),1),t("td",null,u(s.client?.phone||"—"),1),t("td",null,u(s.visit_count),1),t("td",null,u(f(s.last_appointment_date)),1)]))),128))])])])):m("",!0)]),_:1}))}},M=g(A,[["__scopeId","data-v-2b42ff35"]]);export{M as default};
