2 lines
8.8 KiB
JavaScript
2 lines
8.8 KiB
JavaScript
import{j as r,T as L,b as V,bq as q,bs as S,ak as uu,B as M,d as eu}from"./mui-vendor-CkIVaoQP.js";import{G as s,S as i,X as P,O as ru,j as $,L as au,h as su,lQ as nu}from"./index-BHF9XhlR.js";import{r as n,f as tu}from"./react-vendor-CmFgShSM.js";import{R as lu,a as ou}from"./index.esm-Bu7XMDZU.js";import{u as cu,f as du}from"./redux-vendor-B7uoacJt.js";import{M as J}from"./ManageGuildsOperations-CZz1vBZR.js";import{C as pu}from"./CreateGuilds-CGqLB4_e.js";import{P as Cu}from"./PageTable-D1uSrR4N.js";import"./iconBase-BEJYyZsk.js";import"./Edit-DE-0ja3Q.js";import"./Visibility-DUYp8piW.js";import"./CheckCircle-DVOR8q2_.js";import"./Send-CtIh0AvH.js";import"./Person-C8Ow22r4.js";import"./Business-DVBtBWWh.js";import"./Phone-BRhOY7uM.js";import"./Badge-ed0frWuI.js";import"./Cake-DjDFXD3n.js";import"./Tune-rHyTJYQA.js";import"./Done-CXPGvgsL.js";import"./DialogAlert-DKhMdDI2.js";import"./LabelField-CY9emCr4.js";import"./styled-components.browser.esm-gS9mh05b.js";const K=({columns:o,data:t,ignore:h,paginated:j,name:c})=>{const O=Math.ceil((t==null?void 0:t.length)/2),[l,b]=n.useState(1);function w(p){return h==null?void 0:h.includes(p)}const F=(l-1)*2,I=F+2,d=j?t.slice(F,I):t;return r.jsxs(r.Fragment,{children:[r.jsxs(s,{container:!0,xs:12,mb:i.SMALL,spacing:1,justifyContent:"space-between",children:[c&&r.jsx(L,{m:2,xs:12,variant:"body2",children:c}),!t.length&&r.jsx(s,{xs:12,display:"grid",justifyContent:"center",mt:4,children:r.jsx(L,{xs:12,variant:"body1",color:"error",children:"موردی وجود ندارد!"})}),d.map((p,x)=>{let C=0;return r.jsx(s,{xs:t.length===1?12:6,children:r.jsx(V,{display:"flex",flexDirection:"column",border:1,borderRadius:3,children:p.map((T,f)=>{var y;return!w(f)&&r.jsxs(s,{alignItems:"center",justifyContent:"space-between",display:"flex",xs:12,sx:{backgroundColor:C++%2===0?"rgba(148,148,148,0.1)":"ffff"},children:[r.jsx(s,{item:!0,xs:5,children:r.jsx(L,{sx:{fontSize:((y=o[f])==null?void 0:y.length)<=15?13:10},children:`${o[f]}`})}),r.jsx(s,{item:!0,xs:7,style:{fontSize:12,width:"100%"},children:T})]},f)})})},x)})]}),j&&r.jsx(s,{container:!0,mb:i.SMALL,justifyContent:"center",children:r.jsx(q,{count:O,page:l,variant:"outlined",onChange:(p,x)=>b(x)})})]})};K.propTypes={columns:S.any,data:S.any,ignore:S.array,paginated:S.any};const fu=()=>{const o=cu(),[t,h]=n.useState([]),j=du(u=>u.userSlice.userProfile.key),[c,A]=n.useState([]),[O,l]=n.useState(!1),[b,w]=n.useState(0),[F,I]=n.useState(10),[d,p]=n.useState(""),x=u=>{p(u.target.value)},C=async(u,e)=>{l(!0);let a=await $.get(`total_guilds/?role=Guilds&steward=true&search=filter&value=${e}&page=${u}&page_size=${F}`);A(a.data.results),w(a.data.count),l(!1)},T=u=>{C(u,d)},f=async(u,e)=>{l(!0);let a=await $.get(`total_guilds/?role=Guilds&steward=true&search=filter&value=${d}&page=${e}&page_size=${u}`);A(a.data.results),w(a.data.count),I(u),l(!1),o(su())},[y,Q]=n.useState(0),X=(u,e)=>{o(au()),Q(e),C(e+1,d)};n.useEffect(()=>{C(1)},[]);const E=()=>{C(1)},D=[{name:"شناسه صنف",selector:u=>u.guildsId,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"نام واحد صنفی",selector:u=>u==null?void 0:u.guildsName,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"نام شخص/شرکت",selector:u=>{var e,a;return`${(e=u==null?void 0:u.user)==null?void 0:e.fullname} (${(a=u==null?void 0:u.user)==null?void 0:a.mobile})`},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"100px"},{name:"کدملی",selector:u=>{var e;return(e=u==null?void 0:u.user)==null?void 0:e.nationalId},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"100px"},{name:"نوع فعالیت",selector:u=>u==null?void 0:u.typeActivity,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"حوزه فعالیت",selector:u=>u==null?void 0:u.areaActivity,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"کدپستی",selector:u=>{var e;return(e=u==null?void 0:u.address)==null?void 0:e.postalCode},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"استان/شهر/آدرس",selector:u=>{var e,a,g;return`${(e=u==null?void 0:u.address)==null?void 0:e.province.name}/${(a=u==null?void 0:u.address)==null?void 0:a.city.name}/${(g=u==null?void 0:u.address)==null?void 0:g.address}`},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"مباشر",selector:u=>u!=null&&u.steward?"می باشد":"نمی باشد",sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"محدودیت تخصیص",selector:u=>u!=null&&u.limitationAllocation?"دارد":"ندارد",sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"حداکثر تخصیص",selector:u=>u==null?void 0:u.allocationLimit,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"مباشر",selector:u=>{var e;return(e=u==null?void 0:u.centersAllocation)==null?void 0:e.map(a=>a.label).join(" - ")},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"کشتارگاه",selector:u=>{var e;return(e=u==null?void 0:u.killHouseInfo)==null?void 0:e.map(a=>`${a.name} (${a.mobile})`).join(" - ")},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"وضعیت",selector:u=>{let e="";return(u==null?void 0:u.provinceAcceptState)==="accepted"?e="تایید شده":(u==null?void 0:u.provinceAcceptState)==="rejected"?e="رد شده":(u==null?void 0:u.provinceAcceptState)==="pending"&&(e="در انتظار تایید"),e},sortable:!0,wrap:!0,allowOverflow:!0,center:!0},{name:"عملیات",selector:(u,e)=>r.jsx(J,{guild:u,updateTable:E},e+(u==null?void 0:u.guildsId)),sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"110px"}],G=async u=>{u.preventDefault(),l(!0);try{const e=await $.get(`total_guilds/?role=${P()}&search=filter&value=${d}&steward=true`);A(e.data.results),w(e.data.count)}catch(e){console.error("Error fetching data:",e)}finally{l(!1)}};P()==="CityJahad"&&D.pop();const Y=u=>{let e="";return(u==null?void 0:u.provinceAcceptState)==="accepted"?e="تایید شده":(u==null?void 0:u.provinceAcceptState)==="rejected"?e="رد شده":(u==null?void 0:u.provinceAcceptState)==="pending"&&(e="در انتظار تایید"),e};n.useEffect(()=>{const u=c==null?void 0:c.map((e,a)=>{var g,_,N,k,z,B,W,U,H;return[e.guildsId,e==null?void 0:e.guildsName,`${(g=e==null?void 0:e.user)==null?void 0:g.fullname} (${(_=e==null?void 0:e.user)==null?void 0:_.mobile})`,(N=e==null?void 0:e.user)==null?void 0:N.nationalId,e==null?void 0:e.typeActivity,e==null?void 0:e.areaActivity,(k=e==null?void 0:e.address)==null?void 0:k.postalCode,`${(z=e==null?void 0:e.address)==null?void 0:z.province.name}/${(B=e==null?void 0:e.address)==null?void 0:B.city.name}/${(W=e==null?void 0:e.address)==null?void 0:W.address}`,e!=null&&e.steward?"می باشد":"نمی باشد",e!=null&&e.limitationAllocation?"دارد":"ندارد",e==null?void 0:e.allocationLimit,(U=e==null?void 0:e.centersAllocation)==null?void 0:U.map(v=>v.label).join(" - "),(H=e==null?void 0:e.killHouseInfo)==null?void 0:H.map(v=>`${v.name} (${v.mobile})`).join(" - "),Y(e),r.jsx(J,{guild:e},a+(e==null?void 0:e.guildsId))]});h(u)},[c]);const Z=D.map(u=>u.name),m=window.innerWidth<=600,R=r.jsx(s,{container:!0,alignItems:"center",justifyContent:"space-between",gap:2,paddingTop:2,mb:1,width:"100%",children:r.jsxs(s,{container:!0,width:"100%",alignItems:"center",justifyContent:"space-between",gap:i.SMALL,children:[r.jsx("form",{onSubmit:G,children:r.jsxs(s,{container:!0,alignItems:"center",gap:i.SMALL,children:[r.jsx(L,{children:"مدیریت اصناف"}),r.jsx(uu,{size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},onChange:x}),r.jsx(M,{type:"submit",onClick:G,endIcon:r.jsx(lu,{}),children:"جستجو"})]})}),r.jsxs(s,{children:[P()!=="CityJahad"&&r.jsx(M,{variant:"contained",onClick:()=>{o(ru({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,size:window.innerWidth<=600?"small":"auto",title:"ثبت واحد جدید",content:r.jsx(pu,{updateTable:E})}))},children:"ثبت واحد جدید"}),r.jsx(eu,{title:"خروجی اکسل",children:r.jsx("a",{href:`${$.defaults.baseURL}guilds_excel/?key=${j}&role=${P()}&search=filter&value=${d}`,rel:"noreferrer",children:r.jsx(M,{color:"success",children:r.jsx(ou,{size:32})})})})]})]})});return r.jsx(s,{children:m?r.jsxs(s,{container:!0,justifyContent:"center",gap:i.SMALL,children:[R,r.jsx(K,{columns:Z,data:t}),r.jsx(q,{count:Math.ceil(b/10),page:y+1,variant:"outlined",onChange:(u,e)=>{X(u,e-1)}})]}):r.jsx(Cu,{title:R,columns:D,data:c,progressPending:O,pagination:!0,paginationServer:!0,paginationTotalRows:b,onChangeRowsPerPage:f,onChangePage:T})})},_u=()=>{const{pathname:o}=tu();return r.jsx(r.Fragment,{children:r.jsx(V,{display:"flex",justifyContent:"center",children:r.jsx(s,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,children:r.jsx(s,{container:!0,justifyContent:"space-between",gap:i.SMALL,children:r.jsx(s,{xs:12,children:o===nu&&r.jsx(fu,{})})})})})})};export{_u as default};
|