import{U as y,m as f}from"./primevue-CfIk0_DY.js";import{_ as h,b as k,s as p}from"./index-BxIwIJfy.js";import{o as b,b as a,c as i,d as s,f as w,t as o,p as n,F as A,C as B,k as C,j as $,a as g,y as d}from"./vue-core-Di3IuVqe.js";import"./cjs-helpers-psZwOBky.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";const N={class:"max-w-4xl mx-auto"},S={style:{"margin-bottom":"20px"}},T={class:"text-gray-500",style:{"margin-top":"2px"}},V={key:0},D={key:0,class:"text-center text-gray-400",style:{padding:"48px 0"}},I={key:1,class:"bg-white rounded-xl shadow-sm text-center",style:{padding:"48px 24px"}},j={key:2,class:"flex flex-col gap-2"},z={class:"min-w-0",style:{flex:"1"}},F={class:"font-medium text-gray-800"},M={key:0,class:"text-gray-500",style:{"margin-top":"2px"}},P={key:1,class:"text-gray-400",style:{"margin-top":"2px"}},q={class:"flex items-center gap-2 shrink-0"},E=["href"],L={__name:"PortailClientSites",setup(U){const u=d(()=>p.state.portailClientDb),_=d(()=>p.state.portailClientToken),l=g([]),c=g(!1),m=d(()=>l.value.reduce((r,e)=>r+(e.nb_agents||0),0));return b(async()=>{if(u.value){c.value=!0;try{const r=await k.get(`${p.lienApi}/portail-client/sites/${u.value}`,{headers:{Authorization:`Bearer ${_.value}`}});l.value=r.data||[]}catch{l.value=[]}finally{c.value=!1}}}),(r,e)=>{const x=y,v=f;return a(),i("div",N,[s("div",S,[e[0]||(e[0]=s("h1",{class:"text-2xl font-bold text-gray-800"},"Mes sites",-1)),s("p",T,[w(o(l.value.length)+" site(s)",1),m.value?(a(),i("span",V," · "+o(m.value)+" agent(s) affecté(s)",1)):n("",!0)])]),c.value?(a(),i("div",D,[...e[1]||(e[1]=[s("i",{class:"pi pi-spin pi-spinner text-2xl"},null,-1)])])):l.value.length?(a(),i("div",j,[(a(!0),i(A,null,B(l.value,t=>(a(),i("div",{key:t.Id_site,class:"site-carte"},[e[4]||(e[4]=s("div",{class:"site-pastille"},[s("i",{class:"pi pi-map-marker"})],-1)),s("div",z,[s("div",F,o(t.Nom||"Site sans nom"),1),t.Adresse||t.ville?(a(),i("div",M,o([t.Adresse,t.ville].filter(Boolean).join(" · ")),1)):n("",!0),t.affaire?(a(),i("div",P,o(t.affaire),1)):n("",!0)]),s("div",q,[t.nb_agents?(a(),C(x,{key:0,value:`${t.nb_agents} agent(s)`,severity:"secondary"},null,8,["value"])):n("",!0),t.latitude&&t.longitude?$((a(),i("a",{key:1,href:`https://www.google.com/maps?q=${t.latitude},${t.longitude}`,target:"_blank",rel:"noopener",class:"lien-carte"},[...e[3]||(e[3]=[s("i",{class:"pi pi-external-link"},null,-1)])],8,E)),[[v,"Voir sur la carte"]]):n("",!0)])]))),128))])):(a(),i("div",I,[...e[2]||(e[2]=[s("i",{class:"pi pi-map-marker text-gray-300",style:{"font-size":"40px"}},null,-1),s("p",{class:"text-gray-500",style:{"margin-top":"12px"}},"Aucun site enregistré.",-1)])]))])}}},W=h(L,[["__scopeId","data-v-d109c8c0"]]);export{W as default};
