import{y as V,A as N,U as $,z as j}from"./primevue-CfIk0_DY.js";import{b as A,s as y}from"./index-BxIwIJfy.js";import{a as o,o as C,b as F,c as M,d as l,t as m,v as s,l as n,f,y as k}from"./vue-core-Di3IuVqe.js";import"./cjs-helpers-psZwOBky.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";const z={class:"max-w-5xl mx-auto"},T={class:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",style:{"margin-bottom":"16px"}},B={class:"text-gray-500",style:{"margin-top":"2px"}},S={class:"flex gap-2"},Y={class:"font-medium text-gray-800"},P={__name:"PortailCabinetEcheances",setup(E){const h=k(()=>y.state.portailCabinetToken),u=o(new Date().getMonth()+1),c=o(new Date().getFullYear()),x=[{label:"Janvier",value:1},{label:"Fevrier",value:2},{label:"Mars",value:3},{label:"Avril",value:4},{label:"Mai",value:5},{label:"Juin",value:6},{label:"Juillet",value:7},{label:"Aout",value:8},{label:"Septembre",value:9},{label:"Octobre",value:10},{label:"Novembre",value:11},{label:"Decembre",value:12}],g=o([new Date().getFullYear()+1,new Date().getFullYear(),new Date().getFullYear()-1]),r=o([]),d=o(!1),_=t=>{if(!t)return"—";const e=new Date(t);return isNaN(e)?"—":e.toLocaleDateString("fr-FR")},v=t=>{if(t.statut==="fait")return{label:"Realisee",severity:"success"};const e=Number(t.jours_restants);return isNaN(e)?{label:"—",severity:"secondary"}:e<0?{label:`${Math.abs(e)} j de retard`,severity:"danger"}:e===0?{label:"Aujourd'hui",severity:"danger"}:e<=5?{label:`Dans ${e} j`,severity:"warn"}:{label:`Dans ${e} j`,severity:"info"}},p=async()=>{d.value=!0;try{const t=await A.get(`${y.lienApi}/portail-cabinet/echeances`,{params:{mois:u.value,annee:c.value},headers:{Authorization:`Bearer ${h.value}`}});r.value=t.data||[]}catch{r.value=[]}finally{d.value=!1}};return C(p),(t,e)=>{const b=V,i=N,w=$,D=j;return F(),M("div",z,[l("div",T,[l("div",null,[e[2]||(e[2]=l("h1",{class:"text-2xl font-bold text-gray-800"},"Mes echeances",-1)),l("p",B,m(r.value.length)+" echeance(s) ce mois",1)]),l("div",S,[s(b,{modelValue:u.value,"onUpdate:modelValue":e[0]||(e[0]=a=>u.value=a),options:x,optionLabel:"label",optionValue:"value",onChange:p,size:"small",style:{"min-width":"130px"}},null,8,["modelValue"]),s(b,{modelValue:c.value,"onUpdate:modelValue":e[1]||(e[1]=a=>c.value=a),options:g.value,onChange:p,size:"small",style:{"min-width":"100px"}},null,8,["modelValue","options"])])]),s(D,{value:r.value,loading:d.value,stripedRows:"",size:"small",class:"bg-white rounded-xl shadow-sm overflow-hidden"},{empty:n(()=>[...e[3]||(e[3]=[l("div",{class:"text-center text-gray-400",style:{padding:"32px 0"}},[l("i",{class:"pi pi-calendar text-3xl block",style:{"margin-bottom":"8px"}}),f(" Aucune echeance pour cette periode. ")],-1)])]),default:n(()=>[s(i,{header:"Type"},{body:n(({data:a})=>[l("span",Y,m(a.type_libelle||a.code_type),1)]),_:1}),s(i,{field:"periode",header:"Periode",style:{width:"130px"}}),s(i,{header:"Echeance",style:{width:"130px"}},{body:n(({data:a})=>[f(m(_(a.date_echeance)),1)]),_:1}),s(i,{header:"Delai",style:{width:"150px"}},{body:n(({data:a})=>[s(w,{value:v(a).label,severity:v(a).severity},null,8,["value","severity"])]),_:1})]),_:1},8,["value","loading"])])}}};export{P as default};
