import{y as b,A as D,U as N,z as V}from"./primevue-CfIk0_DY.js";import{b as k,s as x}from"./index-BxIwIJfy.js";import{a as i,o as A,b as C,c as F,d as n,t as c,v as s,l,f as p,y as S}from"./vue-core-Di3IuVqe.js";import"./cjs-helpers-psZwOBky.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";const T={class:"max-w-5xl mx-auto"},$={class:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",style:{"margin-bottom":"16px"}},z={class:"text-gray-500",style:{"margin-top":"2px"}},B={class:"font-medium text-gray-800"},j={__name:"PortailCabinetDeclarations",setup(E){const _=S(()=>x.state.portailCabinetToken),d=i(new Date().getFullYear()),v=i([new Date().getFullYear(),new Date().getFullYear()-1,new Date().getFullYear()-2]),r=i([]),u=i(!1),m=a=>{if(!a)return"—";const e=new Date(a);return isNaN(e)?"—":e.toLocaleDateString("fr-FR")},y=a=>{if(a.statut==="fait")return{label:"Realisee",severity:"success"};const e=a.date_echeance?new Date(a.date_echeance):null;return e&&!isNaN(e)&&e<new Date(new Date().toDateString())?{label:"En retard",severity:"danger"}:a.statut==="en_cours"?{label:"En cours",severity:"info"}:{label:"A faire",severity:"warn"}},f=async()=>{u.value=!0;try{const a=await k.get(`${x.lienApi}/portail-cabinet/declarations`,{params:{annee:d.value},headers:{Authorization:`Bearer ${_.value}`}});r.value=a.data||[]}catch{r.value=[]}finally{u.value=!1}};return A(f),(a,e)=>{const g=b,o=D,h=N,w=V;return C(),F("div",T,[n("div",$,[n("div",null,[e[1]||(e[1]=n("h1",{class:"text-2xl font-bold text-gray-800"},"Mes declarations",-1)),n("p",z,c(r.value.length)+" declaration(s)",1)]),s(g,{modelValue:d.value,"onUpdate:modelValue":e[0]||(e[0]=t=>d.value=t),options:v.value,onChange:f,size:"small",style:{"min-width":"100px"}},null,8,["modelValue","options"])]),s(w,{value:r.value,loading:u.value,stripedRows:"",size:"small",paginator:"",rows:20,class:"bg-white rounded-xl shadow-sm overflow-hidden"},{empty:l(()=>[...e[2]||(e[2]=[n("div",{class:"text-center text-gray-400",style:{padding:"32px 0"}},[n("i",{class:"pi pi-file text-3xl block",style:{"margin-bottom":"8px"}}),p(" Aucune declaration pour cette annee. ")],-1)])]),default:l(()=>[s(o,{header:"Type"},{body:l(({data:t})=>[n("span",B,c(t.type_libelle||t.code_type),1)]),_:1}),s(o,{field:"periode",header:"Periode",style:{width:"130px"}}),s(o,{header:"Echeance",style:{width:"130px"}},{body:l(({data:t})=>[p(c(m(t.date_echeance)),1)]),_:1}),s(o,{header:"Statut",style:{width:"140px"}},{body:l(({data:t})=>[s(h,{value:y(t).label,severity:y(t).severity},null,8,["value","severity"])]),_:1}),s(o,{header:"Realisee le",style:{width:"130px"}},{body:l(({data:t})=>[p(c(m(t.date_realisation)),1)]),_:1})]),_:1},8,["value","loading"])])}}};export{j as default};
