import{b as F,s as i}from"./index-BxIwIJfy.js";import{o as M,h as N,b as a,c as n,d as t,t as o,q as _,f,p as h,F as B,C as S,k as A,l as E,y as c,a as u}from"./vue-core-Di3IuVqe.js";import"./primevue-CfIk0_DY.js";import"./cjs-helpers-psZwOBky.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";const R={class:"max-w-5xl mx-auto space-y-6"},I={class:"text-2xl font-bold text-gray-800"},L={class:"grid grid-cols-1 sm:grid-cols-3 gap-4"},V={class:"rounded-xl border bg-white p-5 shadow-sm"},$={class:"rounded-xl border bg-white p-5 shadow-sm"},j={class:"text-2xl font-bold text-gray-800 mt-1"},H={class:"rounded-xl border bg-white p-5 shadow-sm"},z={key:0,class:"text-base font-semibold text-gray-800 mt-1"},P={key:1,class:"text-xs text-gray-400"},T={key:2,class:"text-gray-400 mt-1"},U={key:0,class:"rounded-xl border bg-white p-5 shadow-sm"},q={class:"flex items-center justify-between flex-wrap gap-2"},O={class:"text-lg font-bold text-gray-800 mt-1"},G={class:"text-xs text-gray-500",style:{"margin-top":"4px"}},J={class:"text-right"},K={class:"text-xl font-bold text-red-600"},Q={class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4"},W={class:"flex items-center gap-4"},X={class:"flex h-12 w-12 items-center justify-center rounded-lg bg-blue-50"},Y={class:"font-semibold text-gray-800 group-hover:text-blue-600 transition-colors"},it={__name:"PortailClientAccueil",setup(Z){const y=c(()=>i.state.portailClientClient?.nom||""),x=c(()=>i.state.portailClientDb),v=c(()=>i.state.portailClientClient?.code_client),w=c(()=>i.state.portailClientToken),m=u(0),g=u(0),l=u(null),r=u(null),k={documents_factures:{label:"Mes factures",to:"/portail-client/factures",icon:"pi pi-file-edit"},documents_avoirs:{label:"Mes avoirs",to:"/portail-client/avoirs",icon:"pi pi-undo"},releve:{label:"Mon releve",to:"/portail-client/releve",icon:"pi pi-list"},reglements:{label:"Mes reglements",to:"/portail-client/reglements",icon:"pi pi-wallet"},documents_devis:{label:"Mes devis",to:"/portail-client/devis",icon:"pi pi-file"},documents_bl:{label:"Mes bons de livraison",to:"/portail-client/bl",icon:"pi pi-truck"},commandes_en_cours:{label:"Commandes en attente",to:"/portail-client/commandes",icon:"pi pi-clock"},stock_articles:{label:"Stock disponible",to:"/portail-client/stock",icon:"pi pi-box"},catalogue:{label:"Catalogue",to:"/portail-client/catalogue",icon:"pi pi-shopping-bag"}},C=c(()=>(i.state.portailClientModules||[]).map(s=>k[s.code_module]).filter(Boolean)),p=s=>s==null?"0,00":Number(s).toLocaleString("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2}),b=s=>{if(!s)return"—";const e=new Date(s);return isNaN(e)?"—":e.toLocaleDateString("fr-FR")};return M(async()=>{if(!(!x.value||!v.value))try{const s=await F.get(`${i.lienApi}/portail-client/resume/${x.value}/${encodeURIComponent(v.value)}`,{headers:{Authorization:`Bearer ${w.value}`}});m.value=s.data.soldeDu||0,g.value=s.data.nbImpayees||0,l.value=s.data.derniereFacture,r.value=s.data.prochaineEcheance}catch{}}),(s,e)=>{const D=N("router-link");return a(),n("div",R,[t("div",null,[t("h1",I," Bonjour, "+o(y.value),1),e[0]||(e[0]=t("p",{class:"text-gray-500 mt-1"},"Voici un resume de votre situation.",-1))]),t("div",L,[t("div",V,[e[2]||(e[2]=t("div",{class:"text-sm text-gray-500"},"Solde du",-1)),t("div",{class:_(["text-2xl font-bold mt-1",m.value>0?"text-red-600":"text-green-600"])},[f(o(p(m.value))+" ",1),e[1]||(e[1]=t("span",{class:"text-sm font-normal text-gray-400"},"DH",-1))],2)]),t("div",$,[e[3]||(e[3]=t("div",{class:"text-sm text-gray-500"},"Factures impayees",-1)),t("div",j,o(g.value),1)]),t("div",H,[e[4]||(e[4]=t("div",{class:"text-sm text-gray-500"},"Derniere facture",-1)),l.value?(a(),n("div",z," N° "+o(l.value.nfacturec),1)):h("",!0),l.value?(a(),n("div",P,o(b(l.value.date))+" · "+o(p(l.value.ttc_dh))+" DH ",1)):(a(),n("div",T,"—"))])]),r.value?(a(),n("div",U,[t("div",q,[t("div",null,[e[5]||(e[5]=t("div",{class:"text-sm text-gray-500"},"Prochaine echeance impayee",-1)),t("div",O," Facture N° "+o(r.value.nfacturec),1),t("div",G," Echeance : "+o(b(r.value.echeance)),1)]),t("div",J,[e[7]||(e[7]=t("div",{class:"text-sm text-gray-500"},"Reste a payer",-1)),t("div",K,[f(o(p(r.value.reste))+" ",1),e[6]||(e[6]=t("span",{class:"text-sm font-normal"},"DH",-1))])])])])):h("",!0),t("div",null,[e[8]||(e[8]=t("h2",{class:"text-lg font-semibold text-gray-700 mb-3"},"Acces rapide",-1)),t("div",Q,[(a(!0),n(B,null,S(C.value,d=>(a(),A(D,{key:d.to,to:d.to,class:"block rounded-xl border bg-white p-5 shadow-sm hover:shadow-md transition-shadow group"},{default:E(()=>[t("div",W,[t("div",X,[t("i",{class:_([d.icon,"text-xl"]),style:{color:"var(--omag-500)"}},null,2)]),t("div",null,[t("h3",Y,o(d.label),1)])])]),_:2},1032,["to"]))),128))])])])}}};export{it as default};
