import{j as e,al as H,ak as R,B as K}from"./mui-vendor-CkIVaoQP.js";import{r as a}from"./react-vendor-CmFgShSM.js";import{u as Q}from"./redux-vendor-B7uoacJt.js";import{p as Y,_ as Z,G as p,S as T,X as d,L,j as _,h as f}from"./index-Cr86_nOs.js";import{R as m}from"./index.esm-Bu7XMDZU.js";import{R as uu}from"./ResponsiveTable-Dua7tTwQ.js";const ru=()=>{const[t,i]=a.useState([]),[v,G]=a.useState(0),[r,N]=a.useState(10),[h,k]=a.useState(""),[c,A]=a.useState(1),[z,B]=a.useState([]),[g,M]=a.useState([]),[C,O]=a.useState(""),o=Q(),V=async()=>{try{o(L());const s=await _.get(`/get_all_pos_company/?role=${d()}`);M(s.data),o(f())}catch(s){console.error("Error fetching companies:",s),o(f())}},l=async s=>{let u;o(L());let n=`report-pos-device_session/?search=filter&value=${h}&role=${d()}&page=${s}&page_size=${r}`;C&&(n+=`&company=${C}`),u=await _.get(n),o(f()),i(u.data.results),G(u.data.count)},W=s=>{l(s),A(s)},J=s=>{N(s),A(1)},U=s=>{k(s.target.value)};a.useEffect(()=>{const s=t==null?void 0:t.map((u,n)=>{var x,y,S,j,I,b,D,E,F,P,$,w;return[c===1?n+1:n+r*(c-1)+1,(x=u==null?void 0:u.pos)==null?void 0:x.posCompany,`${(S=(y=u==null?void 0:u.pos)==null?void 0:y.userInfo)==null?void 0:S.type} (${(I=(j=u==null?void 0:u.pos)==null?void 0:j.userInfo)==null?void 0:I.name})`,`${(D=(b=u==null?void 0:u.pos)==null?void 0:b.userInfo)==null?void 0:D.fullname} (${(F=(E=u==null?void 0:u.pos)==null?void 0:E.userInfo)==null?void 0:F.mobile})`,($=(P=u==null?void 0:u.pos)==null?void 0:P.userInfo)==null?void 0:$.nationalCode,(w=u==null?void 0:u.pos)==null?void 0:w.posId,u==null?void 0:u.password,u==null?void 0:u.name,Y(u==null?void 0:u.sessionCreateDate),Z(u==null?void 0:u.sessionLastSeenDate),u!=null&&u.active?"فعال":"غیرفعال"]});B(s)},[t]),a.useEffect(()=>{V(),l(1)},[o]),a.useEffect(()=>{l(c)},[C,r]);const X=async s=>{s.preventDefault(),l(1)},q=e.jsx(p,{container:!0,alignItems:"center",justifyContent:"space-between",gap:2,mb:1,padding:2,width:"100%",children:e.jsxs(p,{container:!0,width:"100%",alignItems:"center",justifyContent:"start",gap:T.SMALL,children:[d()!=="PosCompany"&&e.jsx(H,{size:"small",style:{minWidth:210},disablePortal:!0,id:"session",options:g?g.map(s=>({data:s,label:`${s==null?void 0:s.name}`})):[],onChange:(s,u)=>{var n;O((n=u==null?void 0:u.data)==null?void 0:n.key)},renderInput:s=>e.jsx(R,{fullWidth:!0,...s,label:"انتخاب شرکت psp"})}),e.jsxs(p,{container:!0,alignItems:"center",gap:T.SMALL,children:[e.jsx(R,{size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},value:h,onChange:U}),e.jsx(K,{type:"submit",onClick:X,endIcon:e.jsx(m,{}),children:"جستجو"})]})]})});return e.jsxs(p,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[q,e.jsx(uu,{data:z,columns:["ردیف","شرکت پرداختی","نام واحد","نام شخص","کدملی","کلید اتصال","کلمه عبور امنیتی","نام دستگاه","اولین ورود","آخرین بازدید","وضعیت"],handlePageChange:W,totalRows:v,page:c,perPage:r,handlePerRowsChange:J,title:"نشست های فعال"})]})};export{ru as P};
