1import{u as j,j as e}from"./query-vendor-BRmJJ5qy.js";import{r as n}from"./react-vendor-BFRhVHEi.js";import{A as N,I as l,M as w,x as v,bD as C}from"./index-OYhlPsKp.js";import _ from"./ColisListeParWin-DpEloONi.js";import"./PageTitle-BU6cFTlv.js";import"./DataTable-CW46N8ZB.js";import"./CursorPagination-Dp6JRBKB.js";import"./scroll-DlR_Zrco.js";import"./GestionnairePrintModal-Dv7Htig-.js";import"./AdminHistoriqueModal-BBvJWkRI.js";import"./ColisDetailDemo-CqWNX1-t.js";import"./CountUp-CjQqcrFJ.js";import"./adminColisColumns-DyP-vs0h.js";import"./winLabels-D3iB8_Nu.js";function z(){const[s,x]=n.useState(null),[h,o]=n.useState(!0),[c,m]=n.useState(""),{data:t,isPending:y,error:a}=j({queryKey:["retours-a-recuperer"],queryFn:C}),d=a?a instanceof N?a.message:"Erreur de chargement.":null,u=(t==null?void 0:t.items)??[],i=c.trim().toLowerCase(),p=n.useMemo(()=>(i?u.filter(r=>(r.nom??"").toLowerCase().includes(i)||String(r.id_fournisseur).includes(i)):u).filter(r=>r.id_fournisseur!=null),[u,i]);function g(r,f,b){x({id:r,nom:f,nb:b}),o(!1),m("")}return e.jsxs("div",{className:"space-y-4",children:[s?e.jsx(_,{wins:[],colisARecupererId:s.id,knownTotal:s.nb,title:`Colis à récupérer â ${s.nom}`,icon:e.jsx(l,{}),emptyLabel:"Aucun colis à récupérer",showArticle:!0,beforeFilter:e.jsxs("button",{type:"button",onClick:()=>o(!0),className:"inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-700 transition hover:bg-gray-50",children:[e.jsx(l,{className:"h-4 w-4"}),"Changer de fournisseur"]})},`ar-${s.id}`):e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-gray-300 px-6 py-16 text-center text-gray-400",children:[e.jsx(l,{className:"h-8 w-8"}),e.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Choisissez un fournisseur pour voir ses colis à récupérer."}),e.jsx("button",{type:"button",onClick:()=>o(!0),className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-white transition hover:bg-primary-hover",children:"Choisir un fournisseur"})]}),e.jsx(w,{open:h,onClose:()=>o(!1),title:t?`Colis à récupérer â ${t.total_fournisseurs} fournisseur(s), ${t.total_colis} colis`:"Colis à récupérer",maxWidth:"max-w-md",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(v,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{autoFocus:!0,value:c,onChange:r=>m(r.target.value),placeholder:"Rechercher un fournisseurâ¦",className:"w-full rounded-lg border border-gray-300 py-2 pl-9 pr-3 text-sm text-gray-900 outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20"})]}),e.jsx("div",{className:"max-h-80 overflow-y-auto rounded-lg border border-gray-100",children:y?e.jsx("p",{className:"py-6 text-center text-sm text-gray-400",children:"Chargementâ¦"}):d?e.jsx("p",{className:"py-6 text-center text-sm text-red-500",children:d}):p.length===0?e.jsx("p",{className:"py-6 text-center text-sm text-gray-400",children:"Aucun fournisseur."}):p.map(r=>e.jsxs("button",{type:"button",onClick:()=>g(r.id_fournisseur,r.nom??`Fournisseur ${r.id_fournisseur}`,r.nb),className:`flex w-full items-center justify-between gap-3 border-b border-gray-50 px-3 py-2.5 text-left transition hover:bg-gray-50 ${(s==null?void 0:s.id)===r.id_fournisseur?"bg-primary/5":""}`,children:[e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"truncate text-sm font-medium text-gray-800",children:r.nom??`Fournisseur ${r.id_fournisseur}`})}),e.jsxs("span",{className:"inline-block shrink-0 whitespace-nowrap rounded-md bg-primary px-2 py-0.5 text-xs font-semibold text-white",children:[r.nb," colis"]})]},r.id_fournisseur))})]})})]})}export{z 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.