Files
Rasadyar_FrontEnd/build/assets/Guilds-D4W1iArQ.js

2 lines
27 KiB
JavaScript

import{j as u,al as cu,a_ as j,an as L,ac as T0,ao as x0,T as au,B as N,d as Lu,I as k,b3 as h0,b8 as du,aA as iu,b as Nu}from"./mui-vendor-D_SVL-Dx.js";import{G as c,bf as pu,bg as Su,bh as Au,bi as Ru,bj as q,bk as K,bl as Z,bm as uu,bn as eu,bo as nu,bp as ru,bq as su,S as g,a0 as a,br as yu,bs as Du,bt as mu,bu as Mu,bv as bu,bw as Vu,bx as ku,by as wu,bz as zu,bA as Bu,bB as Wu,bC as Hu,bD as $u,bE as Xu,bF as Qu,bG as Yu,bH as Ju,bI as qu,bJ as Ku,bK as Zu,L as W,j as m,bL as Ou,h as y,A as Iu,u as u0,c as e0,W as n0,ah as v0,ad as w,bM as j0,bN as r0,bO as s0,bP as t0,bQ as o0,bR as l0,bS as c0,bT as a0,bU as i0,bV as _0,bW as C0,bX as E0,bY as Cu,bZ as Eu,C as Pu,b as _u,O as Fu,b_ as d0,b$ as p0,c0 as S0,c1 as A0,c2 as R0,c3 as P0,c4 as F0,c5 as G0,c6 as f0,c7 as L0,c8 as N0,c9 as y0,ca as D0,cb as m0,cc as M0,cd as b0}from"./index-D80MdVQn.js";import{B as O0}from"./BackButton-Dr-K0JXJ.js";import{N as I}from"./NavLink-Uri4Pz8C.js";import{L as U}from"./LinkItem-Din4toX7.js";import{c as h}from"./index.esm-D0kIaQoT.js";import{f as Uu,r as d}from"./react-vendor-CmFgShSM.js";import{a as V0,R as k0}from"./index.esm-C1-dCPnj.js";import{a as gu,f as tu,u as P}from"./redux-vendor-CfkcHgWN.js";import{d as w0}from"./Tune-BBzxV8DK.js";import{R as ou}from"./ResponsiveTable-bUYl0qDM.js";import{I as lu}from"./index.esm-D7rRcI8K.js";import{M as I0,a as z0,P as B0,b as W0,c as H0}from"./ProvinceLegalGuildsOutProvince-DyJ1xElp.js";import{p as z,a as B,P as Gu,b as $0}from"./ProvinceManageDistributionsSubmitCommitmentPercent-BGw_oUjf.js";import"./FilterAlt-DZsHj-WQ.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./Visibility-Cb7r65bM.js";import"./Check-DhP5SvVt.js";import"./Close-J1gH5PMD.js";import"./CheckCircle-DhdOmw2t.js";import"./Send-BBQc1q74.js";import"./CreateGuilds-DgFk5FAd.js";import"./city-get-city-Cof5ivkn.js";import"./Person-PsPK2YrR.js";import"./Phone-DO6stZ0w.js";import"./Cake-B9u2Frdy.js";import"./LabelField-BYhJrYEE.js";import"./DialogAlert-CML4Ua46.js";import"./Business-C5WNOK1n.js";import"./ManageGuildsOperations-Y6lK_GEz.js";import"./checkPathStartsWith-DedybDvj.js";import"./SimpleTable-tm4uaKUf.js";import"./index-Eu1ghc4Y.js";import"./Search-TgPAjvS8.js";import"./Delete-CIwpNviU.js";import"./address-DVSldlUX.js";import"./slaughter-get-provinces-D6etA0Tf.js";import"./slaughter-get-guilds-for-allocate-CQRKvxsV.js";const X0=()=>{const{pathname:n}=Uu();return u.jsxs(u.Fragment,{children:[u.jsx(O0,{}),u.jsxs(c,{container:!0,gap:g.SMALL,p:g.SMALL,direction:"row",justifyContent:"center",xs:12,children:[[pu,Su,Au,Ru].includes(n)&&u.jsxs(u.Fragment,{children:[u.jsx(I,{to:a()==="SuperAdmin"?q:a()==="AdminX"?K:a()==="KillHouse"?uu:a()==="ProvinceOperator"?Z:null,children:u.jsx(U,{icon:u.jsx(h,{size:30,color:"#244CCC"}),title:"اصناف داخل استان"})}),u.jsx(I,{to:a()==="SuperAdmin"?eu:a()==="AdminX"?nu:a()==="KillHouse"?su:a()==="ProvinceOperator"?ru:null,children:u.jsx(U,{icon:u.jsx(h,{size:30,color:"#244CCC"}),title:"اصناف خارج استان"})})]}),[q,K,Z,uu].includes(n)&&u.jsxs(u.Fragment,{children:[u.jsx(I,{to:a()==="SuperAdmin"?yu:a()==="AdminX"?Du:a()==="KillHouse"?mu:a()==="ProvinceOperator"?Mu:null,children:u.jsx(U,{icon:u.jsx(h,{size:30,color:"#244CCC"}),title:"درخواست های ثبت صنف"})}),u.jsx(I,{to:a()==="SuperAdmin"?bu:a()==="AdminX"?Vu:a()==="KillHouse"?ku:a()==="ProvinceOperator"?wu:null,children:u.jsx(U,{icon:u.jsx(h,{size:30,color:"#244CCC"}),title:"اصناف حقیقی"})}),u.jsx(I,{to:a()==="SuperAdmin"?zu:a()==="AdminX"?Bu:a()==="KillHouse"?Wu:a()==="ProvinceOperator"?Hu:null,children:u.jsx(U,{icon:u.jsx(h,{size:30,color:"#244CCC"}),title:"اصناف حقوقی"})})]}),[eu,nu,ru,su].includes(n)&&u.jsxs(u.Fragment,{children:[u.jsx(I,{to:a()==="SuperAdmin"?$u:a()==="AdminX"?Xu:a()==="KillHouse"?Qu:a()==="ProvinceOperator"?Yu:null,children:u.jsx(U,{icon:u.jsx(h,{size:30,color:"#244CCC"}),title:"اصناف حقیقی"})}),u.jsx(I,{to:a()==="SuperAdmin"?Ju:a()==="AdminX"?qu:a()==="KillHouse"?Ku:a()==="ProvinceOperator"?Zu:null,children:u.jsx(U,{icon:u.jsx(h,{size:30,color:"#244CCC"}),title:"اصناف حقوقی"})})]})]})]})},Q0=gu("PROVINCE_CHANGE_ACTIVE_STEWARD_SERVICE",async(n,{dispatch:l})=>{try{l(W());const{data:t,status:C}=await m.put("steward/0/",n);return l(Ou()),l(y()),{data:t,status:C}}catch(t){return l(y()),{error:t.response.data.result}}}),Y0=gu("PROVINCE_EDIT_STEWARD_SERVICE",async(n,{dispatch:l})=>{try{l(W());const{data:t,status:C}=await m.put("steward/0/",n);return l(Ou()),l(y()),{data:t,status:C}}catch(t){return l(y()),{error:t.response.data.result}}}),J0=e0().shape({}),q0=({guild:n})=>{const{provinceGetBuyersOptions:l}=tu(o=>o.provinceSlice),[t,C]=d.useState(n.centersAllocation?n.centersAllocation:[]),p=P(),[E]=d.useContext(Iu),i=u0({initialValues:{allocation_limit:n.allocationLimit,centers_allocation:"",limitation_allocation:n.limitationAllocation},validationSchema:J0,onSubmit:o=>{p(Y0({allocation_limit:o.allocation_limit,limitation_allocation:o.limitation_allocation,centers_allocation:t,steward_key:n.key})).then(S=>{S.payload.error?E({vertical:"top",horizontal:"center",msg:S.payload.error,severity:"error"}):(p(n0({right:!1,bottom:!1,content:null})),E({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}});return d.useEffect(()=>{p(v0())},[]),u.jsx("form",{onSubmit:i.handleSubmit,style:{width:"100%"},children:u.jsxs(c,{container:!0,direction:"column",width:"100%",gap:g.SMALL,children:[u.jsx(cu,{control:u.jsx(j,{name:"limitation_allocation",checked:i.values.limitation_allocation,onChange:i.handleChange}),label:"محدودیت تخصیص"}),i.errors.limitation_allocation&&u.jsx("div",{children:i.errors.limitation_allocation}),i.values.limitation_allocation&&u.jsxs(u.Fragment,{children:[u.jsx(L,{label:"حداکثر تخصیص",variant:"outlined",fullWidth:!0,id:"allocation_limit",name:"allocation_limit",InputProps:{endAdornment:u.jsx(T0,{position:"start",children:"کیلوگرم"})},value:i.values.allocation_limit,onChange:i.handleChange,error:i.touched.allocation_limit&&!!i.errors.allocation_limit,helperText:i.touched.allocation_limit&&i.errors.allocation_limit}),u.jsx(x0,{style:{width:"100%"},options:l,value:i.values.guild,onChange:(o,S)=>{C([...t,S])},error:i.touched.guild&&!!i.errors.guild,helperText:i.touched.guild&&i.errors.guild,getOptionLabel:o=>o.label,renderInput:o=>u.jsx(L,{...o,label:"انتخاب انبار",variant:"outlined"})}),u.jsx(au,{children:"محدودیت انبار های انتخاب شده"}),!t.length&&u.jsx(au,{variant:"caption",children:"محدودیتی وجود ندارد"}),t==null?void 0:t.map((o,S)=>u.jsxs(c,{container:!0,gap:g.SMALL,alignItems:"center",children:[u.jsx(N,{variant:"text",onClick:()=>{C(t.filter(T=>T.value!==o.value))},children:"حذف"}),u.jsx(au,{children:o.label},o.label)]},o.value))]}),u.jsx(N,{color:"primary",fullWidth:!0,variant:"contained",type:"submit",children:"ثبت"})]})})},K0=({guild:n})=>{const l=P(),[t,C]=d.useState(n.active),[p,E]=d.useState(!1),[i,o]=d.useState(null),S=A=>{E(!0),o(A.currentTarget)},T=()=>{E(!1),o(null)},r=A=>{C(A.target.checked),l(Q0({steward_key:n==null?void 0:n.key,active:A.target.checked}))};return u.jsxs(c,{children:[u.jsx(Lu,{title:"مدیریت متصدی",placement:"left",children:u.jsx(k,{color:"primary",onClick:S,children:u.jsx(w0,{})})}),u.jsx(h0,{open:p,anchorEl:i,onClose:T,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},children:u.jsx("div",{style:{padding:10},children:u.jsxs(c,{container:!0,direction:"column",alignItems:"flex-start",justifyContent:"center",gap:1,children:[u.jsx(cu,{control:u.jsx(du,{checked:t,onChange:r,color:"primary"}),label:t?"فعال":"غیرفعال",style:{justifyContent:"center",alignItems:"center",display:"flex"}}),u.jsx(N,{size:"small",color:"primary",startIcon:u.jsx(w,{}),sx:{fontSize:{xs:12,md:15}},onClick:()=>{T(),l(n0({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"اعمال محدودیت",content:u.jsx(q0,{guild:n})}))},children:"اعمال محدودیت"})]})})})]})},Z0=()=>{const n=P(),[l,t]=d.useState([]),[C,p]=d.useState("همه"),{provinceGetStewards:E}=tu(S=>S.provinceSlice),i=tu(S=>S.userSlice.userProfile.key);d.useEffect(()=>{n(Ou())},[]),d.useEffect(()=>{const S=C==="همه"?E:E==null?void 0:E.filter(r=>C==="فعال"?r==null?void 0:r.active:!(r!=null&&r.active)),T=S==null?void 0:S.map((r,A)=>{var H,$,s,X,Q,D,Y,J,O,G,f,M,_,e,v,b,V,R,Tu,xu,hu,vu,ju;const F=[A+1,(H=r==null?void 0:r.guilds)==null?void 0:H.guildsId,($=r==null?void 0:r.guilds)==null?void 0:$.guildsName,`${(X=(s=r==null?void 0:r.guilds)==null?void 0:s.user)==null?void 0:X.fullname} (${(D=(Q=r==null?void 0:r.guilds)==null?void 0:Q.user)==null?void 0:D.mobile})`,(J=(Y=r==null?void 0:r.guilds)==null?void 0:Y.user)==null?void 0:J.nationalId,(O=r==null?void 0:r.guilds)==null?void 0:O.typeActivity,(G=r==null?void 0:r.guilds)==null?void 0:G.areaActivity,(f=r==null?void 0:r.guilds)==null?void 0:f.licenseNumber,`${(_=(M=r==null?void 0:r.guilds)==null?void 0:M.address)==null?void 0:_.province.name}/${(v=(e=r==null?void 0:r.guilds)==null?void 0:e.address)==null?void 0:v.city.name}`,(V=(b=r==null?void 0:r.guilds)==null?void 0:b.address)==null?void 0:V.address,r!=null&&r.limitationAllocation?"دارد":"ندارد",(R=r==null?void 0:r.allocationLimit)==null?void 0:R.toLocaleString(),(Tu=r==null?void 0:r.centersAllocation)==null?void 0:Tu.map(g0=>g0.label).join(" - "),(hu=(xu=r==null?void 0:r.productInfo)==null?void 0:xu.totalCarcassesWeight)==null?void 0:hu.toLocaleString(),(ju=(vu=r==null?void 0:r.productInfo)==null?void 0:vu.realAllocatedWeight)==null?void 0:ju.toLocaleString(),u.jsx(K0,{guild:r},A)];return a()==="CityJahad"&&F.pop(),F});t(T)},[E,C]);const o=["ردیف","شناسه صنف","نام واحد صنفی","نام شخص/شرکت","کدملی","نوع فعالیت","حوزه فعالیت","شماره مجوز","استان/شهرستان","آدرس واحد صنفی","محدودیت تخصیص","حداکثر تخصیص","مراکز تخصیص","وزن خرید (کیلوگرم)","وزن فروش (کیلوگرم)","عملیات"];return a()==="CityJahad"&&o.pop(),u.jsxs(c,{container:!0,children:[u.jsxs(c,{container:!0,alignItems:"center",gap:g.SMALL,children:[u.jsx(Lu,{title:"خروجی اکسل",children:u.jsx("a",{href:`${m.defaults.baseURL}stewards_excel/?role=${a()}&key=${i}`,rel:"noreferrer",children:u.jsx(N,{color:"success",children:u.jsx(V0,{size:32})})})}),u.jsxs(L,{select:!0,label:"وضعیت",value:C,onChange:S=>p(S.target.value),size:"small",sx:{width:150},children:[u.jsx(iu,{value:"همه",children:"همه"}),u.jsx(iu,{value:"فعال",children:"فعال"}),u.jsx(iu,{value:"غیرفعال",children:"غیرفعال"})]})]}),u.jsx(ou,{title:"مباشرین",paginated:!0,columns:o,data:l})]})},U0=gu("UPDATE_GUILDS_SETTINGS_SERVICE",async n=>{const{data:l,status:t}=await m.put("kill_house_choose_steward_guilds/0/",n);return{data:l,status:t}}),u6=({guildState:n,choose_steward_guilds_key:l})=>{const t=P(),[C,p]=d.useState(n),E=()=>{p(i=>(t(U0({choose_steward_guilds_key:l,guilds:!i})),!i))};return u.jsx(c,{container:!0,alignItems:"center",justifyContent:"center",children:u.jsx(cu,{control:u.jsx(du,{checked:C,onChange:E,name:"switchState",color:"primary"})})})},e6=({stewardState:n,choose_steward_guilds_key:l})=>{const t=P(),[C,p]=d.useState(n),E=()=>{p(i=>(t(U0({choose_steward_guilds_key:l,steward:!i})),!i))};return u.jsx(c,{container:!0,alignItems:"center",justifyContent:"center",children:u.jsx(cu,{control:u.jsx(du,{checked:C,onChange:E,name:"switchState",color:"primary"})})})},n6=()=>{const n=P(),[l,t]=d.useState([]),{getGuildsSettings:C}=tu(p=>p.provinceSlice);return d.useEffect(()=>{n(W()),n(j0({kill_house_key:null})).then(()=>{n(y())})},[]),d.useEffect(()=>{if(Array.isArray(C)){const p=C==null?void 0:C.map((E,i)=>[i+1,E.killHouse.name,u.jsx(u6,{guildState:E.guilds,choose_steward_guilds_key:E.key},i),u.jsx(e6,{stewardState:E.steward,choose_steward_guilds_key:E.key},i)]);t(p)}},[C]),u.jsx(c,{children:u.jsx(ou,{paginated:!0,title:"مجوزهای توزیع",columns:["ردیف","نام کشتارگاه","اجازه فروش آزاد به صنف","اجازه فروش آزاد به مباشرین"],data:l})})},r6=()=>u.jsxs(c,{container:!0,gap:g.SMALL,p:g.SMALL,direction:{xs:"column",md:"row"},justifyContent:"center",children:[u.jsx(I,{to:a()==="Commerce"?r0:s0,children:u.jsx(U,{icon:u.jsx(h,{size:30,color:"#244CCC"}),title:"اصناف"})}),u.jsx(I,{to:a()==="Commerce"?t0:o0,children:u.jsx(U,{icon:u.jsx(lu,{size:30,color:"#244CCC"}),title:"مباشرین"})}),u.jsx(I,{to:a()==="Commerce"?l0:c0,children:u.jsx(U,{icon:u.jsx(lu,{size:30,color:"#244CCC"}),title:"مدیریت فرآیند"})})]}),s6=()=>u.jsxs(c,{container:!0,gap:g.SMALL,p:g.SMALL,direction:{xs:"column",md:"row"},justifyContent:"center",children:[u.jsx(I,{to:a()==="CityJahad"?a0:i0,children:u.jsx(U,{icon:u.jsx(h,{size:30,color:"#244CCC"}),title:"اصناف"})}),u.jsx(I,{to:a()==="CityJahad"?_0:C0,children:u.jsx(U,{icon:u.jsx(lu,{size:30,color:"#244CCC"}),title:"مباشرین"})})]}),t6=()=>{const{pathname:n}=Uu();return u.jsxs(c,{container:!0,gap:g.SMALL,p:g.SMALL,direction:{xs:"column",md:"row"},justifyContent:"center",children:[u.jsx(I,{to:E0,children:u.jsx(U,{icon:u.jsx(h,{size:30,color:"#244CCC"}),title:"درخواست های ثبت صنف"})}),u.jsx(I,{to:Cu,active:n===Cu?"true":null,children:u.jsx(U,{icon:u.jsx(h,{size:30,color:"#244CCC"}),title:"اصناف"})}),u.jsx(I,{to:Eu,active:n===Eu?"true":null,children:u.jsx(U,{icon:u.jsx(lu,{size:30,color:"#244CCC"}),title:"مباشرین"})})]})},o6=()=>u.jsx(c,{container:!0,alignItems:"center",justifyContent:"center",children:u.jsx(I0,{})}),l6=e0({percentInsideProvince:_u().typeError("باید عدد وارد کنید").min(0,"نمی‌تواند کمتر از 0 باشد").max(100,"نمی‌تواند بیشتر از 100 باشد").required("الزامی"),percentOutsideProvince:_u().typeError("باید عدد وارد کنید").min(0,"نمی‌تواند کمتر از 0 باشد").max(100,"نمی‌تواند بیشتر از 100 باشد").required("الزامی"),percentSegmentation:_u().typeError("باید عدد وارد کنید").min(0,"نمی‌تواند کمتر از 0 باشد").max(100,"نمی‌تواند بیشتر از 100 باشد").required("الزامی")}).test("total-percentage","مجموع درصدها نمی‌تواند بیشتر از 100 باشد",function(n){const{percentInsideProvince:l,percentOutsideProvince:t,percentSegmentation:C}=n;return(l||0)+(t||0)+(C||0)<=100}),fu=({item:n,updateTable:l,type:t,isDashboard:C})=>{const[p]=d.useContext(Iu),E=P(),i=C?z:B,o=u0({initialValues:{percentInsideProvince:t==="gov"?n==null?void 0:n.inProvinceGovernmentalSellingPercent:(n==null?void 0:n.inProvinceFreeSellingPercent)||0,percentOutsideProvince:t==="gov"?n==null?void 0:n.outProvinceGovernmentalSellingPercent:(n==null?void 0:n.outProvinceFreeSellingPercent)||0,percentSegmentation:t==="gov"?n==null?void 0:n.segmentationGovernmentalPercent:(n==null?void 0:n.segmentationFreeSellingPercent)||0},validationSchema:l6,onSubmit:r=>{E(i({...C?{}:{key:n==null?void 0:n.key},...t==="gov"?{governmental_selling_permission:!0,in_province_governmental_selling_percent:r.percentInsideProvince,segmentation_governmental_percent:r.percentSegmentation,out_province_governmental_selling_percent:r.percentOutsideProvince}:{free_selling_permission:!0,in_province_free_selling_percent:r.percentInsideProvince,out_province_free_selling_percent:r.percentOutsideProvince,segmentation_free_selling_percent:r.percentSegmentation}})).then(A=>{A.payload.error?p({vertical:"top",horizontal:"center",msg:A.payload.error,severity:"error"}):p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),E(Pu()),l()})}}),T=(()=>{const{percentInsideProvince:r,percentOutsideProvince:A,percentSegmentation:F}=o.values;return(r||0)+(A||0)+(F||0)})();return u.jsx(Nu,{component:"form",onSubmit:o.handleSubmit,sx:{width:"100%"},children:u.jsxs(c,{container:!0,spacing:2,alignItems:"flex-start",children:[u.jsx(c,{item:!0,xs:12,sm:4,children:u.jsx(L,{fullWidth:!0,id:"percentInsideProvince",name:"percentInsideProvince",label:"حداقل توزیع داخل استان",type:"number",value:o.values.percentInsideProvince,onChange:o.handleChange,onBlur:o.handleBlur,error:o.touched.percentInsideProvince&&!!o.errors.percentInsideProvince,helperText:o.touched.percentInsideProvince&&o.errors.percentInsideProvince,inputProps:{min:0,max:100,step:.1},size:"small"})}),u.jsx(c,{item:!0,xs:12,sm:4,children:u.jsx(L,{fullWidth:!0,id:"percentOutsideProvince",name:"percentOutsideProvince",label:"حداکثر فروش خارج استان",type:"number",value:o.values.percentOutsideProvince,onChange:o.handleChange,onBlur:o.handleBlur,error:o.touched.percentOutsideProvince&&!!o.errors.percentOutsideProvince,helperText:o.touched.percentOutsideProvince&&o.errors.percentOutsideProvince,inputProps:{min:0,max:100,step:.1},size:"small"})}),u.jsx(c,{item:!0,xs:12,sm:4,children:u.jsx(L,{fullWidth:!0,id:"percentSegmentation",name:"percentSegmentation",label:"حداکثر قطعه بندی",type:"number",value:o.values.percentSegmentation,onChange:o.handleChange,onBlur:o.handleBlur,error:o.touched.percentSegmentation&&!!o.errors.percentSegmentation,helperText:o.touched.percentSegmentation&&o.errors.percentSegmentation,inputProps:{min:0,max:100,step:.1},size:"small"})}),u.jsxs(c,{container:!0,xs:12,justifyContent:"center",spacing:1,children:[u.jsx(c,{xs:6,children:u.jsx(N,{onClick:o.handleSubmit,variant:"contained",color:"primary",disabled:!o.isValid||T>100,fullWidth:!0,children:"ثبت"})}),u.jsx(c,{xs:6,children:u.jsx(N,{onClick:()=>E(Pu()),variant:"contained",color:"error",fullWidth:!0,children:"انصراف"})})]})]})})},c6=()=>{const n=_=>{r(_.target.value)},[l]=d.useContext(Iu),t=P(),[C,p]=d.useState([]),[E,i]=d.useState(0),[o,S]=d.useState(10),[T,r]=d.useState(""),[A,F]=d.useState(1),[H,$]=d.useState([]),[s,X]=d.useState([]),Q=()=>{t($0()).then(_=>{X(_.payload.data)})},D=async _=>{let e;t(W()),e=await m.get(`guilds-for-configs/?search=filter&value=${T}&role=${a()}&page=${_}&page_size=${o}`),Q(),t(y()),p(e.data.results),i(e.data.count)},Y=_=>{D(_),F(_)},J=_=>{S(_),F(1)},O=()=>{D(A!==0?A:1)},G=(_,e)=>{t(Fu({title:"فروش دولتی",content:u.jsx(fu,{item:_,updateTable:O,type:"gov",isDashboard:e})}))},f=(_,e)=>{t(Fu({title:"فروش آزاد",content:u.jsx(fu,{item:_,updateTable:O,type:"free",isDashboard:e})}))};d.useEffect(()=>{const _=C==null?void 0:C.map((e,v)=>{var b,V;return[A===1?v+1:v+o*(A-1)+1,`${(b=e==null?void 0:e.user)==null?void 0:b.fullname} (${(V=e==null?void 0:e.user)==null?void 0:V.mobile})`,u.jsx(Gu,{amount:e==null?void 0:e.outProvinceFreeBuyingCommitmentPercent,updateTable:O,item:e,isGuild:!0},v),u.jsx(j,{checked:e==null?void 0:e.freeSaleFromFreeQuotaInProvince,onClick:()=>{t(B({key:e==null?void 0:e.key,free_sale_from_free_quota_in_province:!(e!=null&&e.freeSaleFromFreeQuotaInProvince)})).then(R=>{R.payload.error?l({vertical:"top",horizontal:"center",msg:R.payload.error,severity:"error"}):(O(),l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}},v),u.jsx(j,{checked:e==null?void 0:e.freeSaleFormGovernmentalQuota,onClick:()=>{t(B({key:e==null?void 0:e.key,free_sale_form_governmental_quota:!(e!=null&&e.freeSaleFormGovernmentalQuota)})).then(R=>{R.payload.error?l({vertical:"top",horizontal:"center",msg:R.payload.error,severity:"error"}):(O(),l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}},v),u.jsxs(c,{container:!0,alignItems:"center",xs:12,justifyContent:"start",direction:"row",children:[u.jsx(c,{xs:6,children:u.jsx(j,{checked:e==null?void 0:e.governmentalSellingPermission,onChange:()=>{const R=!(e!=null&&e.governmentalSellingPermission);t(B({key:e==null?void 0:e.key,governmental_selling_permission:R,...R===!1?{in_province_governmental_selling_percent:0,segmentation_governmental_percent:0,out_province_governmental_selling_percent:0}:{}})).then(()=>{R===!0?G(e):l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),O()})}})}),(e==null?void 0:e.governmentalSellingPermission)&&u.jsx(c,{xs:6,children:u.jsx(k,{size:"small",onClick:()=>G(e),color:"primary",children:u.jsx(w,{})})})]},v),u.jsxs(c,{container:!0,alignItems:"center",xs:12,justifyContent:"center",direction:"row",children:[u.jsx(c,{xs:6,children:u.jsx(j,{checked:e==null?void 0:e.freeSellingPermission,onChange:()=>{const R=!(e!=null&&e.freeSellingPermission);t(B({key:e==null?void 0:e.key,free_selling_permission:R,...R===!1?{in_province_free_selling_percent:0,out_province_free_selling_percent:0,segmentation_free_selling_percent:0}:{}})).then(()=>{R===!0?f(e):l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),O()})}})}),u.jsxs(c,{xs:6,children:[(e==null?void 0:e.freeSellingPermission)&&u.jsx(k,{size:"small",onClick:()=>f(e),color:"primary",children:u.jsx(w,{})})," "]})]},v),e==null?void 0:e.inProvinceGovernmentalSellingPercent,e==null?void 0:e.outProvinceGovernmentalSellingPercent,e==null?void 0:e.segmentationGovernmentalPercent,e==null?void 0:e.inProvinceFreeSellingPercent,e==null?void 0:e.outProvinceFreeSellingPercent,e==null?void 0:e.segmentationFreeSellingPercent]});$(_)},[C]),d.useEffect(()=>{D(1)},[t,o]);const M=async _=>{_.preventDefault(),t(W());try{const e=await m.get(`guilds-for-configs/?role=${a()}&search=filter&value=${T}&page=1&page_size=${o}`);p(e.data.results),i(e.data.count),t(y())}catch(e){console.error("Error fetching data:",e)}};return u.jsxs(c,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsx(c,{container:!0,mt:2,mb:4,isDashboard:!0,xs:12,children:u.jsx(ou,{noPagination:!0,isDashboard:!0,columns:["درصد تحویل خرید خارج استان","فروش آزاد به داخل استان","فروش آزاد از سهمیه دولتی","فروش دولتی","فروش آزاد","درصد فروش دولتی داخل استان","درصد فروش دولتی خارج استان","درصد فروش دولتی قطعه بندی","درصد فروش آزاد داخل استان","درصد فروش آزاد خارج استان","درصد فروش آزاد قطعه بندی"],data:[[u.jsx(Gu,{amount:s==null?void 0:s.outProvinceFreeBuyingCommitmentPercent,updateTable:O,item:s,isGuild:!0,isDashboard:!0},s),u.jsx(j,{checked:s==null?void 0:s.freeSaleFromFreeQuotaInProvince,onClick:()=>{t(z({free_sale_from_free_quota_in_province:!(s!=null&&s.freeSaleFromFreeQuotaInProvince)})).then(_=>{_.payload.error?l({vertical:"top",horizontal:"center",msg:_.payload.error,severity:"error"}):(O(),l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}},s),u.jsx(j,{checked:s==null?void 0:s.freeSaleFormGovernmentalQuota,onClick:()=>{t(z({free_sale_form_governmental_quota:!(s!=null&&s.freeSaleFormGovernmentalQuota)})).then(_=>{_.payload.error?l({vertical:"top",horizontal:"center",msg:_.payload.error,severity:"error"}):(O(),l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}},s),u.jsxs(c,{container:!0,alignItems:"center",xs:12,justifyContent:"start",direction:"row",children:[u.jsx(c,{xs:6,children:u.jsx(j,{checked:s==null?void 0:s.governmentalSellingPermission,onChange:()=>{const _=!(s!=null&&s.governmentalSellingPermission);t(z({governmental_selling_permission:_,..._===!1?{in_province_governmental_selling_percent:0,segmentation_governmental_percent:0,out_province_governmental_selling_percent:0}:{}})).then(()=>{_===!0?G(s,!0):l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),O()})}})}),(s==null?void 0:s.governmentalSellingPermission)&&u.jsx(c,{xs:6,children:u.jsx(k,{size:"small",onClick:()=>G(s,!0),color:"primary",children:u.jsx(w,{})})})]},s),u.jsxs(c,{container:!0,alignItems:"center",xs:12,justifyContent:"center",direction:"row",children:[u.jsx(c,{xs:6,children:u.jsx(j,{checked:s==null?void 0:s.freeSellingPermission,onChange:()=>{const _=!(s!=null&&s.freeSellingPermission);t(z({free_selling_permission:_,..._===!1?{in_province_free_selling_percent:0,out_province_free_selling_percent:0,segmentation_free_selling_percent:0}:{}})).then(()=>{_===!0?f(s,!0):l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),O()})}})}),u.jsxs(c,{xs:6,children:[(s==null?void 0:s.freeSellingPermission)&&u.jsx(k,{size:"small",onClick:()=>f(s,!0),color:"primary",children:u.jsx(w,{})})," "]})]},s),s==null?void 0:s.inProvinceGovernmentalSellingPercent,s==null?void 0:s.outProvinceGovernmentalSellingPercent,s==null?void 0:s.segmentationGovernmentalPercent,s==null?void 0:s.inProvinceFreeSellingPercent,s==null?void 0:s.outProvinceFreeSellingPercent,s==null?void 0:s.segmentationFreeSellingPercent]],title:"تنظیمات کلی"})}),u.jsx(c,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:u.jsx(c,{children:u.jsxs("form",{onSubmit:M,children:[u.jsx(L,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:n}),u.jsx(N,{type:"submit",onClick:M,endIcon:u.jsx(k0,{}),children:"جستجو"})]})})}),u.jsx(ou,{data:H,columns:["ردیف","نام مباشر","درصد تحویل خرید خارج استان","فروش آزاد به داخل استان","فروش آزاد از سهمیه دولتی","فروش دولتی","فروش آزاد","درصد فروش دولتی داخل استان","درصد فروش دولتی خارج استان","درصد فروش دولتی قطعه بندی","درصد فروش آزاد داخل استان","درصد فروش آزاد خارج استان","درصد فروش آزاد قطعه بندی"],handlePageChange:Y,totalRows:E,page:A,perPage:o,handlePerRowsChange:J,title:"مباشرین"})]})},a6=[Au,d0,Ru,p0,S0,A0,R0,pu,Su,q,K,Z,eu,nu,ru,uu,su],i6=[Au,pu,Su,Ru,q,K,Z,eu,nu,ru,uu,su],_6=[d0,p0],C6=[A0,R0],E6=[P0,F0,G0,r0,Cu,s0,a0,i0,wu,Vu,bu],d6=[f0,L0,N0,t0,Eu,o0,C0,_0],p6=[y0,D0,m0,c0,l0],S6=[Mu,yu,Du,E0,mu],A6=[M0,b0],R6=[$u,Xu,Yu,Qu],O6=[zu,Bu,Hu,Wu],I6=[Ju,qu,Zu,Ku],x=(n,l)=>l.includes(n),U6=(n,l)=>l.some(t=>n.includes(t)),oe=()=>{const{pathname:n}=Uu();return u.jsx(Nu,{display:"flex",justifyContent:"center",children:u.jsxs(c,{container:!0,direction:"column",justifyContent:"center",xs:12,lg:10,children:[x(n,a6)?u.jsxs(c,{justifyContent:"center",my:g.MEDIUM,children:[x(n,i6)&&u.jsx(X0,{}),x(n,_6)&&u.jsx(r6,{}),x(n,C6)&&u.jsx(s6,{}),n===S0&&u.jsx(t6,{})]}):u.jsx(O0,{}),u.jsx(c,{container:!0,justifyContent:"space-between",gap:g.SMALL,children:u.jsxs(c,{xs:12,children:[x(n,E6)&&u.jsx(o6,{}),U6(n,d6)&&u.jsx(Z0,{}),x(n,p6)&&u.jsx(n6,{}),x(n,S6)&&u.jsx(z0,{}),x(n,A6)&&u.jsx(c6,{}),x(n,R6)&&u.jsx(B0,{userType:"guild"}),n===ku&&u.jsx(I0,{userType:"guild"}),x(n,O6)&&u.jsx(W0,{userType:"guild"}),x(n,I6)&&u.jsx(H0,{userType:"guild"})]})})]})})};export{oe as default};