1import{r,c as E,l as A,a6 as O,aH as h,b as _,g as D,j as e,t as k,w as B,x as M,z as P,v as U,B as H}from"./index-CcMLSBG6.js";import{A as R}from"./AdminLayout-BvLDTXmd.js";import{T as F,a as q,b as d,c,d as z,e as n}from"./table-CXHEOFRj.js";import{B as $}from"./badge-Dneubc8N.js";import{I as G}from"./input-6C8gsjbZ.js";import{C as J}from"./CustomerDetailsDialog-wa36tUer.js";import{L as K}from"./loader-circle-DrqN3EDc.js";import{C as Q}from"./clipboard-copy-D5jqthHi.js";import{f as V}from"./format-VPFD4RGU.js";import"./calendar-70KlfpAC.js";import"./video-CeYomunc.js";import"./chart-no-axes-column-D2swLHl6.js";import"./ticket-CZJGnvk2.js";import"./bell-BY-kgHnA.js";import"./tabs-3XcCUx4u.js";function me(){const[v,w]=r.useState([]),[m,y]=r.useState(""),[I,x]=r.useState(!0),[l,f]=r.useState(null),[N,p]=r.useState(!1),j=E(),g=A(),o=r.useMemo(()=>new URLSearchParams(j.search),[j.search]),s=r.useMemo(()=>({customerEmail:o.get("openCustomerEmail")||o.get("opencustomeremail"),customerId:o.get("customerId")||o.get("customerid"),applicationId:o.get("openApplication")||o.get("openapplication"),tabToOpen:o.get("openTab")||o.get("opentab")}),[o]),C=r.useCallback(async()=>{x(!0);try{const a=await O.User.list("-created_date");return w(a),a}catch(a){return console.error("Failed to fetch users:",a),h({title:"ש××××",description:"×× × ××ª× ××× ×××¢×× ×ת רש××ת ××שת×ש××.",variant:"destructive"}),[]}finally{x(!1)}},[]),b=r.useCallback(async a=>{let i=s.customerId?a.find(t=>t.id===s.customerId):s.customerEmail?a.find(t=>t.email===s.customerEmail):null;if(!i&&s.applicationId)try{const t=await _.entities.MortgageApplication.get(s.applicationId);t!=null&&t.user_id&&(i=a.find(u=>u.id===t.user_id)),!i&&(t!=null&&t.email)&&(i=a.find(u=>u.email===t.email))}catch(t){console.error("Failed to find user by application_id",t)}i?(f(i),p(!0),setTimeout(()=>{g(D("AdminCustomers"),{replace:!0})},500)):(s.customerEmail||s.customerId||s.applicationId)&&h({title:"ש××××",description:"×× × ××¦× ××§×× ×ת×××",variant:"destructive"})},[s,g]);r.useEffect(()=>{C().then(a=>{b(a)})},[C,b]);const L=a=>{navigator.clipboard.writeText(a),h({title:"××עתק ××××",description:"××××× ××עתק ××צ×××."})},S=a=>{f(a),p(!0)},T=v.filter(a=>{var i,t;return(((i=a.full_name)==null?void 0:i.toLowerCase())||"").includes(m.toLowerCase())||(((t=a.email)==null?void 0:t.toLowerCase())||"").includes(m.toLowerCase())});return e.jsxs(R,{children:[e.jsxs(k,{children:[e.jsxs(B,{children:[e.jsx(M,{children:"× ×××× ××§×××ת"}),e.jsx(P,{children:"צפ××× ×× ×××× ×× ××שת×ש×× ×רש×××× ××ער×ת."}),e.jsx(G,{placeholder:"××פ×ש ××¤× ×©× ×× ××××××...",value:m,onChange:a=>y(a.target.value),className:"max-w-sm"})]}),e.jsx(U,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(F,{children:[e.jsx(q,{children:e.jsxs(d,{children:[e.jsx(c,{children:"×××× ×שת×ש"}),e.jsx(c,{children:"×©× ×××"}),e.jsx(c,{children:"××××××"}),e.jsx(c,{children:"תפק××"}),e.jsx(c,{children:"ת×ר×× ×רש××"})]})}),e.jsx(z,{children:I?e.jsx(d,{children:e.jsx(n,{colSpan:"5",className:"h-24 text-center",children:e.jsx(K,{className:"mx-auto h-6 w-6 animate-spin"})})}):T.length>0?T.map(a=>e.jsxs(d,{onClick:()=>S(a),className:`cursor-pointer ${(l==null?void 0:l.id)===a.id?"bg-blue-50":"hover:bg-gray-50"}`,children:[e.jsx(n,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-mono text-xs",children:[a.id.substring(0,8),"..."]}),e.jsx(H,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:i=>{i.stopPropagation(),L(a.id)},children:e.jsx(Q,{className:"h-4 w-4"})})]})}),e.jsx(n,{className:"font-medium",children:a.full_name||"×× ××××"}),e.jsx(n,{className:"text-left",dir:"ltr",children:a.email}),e.jsx(n,{children:e.jsx($,{variant:a.role==="admin"?"destructive":"secondary",children:a.role})}),e.jsx(n,{children:a.created_date?V(new Date(a.created_date),"dd/MM/yyyy"):"N/A"})]},a.id)):e.jsx(d,{children:e.jsx(n,{colSpan:"5",className:"h-24 text-center",children:"×× × ×צ×× ×שת×ש××."})})})]})})})]}),l&&e.jsx(J,{customer:l,isOpen:N,onClose:()=>p(!1),defaultTab:s.tabToOpen||(s.applicationId?"requests":"info"),openApplicationId:s.applicationId})]})}export{me 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.