PageSourceSearch

https://flashdz.com/assets/ListeEncaissements-DF08pT12.js

js flashdz.com collected 2026-10-06 20:20:55 UTC 7,378 bytes, 1 lines download raw bytes

1import{u as K,j as t}from"./query-vendor-BRmJJ5qy.js";import{r as a}from"./react-vendor-BFRhVHEi.js";import{D as P}from"./DataTable-CW46N8ZB.js";import{d as Q,j as R,cd as D,A as j,aG as W,M as Y,a$ as B,ce as G}from"./index-OYhlPsKp.js";import{A as I}from"./AdminHistoriqueModal-BBvJWkRI.js";import{P as O}from"./PageTitle-BU6cFTlv.js";import{f as m,a as V}from"./adminColisColumns-DyP-vs0h.js";import"./winLabels-D3iB8_Nu.js";function x(){const r=new Date,l=String(r.getMonth()+1).padStart(2,"0"),g=String(r.getDate()).padStart(2,"0");return`${r.getFullYear()}-${l}-${g}`}function z(r){if(!r)return"";const l=r.match(/\b(\d{2}):(\d{2})/);return l?`${l[1]}:${l[2]}`:""}function J(r){return{tracking:r,date_creation:null,id_situation:null,id_win:null,nom_complet:null,mobile:null,commune:null,id_wilaya:null,article:null,quantite:null,total:null,note_fournisseur:null,stopdesk:null,id_externe:null,adresse:null,numero_sav:null,fournisseur:null,id_transport:null,id_bureau_attache:null,date_action_d:null,date_action_hd:null,date_sorti:null,id_bureau_depart:null,nom_bureau:null,date_reception:null,echange:null}}function re(){var w,C;const{transporteur:r,agentName:l}=Q(),{colors:g}=R(),[o,S]=a.useState(x()),[d,E]=a.useState(x()),[$]=a.useState(0),[c,p]=a.useState([]),[_,y]=a.useState(null),[M,h]=a.useState(!1),[f,u]=a.useState(!1),[L,b]=a.useState(null),[s,N]=a.useState(null),[v,k]=a.useState(null),i=K({queryKey:["admin-encaissement-lignes",s==null?void 0:s.id_encaissement],queryFn:()=>G(s==null?void 0:s.id_encaissement),enabled:(s==null?void 0:s.id_encaissement)!=null});a.useEffect(()=>{let e=!1;return u(!0),b(null),p([]),y(null),h(!1),D({date_debut:o,date_fin:d,limit:100}).then(n=>{e||(p(n.items),h(n.a_suivant),y(n.dernier_id))}).catch(n=>{e||b(n instanceof j?n.message:"Erreur de chargement.")}).finally(()=>{e||u(!1)}),()=>{e=!0}},[o,d,$]);async function T(){if(_!=null){u(!0);try{const e=await D({date_debut:o,date_fin:d,limit:100,apres_id:_});p(n=>[...n,...e.items]),h(e.a_suivant),y(e.dernier_id)}catch(e){b(e instanceof j?e.message:"Erreur de chargement.")}finally{u(!1)}}}const q=c.reduce((e,n)=>e+(n.montant??0),0),F=c.reduce((e,n)=>e+(n.colis??0),0),H=[{key:"date",header:"Date",render:e=>{const n=z(e.date);return t.jsxs("div",{className:"flex items-center gap-2 leading-tight",children:[t.jsx("span",{className:"text-gray-800",children:V(e.date_d??e.date)}),n&&t.jsx("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-xs font-semibold text-gray-600",children:n})]})}},{key:"agent",header:"Agent",render:e=>l(e.id_utilisateur)??"—"},{key:"wilaya",header:"Wilaya",render:e=>e.id_wilaya!=null?t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"shrink-0 rounded bg-blue-100 px-2 py-0.5 text-sm font-bold text-blue-700",children:e.id_wilaya}),t.jsx("span",{children:B(e.id_wilaya)})]}):t.jsx("span",{className:"text-gray-400",children:"—"})},{key:"livreur",header:"Livreur",render:e=>{const n=e.id_transport!=null?r(e.id_transport):null,A=(n==null?void 0:n.nom)??(e.id_transport!=null?`#${e.id_transport}`:null);return A?t.jsx("span",{className:"inline-block whitespace-nowrap rounded-full px-2.5 py-0.5 text-xs font-semibold text-white",style:{backgroundColor:g.primary},children:A}):t.jsx("span",{className:"text-gray-400",children:"—"})}},{key:"colis",header:"Colis",align:"center",render:e=>t.jsx("span",{className:"font-semibold",children:e.colis??0})},{key:"montant",header:"Montant",align:"right",render:e=>t.jsxs("span",{className:"font-semibold text-gray-900",children:[m(e.montant)," DA"]})},{key:"detail",header:"",align:"right",render:e=>t.jsx("button",{type:"button",onClick:()=>N(e),className:"rounded-md border border-gray-300 px-2.5 py-1 text-xs font-medium text-gray-700 transition hover:bg-gray-50",children:"Détail"})}];return t.jsxs("div",{className:"space-y-4",children:[t.jsx(O,{icon:t.jsx(W,{}),label:"Liste des Encaissements"}),t.jsxs("div",{className:"flex flex-wrap items-end gap-3 rounded-lg border border-gray-200 bg-white px-4 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs font-medium text-gray-500",children:"Du"}),t.jsx("input",{type:"date",value:o,onChange:e=>S(e.target.value||x()),className:"rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs font-medium text-gray-500",children:"Au"}),t.jsx("input",{type:"date",value:d,onChange:e=>E(e.target.value||x()),className:"rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20"})]}),c.length>0&&t.jsxs("div",{className:"ml-auto flex items-center gap-3 self-center border-l border-gray-200 pl-4",children:[t.jsxs("span",{className:"rounded-lg bg-yellow-200 px-4 py-2 text-base font-bold text-gray-800",children:["Total colis : ",F]}),t.jsxs("span",{className:"rounded-lg bg-yellow-200 px-4 py-2 text-base font-bold text-gray-800",children:["Total montant : ",m(q)," DA"]})]})]}),t.jsx(P,{columns:H,rows:c,rowKey:(e,n)=>e.id_encaissement??`e-${n}`,loading:f,error:L,emptyLabel:"Aucun encaissement",emptySubLabel:"Aucun encaissement pour cette période."}),M&&t.jsx("div",{className:"flex justify-center",children:t.jsx("button",{type:"button",onClick:T,disabled:f,className:"rounded-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-50 disabled:opacity-60",children:f?"Chargement…":"Charger plus"})}),t.jsx(Y,{open:s!=null,onClose:()=>N(null),title:s?`Encaissement — ${m(s.montant)} DA · ${s.colis??0} colis`:"Détail encaissement",maxWidth:"max-w-2xl",children:i.isPending?t.jsx("p",{className:"py-6 text-center text-sm text-gray-400",children:"Chargement…"}):i.error?t.jsx("p",{className:"py-6 text-center text-sm text-red-500",children:i.error instanceof j?i.error.message:"Erreur de chargement."}):(((w=i.data)==null?void 0:w.length)??0)===0?t.jsx("p",{className:"py-6 text-center text-sm text-gray-400",children:"Aucun colis."}):t.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-100",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 bg-gray-50 text-left text-gray-500",children:[t.jsx("th",{className:"px-3 py-2 font-medium",children:"#"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Tracking"}),t.jsx("th",{className:"px-3 py-2 text-right font-medium",children:"Tarif livreur"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-50",children:(C=i.data)==null?void 0:C.map((e,n)=>t.jsxs("tr",{className:"hover:bg-gray-50",children:[t.jsx("td",{className:"px-3 py-2 text-gray-400",children:n+1}),t.jsx("td",{className:"px-3 py-2",children:e.tracking?t.jsx("button",{type:"button",onClick:()=>k(J(e.tracking)),title:"Voir l’historique",className:"font-medium text-primary underline-offset-2 transition hover:underline",children:e.tracking}):t.jsx("span",{className:"font-medium text-gray-800",children:"—"})}),t.jsxs("td",{className:"px-3 py-2 text-right font-semibold text-gray-900",children:[m(e.tarif_livreur)," DA"]})]},e.id_encaissement_ligne??`${e.tracking}-${n}`))})]})})}),v&&t.jsx(I,{colis:v,onClose:()=>k(null)})]})}export{re as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.