2 lines
8.7 KiB
JavaScript
2 lines
8.7 KiB
JavaScript
import{j as r,T as P,b as V,bs as K,P as S,an as uu,B as D,d as eu}from"./mui-vendor-D_SVL-Dx.js";import{G as s,S as h,a0 as $,O as ru,j as au,L as su,h as nu,n5 as tu}from"./index-D80MdVQn.js";import{r as t,f as ou}from"./react-vendor-CmFgShSM.js";import{R as lu,a as cu}from"./index.esm-C1-dCPnj.js";import{u as du,f as pu}from"./redux-vendor-CfkcHgWN.js";import{M as J,p as M}from"./ManageGuildsOperations-Y6lK_GEz.js";import{C as Cu}from"./CreateGuilds-DgFk5FAd.js";import{P as fu}from"./PageTable-B0hPU2Kw.js";import"./checkPathStartsWith-DedybDvj.js";import"./Visibility-Cb7r65bM.js";import"./CheckCircle-DhdOmw2t.js";import"./Send-BBQc1q74.js";import"./Person-PsPK2YrR.js";import"./Business-C5WNOK1n.js";import"./Phone-DO6stZ0w.js";import"./Cake-B9u2Frdy.js";import"./Tune-BBzxV8DK.js";import"./city-get-city-Cof5ivkn.js";import"./LabelField-BYhJrYEE.js";import"./DialogAlert-CML4Ua46.js";import"./styled-components.browser.esm-gS9mh05b.js";const q=({columns:n,data:o,ignore:i,paginated:A,name:c})=>{const L=Math.ceil((o==null?void 0:o.length)/2),[l,F]=t.useState(1);function w(p){return i==null?void 0:i.includes(p)}const x=(l-1)*2,O=x+2,d=A?o.slice(x,O):o;return r.jsxs(r.Fragment,{children:[r.jsxs(s,{container:!0,xs:12,mb:h.SMALL,spacing:1,justifyContent:"space-between",children:[c&&r.jsx(P,{m:2,xs:12,variant:"body2",children:c}),!o.length&&r.jsx(s,{xs:12,display:"grid",justifyContent:"center",mt:4,children:r.jsx(P,{xs:12,variant:"body1",color:"error",children:"موردی وجود ندارد!"})}),d.map((p,g)=>{let C=0;return r.jsx(s,{xs:o.length===1?12:6,children:r.jsx(V,{display:"flex",flexDirection:"column",border:1,borderRadius:3,children:p.map((T,f)=>{var v;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(P,{sx:{fontSize:((v=n[f])==null?void 0:v.length)<=15?13:10},children:`${n[f]}`})}),r.jsx(s,{item:!0,xs:7,style:{fontSize:12,width:"100%"},children:T})]},f)})})},g)})]}),A&&r.jsx(s,{container:!0,mb:h.SMALL,justifyContent:"center",children:r.jsx(K,{count:L,page:l,variant:"outlined",onChange:(p,g)=>F(g)})})]})};q.propTypes={columns:S.any,data:S.any,ignore:S.array,paginated:S.any};const hu=()=>{const n=du(),[o,i]=t.useState([]),A=pu(u=>u.userSlice.userProfile.key),[c,b]=t.useState([]),[L,l]=t.useState(!1),[F,w]=t.useState(0),[x,O]=t.useState(10),[d,p]=t.useState(""),g=u=>{p(u.target.value)},C=async(u,e)=>{l(!0);const a=await n(M({steward:!0,search:"filter",value:e,page:u,page_size:x}));b(a.data.results),w(a.data.count),l(!1)},T=u=>{C(u,d)},f=async(u,e)=>{l(!0);const a=await n(M({steward:!0,search:"filter",value:d,page:e,page_size:x}));b(a.data.results),w(a.data.count),O(u),l(!1),n(nu())},[v,Q]=t.useState(0),X=(u,e)=>{n(su()),Q(e),C(e+1,d)};t.useEffect(()=>{C(1)},[]);const E=()=>{C(1)},I=[{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,j;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}/${(j=u==null?void 0:u.address)==null?void 0:j.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,{item: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 n(M({steward:!0,search:"filter",value:d}));b(e.data.results),w(e.data.count)}catch(e){console.error("Error fetching data:",e)}finally{l(!1)}};$()==="CityJahad"&&I.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};t.useEffect(()=>{const u=c==null?void 0:c.map((e,a)=>{var j,N,_,k,z,B,W,U,H;return[e.guildsId,e==null?void 0:e.guildsName,`${(j=e==null?void 0:e.user)==null?void 0:j.fullname} (${(N=e==null?void 0:e.user)==null?void 0:N.mobile})`,(_=e==null?void 0:e.user)==null?void 0:_.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(y=>y.label).join(" - "),(H=e==null?void 0:e.killHouseInfo)==null?void 0:H.map(y=>`${y.name} (${y.mobile})`).join(" - "),Y(e),r.jsx(J,{item:e},a+(e==null?void 0:e.guildsId))]});i(u)},[c]);const Z=I.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:h.SMALL,children:[r.jsx("form",{onSubmit:G,children:r.jsxs(s,{container:!0,alignItems:"center",gap:h.SMALL,children:[r.jsx(P,{children:"مدیریت اصناف"}),r.jsx(uu,{size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},onChange:g}),r.jsx(D,{type:"submit",onClick:G,endIcon:r.jsx(lu,{}),children:"جستجو"})]})}),r.jsxs(s,{children:[$()!=="CityJahad"&&r.jsx(D,{variant:"contained",onClick:()=>{n(ru({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,size:window.innerWidth<=600?"small":"auto",title:"ثبت واحد جدید",content:r.jsx(Cu,{updateTable:E})}))},children:"ثبت واحد جدید"}),r.jsx(eu,{title:"خروجی اکسل",children:r.jsx("a",{href:`${au.defaults.baseURL}guilds_excel/?key=${A}&role=${$()}&search=filter&value=${d}`,rel:"noreferrer",children:r.jsx(D,{color:"success",children:r.jsx(cu,{size:32})})})})]})]})});return r.jsx(s,{children:m?r.jsxs(s,{container:!0,justifyContent:"center",gap:h.SMALL,children:[R,r.jsx(q,{columns:Z,data:o}),r.jsx(K,{count:Math.ceil(F/10),page:v+1,variant:"outlined",onChange:(u,e)=>{X(u,e-1)}})]}):r.jsx(fu,{title:R,columns:I,data:c,progressPending:L,pagination:!0,paginationServer:!0,paginationTotalRows:F,onChangeRowsPerPage:f,onChangePage:T})})},Ru=()=>{const{pathname:n}=ou();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:h.SMALL,children:r.jsx(s,{xs:12,children:n===tu&&r.jsx(hu,{})})})})})})};export{Ru as default};
|