2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
|
|
import{j as r,ao as K,an as D,B as P,b as Y,I as Z,b3 as v,aq as uu,ar as ru,at as G,b8 as eu,b7 as tu,as as su,T as W,aD as U}from"./mui-vendor-D_SVL-Dx.js";import{r as o}from"./react-vendor-CmFgShSM.js";import{u as M}from"./redux-vendor-CfkcHgWN.js";import{p as au,G as _,S as k,a0 as R,A as q,L as J,j as z,h as V,W as H,O as nu,C as ou}from"./index-D80MdVQn.js";import{R as lu}from"./index.esm-C1-dCPnj.js";import{R as cu}from"./ResponsiveTable-bUYl0qDM.js";import{d as iu}from"./Tune-BBzxV8DK.js";import{d as Cu}from"./PersonAddAlt1Rounded--1IUMwiN.js";import{d as pu,a as hu}from"./AddRounded-_nD2OARX.js";import{B as Au}from"./BackButton-Dr-K0JXJ.js";import"./FilterAlt-DZsHj-WQ.js";import"./styled-components.browser.esm-gS9mh05b.js";const Iu=()=>{const[u,x]=o.useState([]),[T,i]=o.useState(0),[g,m]=o.useState(10),[C,w]=o.useState(""),[h,S]=o.useState(1),[y,I]=o.useState([]),[B,p]=o.useState([]),[l,f]=o.useState(""),c=M(),b=async()=>{try{c(J());const e=await z.get(`/get_all_pos_company/?role=${R()}`);p(e.data),c(V())}catch(e){console.error("Error fetching companies:",e),c(V())}},A=async e=>{var t,j;try{c(J());let a=`/user-pos-machine/?search=filter&value=${C}&role=${R()}&page=${e}&page_size=${g}`;l&&(a+=`&company=${l}`);const E=await z.get(a);x(((t=E.data)==null?void 0:t.results)||[]),i(((j=E.data)==null?void 0:j.count)||0)}catch(a){console.error("Error fetching devices:",a)}finally{c(V())}},O=e=>{A(e),S(e)},L=e=>{m(e),S(1)},N=e=>{w(e.target.value)};o.useEffect(()=>{const e=u==null?void 0:u.map((t,j)=>{const a=(t==null?void 0:t.owner)||{},E=(t==null?void 0:t.pos_company)||{},$=!!(t!=null&&t.owner);return[h===1?j+1:j+g*(h-1)+1,(E==null?void 0:E.name)||"-",(t==null?void 0:t.serial)??"-",(t==null?void 0:t.receiverNumber)??"-",(t==null?void 0:t.terminalNumber)??"-",(t==null?void 0:t.password)??"-",(t==null?void 0:t.posUniqueId)||(t==null?void 0:t.posId)||"-",a!=null&&a.fullname?`${a==null?void 0:a.fullname} (${(a==null?void 0:a.mobile)??"-"})`:"-",(a==null?void 0:a.nationalId)||(a==null?void 0:a.nationalCode)||"-",t!=null&&t.createDate?au(t==null?void 0:t.createDate):"-",t!=null&&t.active?"فعال":"غیرفعال",r.jsx(mu,{device:t,hasOwner:$,onOwnerAssigned:()=>{A(h)}},(t==null?void 0:t.id)||(t==null?void 0:t.key)||`device-${j}`)]});I(e)},[u,h,g]),o.useEffect(()=>{b()},[c]),o.useEffect(()=>{A(h)},[l,g]);const s=async e=>{e.preventDefault(),A(1)},n=()=>{S(1),A(1)},F=()=>{const e=window.innerWidth<=600;c(H({title:"ایجاد دستگاه",right:!e,bottom:e,content:r.jsx(fu,{onSuccess:n})}))},d=r.jsx(_,{container:!0,alignItems:"center",justifyContent:"space-between",gap:2,mb:1,padding:2,width:"100%",children:r.jsxs(_,{container:!0,width:"100%",alignItems:"center",justifyContent:"space-between",gap:k.SMALL,children:[r.jsxs(_,{container:!0,alignItems:"center",gap:k.SMALL,xs:12,md:"auto",children:[R()!=="PosCompany"&&r.jsx(K,{size:"small",style:{minWidth:210},disablePortal:!0,id:"session",options:Array.isArray(B)?B.map(e=>({data:e,label:`${(e==null?void 0:e.name)||""}`})):[],onChange:(e,t)=>{var j;f((j=t==null?void 0:t.data)==null?void 0:j.key)},renderInput:e=>r.jsx(D,{fullWidth:!0,...e,label:"انتخاب شرکت psp"})}),r.jsxs(_,{container:!0,alignItems:"center",gap:k.SMALL,children:[r.jsx(D,{size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},value:C,onChange:N}),r.jsx(P,{type:"submit",onClick:s,endIcon:r.jsx(lu,{}),children:"جستجو"})]})]}),r.jsx(_,{container:!0,justifyContent:"flex-end",xs:12,md:"auto",children:r.jsx(P,{variant:"contained",startIcon:r.jsx(pu,{}),onClick:F,children:"ایجاد دستگاه"})})]})});return r.jsx(Y,{display:"flex",justifyContent:"center",children:r.jsxs(_,{container:!0,xs:12,lg:10,children:[r.jsx(Au,{}),d,r.jsx(cu,{data:y,columns:["ردیف","شرکت پرداختی","شماره سریال","شماره پذیرنده","شماره ترمینال","کلمه عبور امنیتی","کلید پوز","مالک","کدملی","تاریخ ایجاد","فعال / غیرفعال","عملیات"],handlePageChange:O,totalRows:T,page:h,perPage:g,handlePerRowsChang
|