1import{j as e,C as b,l as y,ef as S,aA as U,w as O,_ as E,P as I,a0 as R,B as m,b as T,u as B,v as F,aC as Q,r as c,b5 as w,as as p,an as C,a6 as z,I as M,aM as $,aO as G,aP as H,aQ as q,aR as J,aS as K,aT as V,aU as W}from"./bootstrap-8tA2eVIJ.js";import{u as X,C as Y}from"./CreateSupplierDialog-grcCSHjv.js";import{U as Z}from"./user-Drcsb5Lf.js";import{P as ee}from"./pencil-BRaamPQg.js";import{T as se}from"./trash-2-Cf3va1DF.js";import"./index-nqOXwV_7.js";import"./textarea-ChgbT1SS.js";const ae=({supplier:a,productCount:n=0,onEdit:i,onDelete:l,onClick:x,showActions:h=!0})=>e.jsx(b,{className:"overflow-hidden group hover:shadow-lg transition-all cursor-pointer",onClick:x,children:e.jsxs(y,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx(S,{className:"w-6 h-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground",children:a.name}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(U,{className:"w-3 h-3"}),e.jsxs("span",{children:[n," ××צר××"]})]})]})]}),e.jsx(O,{variant:a.is_global?"secondary":"outline",className:"flex items-center gap-1",children:a.is_global?e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"w-3 h-3"}),"×§×××ת×"]}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-3 h-3"}),"××ש×"]})})]}),e.jsxs("div",{className:"space-y-1",children:[a.phone_number&&e.jsxs("a",{href:`tel:${a.phone_number}`,className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-primary transition-colors",onClick:r=>r.stopPropagation(),children:[e.jsx(I,{className:"w-4 h-4"}),e.jsx("span",{dir:"ltr",children:a.phone_number})]}),a.website_url&&e.jsxs("a",{href:a.website_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-primary transition-colors truncate",onClick:r=>r.stopPropagation(),children:[e.jsx(R,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{className:"truncate",dir:"ltr",children:a.website_url})]})]}),a.notes&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:a.notes}),h&&(i||l)&&e.jsxs("div",{className:"flex gap-2 pt-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[i&&e.jsx(m,{size:"sm",variant:"outline",onClick:r=>{r.stopPropagation(),i()},children:e.jsx(ee,{className:"w-4 h-4"})}),l&&e.jsx(m,{size:"sm",variant:"destructive",onClick:r=>{r.stopPropagation(),l()},children:e.jsx(se,{className:"w-4 h-4"})})]})]})}),de=()=>{const a=T(),[n,i]=B(),{user:l,loading:x}=F(),{isAdmin:h}=Q(),{suppliers:r,supplierCounts:_,isLoading:A,deleteSupplier:P}=X(),j=s=>s.is_global?h:s.user_id===(l==null?void 0:l.id),[o,D]=c.useState(""),[k,d]=c.useState(!1),[f,N]=c.useState(null),[u,g]=c.useState(null);if(c.useEffect(()=>{if(!(n.get("create")==="1"||n.get("newSupplier")==="1"||n.get("ce_new_supplier")==="1"))return;d(!0);const t=new URLSearchParams(n);t.delete("create"),t.delete("newSupplier"),t.delete("ce_new_supplier"),i(t,{replace:!0})},[n,i]),x)return e.jsx(w,{children:e.jsxs("div",{className:"p-6",children:[e.jsx(p,{className:"h-8 w-48 mb-6"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((s,t)=>e.jsx(p,{className:"h-40"},t))})]})});if(!l)return a("/auth"),null;const v=r.filter(s=>{var t;return s.name.toLowerCase().includes(o.toLowerCase())||((t=s.notes)==null?void 0:t.toLowerCase().includes(o.toLowerCase()))}),L=async()=>{u&&(await P.mutateAsync(u),g(null))};return e.jsxs(w,{children:[e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"ספק××"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"× ×××× ×¡×¤×§×× ××§×ש×ר ×××צר××"})]}),e.jsxs(m,{onClick:()=>d(!0),className:"gap-2",children:[e.jsx(C,{className:"w-4 h-4"}),"××סף ספק"]})]}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(z,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(M,{placeholder:"××פ×ש ספק××...",value:o,onChange:s=>D(s.target.value),className:"pr-10"})]}),A?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((s,t)=>e.jsx(p,{className:"h-40"},t))}):v.length===0?e.jsx(b,{className:"border-dashed",children:e.jsxs(y,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(S,{className:"w-12 h-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:o?"×× × ×צ×× ×¡×¤×§×× ×ª×××××":"××× ×¡×¤×§×× ×¢××××"}),e.jsxs(m,{onClick:()=>d(!0),variant:"outline",className:"gap-2",children:[e.jsx(C,{className:"w-4 h-4"}),"××סף ספק ר×ש××"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:v.map(s=>
1e.jsx(ae,{supplier:s,productCount:_[s.id]||0,onClick:()=>a(`/suppliers/${s.id}`),onEdit:j(s)?()=>N(s):void 0,onDelete:j(s)?()=>g(s.id):void 0},s.id))})]}),e.jsx(Y,{open:k||!!f,onOpenChange:s=>{s||(d(!1),N(null))},editSupplier:f}),e.jsx($,{open:!!u,onOpenChange:s=>!s&&g(null),children:e.jsxs(G,{children:[e.jsxs(H,{children:[e.jsx(q,{children:"×××קת ספק"}),e.jsx(J,{children:"××× ××ª× ×××× ×©×רצ×× × ×××××§ ספק ××? ×פע××× ××× × ×פ×××. ×××צר×× ×©××§×שר×× ×ספק ×× ×××××§×, ××× ××§×ש×ר ×ספק ××סר."})]}),e.jsxs(K,{children:[e.jsx(V,{children:"×××××"}),e.jsx(W,{onClick:L,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"×××§"})]})]})})]})};export{de 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.