import{j as t,b5 as C,b as x}from"./mui-vendor-CkIVaoQP.js";import{L as A,j as d,h as l,dN as p,G as _,dO as m,dP as E,S as I,dm as j,dj as f,dk as P,dl as g,dQ as T,dR as F,dS as N}from"./index-Cr86_nOs.js";import{r as c,f as D}from"./react-vendor-CmFgShSM.js";import{a as S,u as h,f as O}from"./redux-vendor-B7uoacJt.js";import{A as y}from"./AdvancedTable-BvRVoK6m.js";import{B as L}from"./BackButton-7Uc4b2uz.js";import{R as w}from"./ResponsiveTable-Dua7tTwQ.js";import"./index-IuzvFnSU.js";import"./Close-C8iZ2Qr6.js";import"./Search-DLgMQCPC.js";import"./Delete-CTUmuli-.js";import"./FilterAlt-RwhTl5ac.js";import"./styled-components.browser.esm-gS9mh05b.js";const U=S("POLICY_CHANGE_KILLHOUSE_DIRECT_BUY_SERVICE",async(e,{dispatch:u})=>{try{u(A());const{data:r,status:a}=await d.put("allow_direct_buying/0/",e);return u(l()),{data:r,status:a}}catch(r){return u(l()),{error:r.response.data.result}}}),H=()=>{const e=h(),{provinceGetKillhouses:u}=O(o=>o.provinceSlice),[r,a]=c.useState();return c.useEffect(()=>{e(p())},[]),c.useEffect(()=>{const o=u==null?void 0:u.map(s=>[s.killHouse.name,t.jsx(C,{checked:s.allow,onChange:n=>{e(U({direct_buying_key:s.key,allow:n.target.checked})).then(i=>{e(p())})},name:"checked",color:"primary"},"kkk"),t.jsx(C,{checked:s.exportStatus,onChange:n=>{e(U({direct_buying_key:s.key,export_status:n.target.checked})).then(i=>{e(p())})},name:"checked",color:"primary"},"kkk")]);a(o)},[u]),t.jsxs(_,{container:!0,children:[t.jsx(L,{}),t.jsx(y,{name:"اجازه خرید مستقیم",columns:["کشتارگاه/کشتارکن","خرید مستقیم","صادرات"],data:r})]})},G=S("POLICY_CHANGE_KILLHOUSE_GUILDS_SERVICE",async(e,{dispatch:u})=>{try{u(A());const{data:r,status:a}=await d.put("allow_register_guilds/0/",e);return u(l()),{data:r,status:a}}catch(r){return u(l()),{error:r.response.data.result}}}),Y=()=>{const e=h(),{provinceGetKillhousesGuilds:u}=O(o=>o.provinceSlice),[r,a]=c.useState();return c.useEffect(()=>{e(m())},[]),c.useEffect(()=>{const o=u==null?void 0:u.map((s,n)=>{var i,k;return[(i=s.killHouse)==null?void 0:i.name,(k=s.killHouse)!=null&&k.killer?"کشتارکن":"کشتارگاه",t.jsx(C,{checked:s.allow,onChange:R=>{e(G({register_guilds_key:s.key,allow:R.target.checked})).then(V=>{e(m())})},name:"checked",color:"primary"},n)]});a(o)},[u]),t.jsxs(_,{container:!0,children:[t.jsx(L,{}),t.jsx(w,{paginated:!0,title:"دسترسی به اصناف",columns:["کشتارگاه/کشتارکن","ماهیت","دسترسی"],data:r,customColors:[{name:"ماهیت",color:"green"}]})]})},v=S("POLICY_CHANGE_POULTRY_CHOOSE_SLAUGHTER_SERVICE",async(e,{dispatch:u})=>{try{u(A());const{data:r,status:a}=await d.put("province_allow_poultry_choose_kill_house/0/",e);return u(l()),{data:r,status:a}}catch(r){return u(l()),{error:r.response.data.result}}}),K=()=>{const e=h(),{provinceGetPoultries:u}=O(o=>o.provinceSlice),[r,a]=c.useState();return c.useEffect(()=>{e(E())},[]),c.useEffect(()=>{const o=u==null?void 0:u.map(s=>[s.name,t.jsx(C,{checked:s.allowState,onChange:n=>{e(v({poultry_key:s.key,allow:n.target.checked})).then(()=>{e(E())})},name:"checked",color:"primary"},"kkk")]);a(o)},[u]),t.jsx(_,{container:!0,children:t.jsx(y,{name:"دسترسی مرغداران جهت انتخاب کشتارگاه",columns:["مرغدار","دسترسی"],data:r})})},b=S("POLICY_CHANGE_POULTRY_CHOOSE_SLAUGHTER_SERVICE",async(e,{dispatch:u})=>{try{u(A());const{data:r,status:a}=await d.put("province_allow_poultry_sell_free/0/",e);return u(l()),{data:r,status:a}}catch(r){return u(l()),{error:r.response.data.result}}}),B=()=>{const e=h(),{provinceGetPoultries:u}=O(o=>o.provinceSlice),[r,a]=c.useState();return c.useEffect(()=>{e(E())},[]),c.useEffect(()=>{const o=u==null?void 0:u.map(s=>[s.name,t.jsx(C,{checked:s.allowSellState,onChange:n=>{e(b({poultry_key:s.key,allow:n.target.checked})).then(i=>{e(E())})},name:"checked",color:"primary"},"kkk")]);a(o)},[u]),t.jsxs(_,{container:!0,children:[t.jsx(L,{}),t.jsx(y,{name:"دسترسی مرغداران جهت فروش آزاد",columns:["مرغدار","دسترسی"],data:r})]})},su=()=>{const{pathname:e}=D();return t.jsx(t.Fragment,{children:t.jsx(x,{display:"flex",justifyContent:"center",children:t.jsx(_,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,children:t.jsx(_,{container:!0,justifyContent:"space-between",gap:I.SMALL,children:t.jsxs(_,{mt:I.SMALL,xs:12,children:[e===j&&t.jsx(K,{}),(e===f||e===P||e===g)&&t.jsx(B,{}),t.jsx(H,{}),(e===T||e===F||e===N)&&t.jsx(Y,{})]})})})})})};export{su as default};
