2 lines
175 KiB
JavaScript
2 lines
175 KiB
JavaScript
import{j as u,b5 as lu,T as w,ak as S,B as R,ag as Q,ah as Z,ai as v,aj as I,i as Oe,d as ou,I as G,ax as Cu,aX as z,aw as Eu,av as Ku,aa as Le,am as le,a3 as su,bh as e0,aA as t0,bf as r0,b as cu,b2 as Ne,b3 as gu,b0 as Yu,an as Qu,b4 as yu,ap as _u,aq as mu,bi as Du}from"./mui-vendor-CkIVaoQP.js";import{B as n0}from"./BackButton-CX1bfrW9.js";import{L as b,j as _,h as g,G as i,S as q,cT as Fu,A as D,u as H,c as M,b as N,X as V,s as a0,C as K,r as Be,O as Y,N as vu,cU as ze,cV as Ue,cW as zu,cX as Ou,cY as Uu,cZ as Ve,c_ as Vu,c$ as qu,d0 as qe,d1 as ku,d2 as Pu,d3 as Me,d4 as Mu,d5 as He,d6 as Hu,d7 as We,d8 as Wu,d9 as Ge,da as Gu,db as s0,ae as pu,af as xu,b1 as o0,M as $,b2 as $e,dc as l0,dd as i0,de as c0,df as C0,dg as d0,dh as h0,di as p0,Z as ie,dj as x0,dk as g0,dl as A0,dm as y0,V as Lu,m as ce,dn as _0,dp as m0,dq as v0,dr as j0,ds as f0,dt as F0,du as E0,dv as b0,dw as S0,dx as k0,dy as P0,dz as I0,dA as w0,dB as T0,dC as R0,dD as D0,dE as O0,dF as L0,dG as N0,dH as B0,dI as z0,dJ as U0,dK as V0}from"./index-Vwb3Bce5.js";import{r as C,f as Ke,u as Ye}from"./react-vendor-CmFgShSM.js";import{a as P,u as k,f as bu}from"./redux-vendor-B7uoacJt.js";import{R as uu}from"./ResponsiveTable-DugzNG82.js";import{d as du}from"./Tune-DzkdDfJZ.js";import{d as Qe}from"./Done-CMcyvwuU.js";import{p as wu}from"./province-policy-wages-edit-killhouse-B0xEaQ0F.js";import{g as q0}from"./getSystemBaseAddress-B3dWKz82.js";import{V as M0,c as H0,d as Ce}from"./index.esm-CjWvmHks.js";import{L as eu}from"./LinkItem-Cp7DiDkz.js";import{N as tu}from"./NavLink-D2GD_ItM.js";import{b as W0,i as G0,e as $0,j as K0,k as Y0,l as Q0,m as X0}from"./index.esm-BY9chGNa.js";import{P as Z0}from"./ProvinceSelectSlaughterForSlaughter-C15ImPou.js";import{d as ru}from"./Edit-CwJaslma.js";import{a as J0,R as Xe}from"./index.esm-Bu7XMDZU.js";import{A as u6}from"./AdvancedTable-B0ObjV8k.js";import{h as e6}from"./hour-limit-get-kill-request-DRA4Ni9g.js";import{p as de,a as t6,b as he}from"./province-get-sell-for-freezing-status-CtJm9H0e.js";import{p as r6,a as n6,b as a6}from"./province-policy-market-daily-limitation-C9cdFwB8.js";import{p as pe,a as s6}from"./province-policy-get-aggregate-bar-info-allow-state-Dwe0M0O8.js";import{p as xe,a as o6,b as ge,c as l6}from"./province-policy-get-slaughter-buying-price-status-ADlSJZ6z.js";import{p as i6}from"./province-policy-drop-limit-qzpRWpbK.js";import{p as hu,a as Ru}from"./province-policy-upload-image-Bz2ni3_d.js";import{p as c6,a as C6,b as Ae}from"./province-policy-edit-trade-time-range-CRUDowBd.js";import{s as d6,g as h6}from"./getDocumentStates-LUwdz_H-.js";import{S as p6}from"./SimpleTable-B3_6HY_p.js";import{d as Xu}from"./Delete-DHYHiC8G.js";import{g as x6}from"./getRoleList-BYQaJKdj.js";import{d as g6}from"./Check-DJutmOSf.js";import{d as A6}from"./Save-SBgvd7Mw.js";import{G as y6}from"./index.esm-YBNW__9r.js";import{c as Au,P as _6}from"./ProvinceManageDistributionsSubmitCommitmentPercent-JtIzyydZ.js";import"./FilterAlt-CTDmPS36.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./iconBase-BEJYyZsk.js";import"./index-CgNdnt2v.js";import"./Close-8pFLGZ5w.js";import"./Search-CLlOaERQ.js";const Tu=P("MANAGE_PROCESS_BUY_REQ_OPERATION_SERVICE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("kill_house_purchase/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),ye=({item:e,getLimitInformation:t,isDebt:r})=>{const a=k(),[n,o]=C.useState(r?e.allowPurchaseRequest.totalLimitation:e.allowPurchaseRequest.allow),l=()=>{r?(o(!n),a(Tu({kill_house_key:e.key,total_limitation:!n})).then(s=>{a(Fu()),t()})):(o(!n),a(Tu({kill_house_key:e.key,allow:!n})).then(s=>{a(Fu()),t()}))};return u.jsx(i,{container:!0,alignItems:"center",justifyContent:"center",gap:q.SMALL,children:u.jsx(i,{container:!0,alignItems:"center",children:u.jsx(lu,{checked:n,onChange:l,color:"primary"})})})},m6=({item:e,getLimitInformation:t,fetchdata:r})=>{var A;const a=k(),[n,o]=C.useState(e.allowPurchaseRequest.limitation),[l,s]=C.useState((A=e==null?void 0:e.allowPurchaseRequest)==null?void 0:A.limitationNumber);C.useEffect(()=>{o(e.allowPurchaseRequest.limitation),s(e.allowPurchaseRequest.limitationNumber)},[e]);const c=Number(l)>0,d=F=>{s(F.target.value)},h=()=>{const F=!n;o(F),a(Tu({kill_house_key:e.key,limitation:F})),a(Fu()),t(),r()},y=()=>{a(Tu({kill_house_key:e.key,limitation:n,limitation_number:Number(l)})),a(Fu()),t(),r()};return u.jsxs(i,{container:!0,direction:"column",gap:q.SMALL,pt:q.TINY,children:[u.jsxs(i,{container:!0,alignItems:"center",spacing:1,children:[u.jsx(i,{item:!0,children:u.jsx(lu,{checked:n,onChange:h,color:"primary"})}),u.jsx(i,{item:!0,children:u.jsx(w,{children:"محدودیت بر اساس بدهی"})})]}),n&&u.jsxs(i,{container:!0,alignItems:"center",spacing:1,children:[u.jsx(i,{item:!0,xs:!0,children:u.jsx(S,{fullWidth:!0,size:"small",label:"مبلغ بدهی",value:l,onChange:d,variant:"outlined"})}),u.jsx(i,{item:!0,children:u.jsx(R,{onClick:y,variant:"contained",color:"primary",disabled:!c,sx:{minWidth:"40px"},children:u.jsx(Qe,{})})})]})]})},v6=({item:e,fetchdata:t})=>{const[r]=C.useContext(D),a=k(),[n,o]=C.useState(e==null?void 0:e.maxKillLimit),[l,s]=C.useState(e==null?void 0:e.totalKillCapacity),[c,d]=C.useState(e==null?void 0:e.extraBarKillPercent),h=()=>{const A=!n;o(A),a(wu({kill_house_key:e==null?void 0:e.key,total_kill_capacity:l,extra_bar_kill_percent:c,max_kill_limit:A})).then(F=>{F.payload.error?r({vertical:"top",horizontal:"center",msg:F.payload.error,severity:"error"}):(t(),r({vertical:"top",horizontal:"center",msg:"وضعیت محدودیت با موفقیت تغییر کرد.",severity:"success"}))})},y=()=>{a(wu({kill_house_key:e==null?void 0:e.key,total_kill_capacity:l,extra_bar_kill_percent:c,max_kill_limit:n})).then(A=>{A.payload.error?r({vertical:"top",horizontal:"center",msg:A.payload.error,severity:"error"}):(t(),r({vertical:"top",horizontal:"center",msg:"محدودیت با موفقیت ویرایش شد.",severity:"success"}))})};return u.jsxs(i,{container:!0,direction:"column",alignItems:"center",spacing:2,children:[u.jsxs(i,{item:!0,container:!0,alignItems:"center",spacing:1,children:[u.jsx(i,{item:!0,children:u.jsx(lu,{checked:n,onChange:h,inputProps:{"aria-label":"محدودیت کشتار"}})}),u.jsx(i,{children:u.jsx(w,{children:"محدودیت سقف کشتار"})})]}),n&&u.jsxs(i,{item:!0,container:!0,spacing:2,justifyContent:"center",width:"100%",children:[u.jsx(i,{item:!0,children:u.jsx(S,{fullWidth:!0,label:"ظرفیت کشتار",type:"number",value:l,onChange:A=>s(A.target.value),size:"small"})}),u.jsx(i,{item:!0,children:u.jsx(S,{fullWidth:!0,label:"درصد اضافه بار",type:"number",value:c,onChange:A=>d(A.target.value),size:"small"})}),u.jsx(i,{item:!0,children:u.jsx(R,{variant:"outlined",disabled:!c||!l||c>100||c<0,onClick:y,children:"ثبت"})})]})]})},j6=({item:e,fetchdata:t})=>{const r=k(),[a]=C.useContext(D),[n,o]=C.useState({minimumSaleState:(e==null?void 0:e.quota)||!1,quotaOption:e!=null&&e.quotaMaxKillLimit?"max_kill_limit":e!=null&&e.quotaRequest?"request":e!=null&&e.quotaCustom?"custom":"",qoutaCustomQuntity:(e==null?void 0:e.quotaCustomQuantity)||0,percent:(e==null?void 0:e.governmentalQuota)||0}),[l,s]=C.useState({percent:!1,qoutaCustomQuntity:!1});C.useEffect(()=>{n.minimumSaleState||(o(x=>({...x,quotaOption:"",qoutaCustomQuntity:0,percent:0})),s({percent:!1,qoutaCustomQuntity:!1}))},[n.minimumSaleState]);const c=(x,p)=>{o(j=>({...j,[x]:p}))},d=x=>{const p=x.target.value;o(j=>({...j,quotaOption:p,...p!=="custom"&&{qoutaCustomQuntity:0},...p==="custom"&&{percent:0}})),s({percent:!1,qoutaCustomQuntity:!1})},h=(x,p)=>{o(j=>({...j,[x]:p})),s(j=>({...j,[x]:!1}))},y=()=>{const x={percent:!1,qoutaCustomQuntity:!1};return n.minimumSaleState&&((n.quotaOption==="max_kill_limit"||n.quotaOption==="request")&&(!n.percent||n.percent<=0||n.percent>100)&&(x.percent=!0),n.quotaOption==="custom"&&(!n.qoutaCustomQuntity||n.qoutaCustomQuntity<=0)&&(x.qoutaCustomQuntity=!0)),s(x),!Object.values(x).some(p=>p)},A=()=>{if(!y()){a({vertical:"top",horizontal:"center",msg:"لطفاً مقادیر الزامی را به درستی وارد کنید",severity:"error"});return}r(wu({kill_house_key:e==null?void 0:e.key,quota:n.minimumSaleState,quota_max_kill_limit:n.quotaOption==="max_kill_limit",quota_request:n.quotaOption==="request",quota_custom:n.quotaOption==="custom",quota_custom_quantity:n.qoutaCustomQuntity,governmental_quota:n.percent})).then(x=>{var p;(p=x.payload)!=null&&p.error?a({vertical:"top",horizontal:"center",msg:x.payload.error,severity:"error"}):(a({vertical:"top",horizontal:"center",msg:"تغییرات با موفقیت ذخیره شد",severity:"success"}),t())})},F=()=>n.minimumSaleState?n.quotaOption==="max_kill_limit"||n.quotaOption==="request"?n.percent>0&&n.percent<=100:n.quotaOption==="custom"?n.qoutaCustomQuntity>0:!1:!0;return u.jsxs(i,{xs:12,container:!0,direction:"column",gap:q.SMALL,children:[u.jsxs(i,{xs:12,container:!0,alignItems:"center",gap:1,children:[u.jsx(i,{item:!0,children:u.jsx(lu,{checked:n.minimumSaleState,onChange:x=>{c("minimumSaleState",x.target.checked),x.target.checked||r(wu({kill_house_key:e==null?void 0:e.key,quota:!1,quota_max_kill_limit:!1,quota_request:!1,quota_custom:!1,quota_custom_quantity:0,governmental_quota:0})).then(p=>{var j;(j=p.payload)!=null&&j.error?a({vertical:"top",horizontal:"center",msg:p.payload.error,severity:"error"}):(a({vertical:"top",horizontal:"center",msg:"تغییرات با موفقیت ذخیره شد",severity:"success"}),t())})},inputProps:{"aria-label":"in-province-selling-limitation-switch"}})}),u.jsx(i,{item:!0,children:u.jsx(w,{children:"الزام به خرید دولتی"})})]}),n.minimumSaleState&&u.jsxs(i,{xs:12,container:!0,direction:"column",gap:1,children:[u.jsx(i,{item:!0,children:u.jsx(Q,{component:"fieldset",fullWidth:!0,children:u.jsxs(Z,{value:n.quotaOption,onChange:d,children:[u.jsx(v,{value:"max_kill_limit",control:u.jsx(I,{}),label:"بر اساس سقف کشتار"}),u.jsx(v,{value:"request",control:u.jsx(I,{}),label:"بر اساس اعلام نیازها"}),u.jsx(v,{value:"custom",control:u.jsx(I,{}),label:"بر اساس حجم از سقف کشتار"})]})})}),(n.quotaOption==="max_kill_limit"||n.quotaOption==="request")&&u.jsx(S,{label:"درصد خرید دولتی",size:"small",fullWidth:!0,type:"number",value:n.percent,onChange:x=>h("percent",Math.max(0,Math.min(100,x.target.value))),inputProps:{min:1,max:100},error:l.percent,helperText:l.percent?"درصد باید بین ۱ تا ۱۰۰ باشد":""}),n.quotaOption==="custom"&&u.jsx(S,{label:"حجم",size:"small",fullWidth:!0,type:"number",value:n.qoutaCustomQuntity,onChange:x=>h("qoutaCustomQuntity",Math.max(0,x.target.value)),inputProps:{min:1},error:l.qoutaCustomQuntity,helperText:l.qoutaCustomQuntity?"حجم باید بزرگتر از صفر باشد":""}),u.jsx(R,{fullWidth:!0,variant:"contained",color:"primary",onClick:A,disabled:!F(),startIcon:u.jsx(Qe,{}),children:"ذخیره تغییرات"})]})]})},Zu=P("PROVINCE_UPDATE_Killer_IDENTITY_SERVICE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("/kill_house/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),f6=M({maximumIncrease:N().typeError("لطفا یک عدد وارد کنید").min(0,"عددی بین 0 تا 100 وارد کنید!").max(100,"عددی بین 0 تا 100 وارد کنید!").required("این فیلد اجباری است"),maximumDecrease:N().typeError("لطفا یک عدد وارد کنید").min(0,"عددی بین 0 تا 100 وارد کنید!").max(100,"عددی بین 0 تا 100 وارد کنید!").required("این فیلد اجباری است")}),F6=({item:e,fetchdata:t})=>{const[r]=C.useContext(D),a=k(),n=H({initialValues:{maximumIncrease:(e==null?void 0:e.maximumLoadVolumeIncrease)||0,maximumDecrease:(e==null?void 0:e.maximumLoadVolumeReduction)||0},validationSchema:f6,onSubmit:o=>{a(Zu({kill_house_key:e==null?void 0:e.key,maximum_load_volume_increase:o.maximumIncrease,maximum_load_volume_reduction:o.maximumDecrease})).then(l=>{l.payload.error?r({vertical:"top",horizontal:"center",msg:l.payload.error,severity:"error"}):(t(),r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}});return u.jsxs("form",{onSubmit:n.handleSubmit,children:[u.jsx(w,{variant:"body2",children:"درصد افزایش/کاهش حجم ورود اطلاعات بار"}),u.jsx(S,{size:"small",fullWidth:!0,id:"maximumIncrease",name:"maximumIncrease",label:"حداکثر افزایش حجم بار",type:"number",value:n.values.maximumIncrease,onChange:n.handleChange,onBlur:n.handleBlur,error:n.touched.maximumIncrease&&!!n.errors.maximumIncrease,helperText:n.touched.maximumIncrease&&n.errors.maximumIncrease,margin:"dense"}),u.jsx(S,{size:"small",fullWidth:!0,id:"maximumDecrease",name:"maximumDecrease",label:"حداکثر کاهش حجم بار",type:"number",value:n.values.maximumDecrease,onChange:n.handleChange,onBlur:n.handleBlur,error:n.touched.maximumDecrease&&!!n.errors.maximumDecrease,helperText:n.touched.maximumDecrease&&n.errors.maximumDecrease,margin:"dense"}),u.jsx(R,{type:"submit",variant:"contained",sx:{mt:1},fullWidth:!0,children:"ثبت اطلاعات"})]})},E6=({item:e,fetchdata:t})=>{const[r]=C.useContext(D),a=k(),[n,o]=C.useState((e==null?void 0:e.wareHouseRemainingWeightLimitationStatus)||!1),[l,s]=C.useState((e==null?void 0:e.wareHouseRemainingWeightLimitation)||""),[c,d]=C.useState((e==null?void 0:e.wareHouseRemainingPercentLimitationStatus)||!1),[h,y]=C.useState((e==null?void 0:e.wareHouseRemainingPercentLimitation)||""),A=()=>{o(!n)},F=()=>{d(!c)},x=()=>{a(Zu({kill_house_key:e==null?void 0:e.key,ware_house_remaining_weight_limitation_status:n,ware_house_remaining_weight_limitation:n?l:0,ware_house_remaining_percent_limitation_status:c,ware_house_remaining_percent_limitation:c?h:0})).then(p=>{p.payload.error?r({vertical:"top",horizontal:"center",msg:p.payload.error,severity:"error"}):(t(),r({vertical:"top",horizontal:"center",msg:"محدودیتهای انبار با موفقیت ویرایش شد.",severity:"success"}))})};return u.jsxs(i,{container:!0,direction:"column",alignItems:"flex-start",width:"100%",sx:{px:{xs:1,sm:0}},children:[u.jsx(i,{item:!0,width:"100%",mb:2,children:u.jsx(w,{variant:"h6",sx:{fontSize:{xs:"1rem",sm:"1rem"},fontWeight:"bold"},children:"محدودیت سقف انبار"})}),u.jsxs(i,{item:!0,container:!0,direction:"column",spacing:{xs:2,sm:2},width:"100%",mb:2,px:1,children:[u.jsxs(i,{item:!0,container:!0,direction:"row",alignItems:"center",flexWrap:"wrap",sx:{gap:2},children:[u.jsx(i,{item:!0,children:u.jsx(lu,{checked:n,onChange:A,inputProps:{"aria-label":"محدودیت وزن انبار"},size:"small"})}),u.jsx(i,{item:!0,xs:!0,children:u.jsx(w,{sx:{fontSize:{xs:"0.625rem",sm:"0.875rem"}},children:"محدودیت مانده انبار"})})]}),n&&u.jsx(i,{item:!0,container:!0,spacing:{xs:1,sm:2},alignItems:"stretch",mb:2,children:u.jsx(i,{item:!0,xs:12,mt:2,children:u.jsx(S,{fullWidth:!0,label:"حداکثر وزن باقی مانده انبار (کیلوگرم)",type:"number",value:l,onChange:p=>s(p.target.value),size:"small",inputProps:{min:0},sx:{"& .MuiInputLabel-root":{fontSize:{xs:"0.875rem",sm:"1rem"}},"& .MuiInputBase-input":{fontSize:{xs:"0.875rem",sm:"1rem"}}}})})})]}),u.jsxs(i,{item:!0,container:!0,direction:"column",spacing:{xs:1.5,sm:2},width:"100%",px:1,children:[u.jsxs(i,{item:!0,container:!0,direction:"row",alignItems:"center",flexWrap:"wrap",sx:{gap:2},children:[u.jsx(i,{item:!0,children:u.jsx(lu,{checked:c,onChange:F,inputProps:{"aria-label":"محدودیت درصد انبار"},size:"small"})}),u.jsx(i,{item:!0,xs:!0,children:u.jsx(w,{sx:{fontSize:{xs:"0.625rem",sm:"0.875rem"}},children:"محدودیت مانده کشتار روزانه"})})]}),c&&u.jsx(i,{item:!0,container:!0,spacing:{xs:1,sm:2},mt:2,alignItems:"stretch",xs:12,children:u.jsx(i,{item:!0,xs:12,children:u.jsx(S,{fullWidth:!0,label:"درصد وزن باقی مانده روزانه انبار",type:"number",value:h,onChange:p=>y(p.target.value),size:"small",inputProps:{min:0,max:100},sx:{"& .MuiInputLabel-root":{fontSize:{xs:"0.875rem",sm:"1rem"}},"& .MuiInputBase-input":{fontSize:{xs:"0.875rem",sm:"1rem"}}}})})})]}),u.jsx(i,{item:!0,width:"100%",mt:4,children:u.jsx(R,{variant:"contained",onClick:x,fullWidth:!0,disabled:n&&(!l||l<=0)||c&&(!h||h<=0||h>100),sx:{fontSize:{xs:"0.875rem"},py:{xs:1.5,sm:1}},children:"ثبت اطلاعات"})})]})},b6=P("PROVINCE_UPDATE_KILLHOUSE_ARCHIVE_PERCENT_SERVICE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("kill_house/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),S6=({item:e,fetchdata:t})=>{const[r]=C.useContext(D),a=k(),[n,o]=C.useState((e==null?void 0:e.wareHouseRemainingWeightArchivePercent)!==void 0&&(e==null?void 0:e.wareHouseRemainingWeightArchivePercent)!==null&&(e==null?void 0:e.wareHouseRemainingWeightArchivePercent)>0),[l,s]=C.useState((e==null?void 0:e.wareHouseRemainingWeightArchivePercent)||0);C.useEffect(()=>{const A=(e==null?void 0:e.wareHouseRemainingWeightArchivePercent)!==void 0&&(e==null?void 0:e.wareHouseRemainingWeightArchivePercent)!==null&&(e==null?void 0:e.wareHouseRemainingWeightArchivePercent)>0;o(A),s((e==null?void 0:e.wareHouseRemainingWeightArchivePercent)||0)},[e]);const c=Number(l)>=0&&Number(l)<=100,d=A=>{s(A.target.value)},h=()=>{const A=!n;o(A),A||s(0)},y=()=>{a(b6({kill_house_key:e.key,ware_house_remaining_weight_archive_percent:n?Number(l):0})).then(A=>{A.payload.error?r({vertical:"top",horizontal:"center",msg:A.payload.error,severity:"error"}):(t(),r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})};return u.jsxs(i,{container:!0,direction:"column",gap:q.SMALL,pt:q.TINY,children:[u.jsx(i,{container:!0,alignItems:"center",spacing:1,children:u.jsx(i,{item:!0,children:u.jsx(v,{control:u.jsx(lu,{checked:n,onChange:h,color:"primary"}),label:"حداکثر افت استاندارد لاشه"})})}),n&&u.jsx(i,{container:!0,alignItems:"center",spacing:1,children:u.jsx(i,{item:!0,xs:!0,children:u.jsx(S,{fullWidth:!0,size:"small",label:"درصد",type:"number",value:l,onChange:d,variant:"outlined",inputProps:{min:0,max:100},error:!c,helperText:c?"":"عدد باید بین 0 تا 100 باشد"})})}),u.jsx(i,{item:!0,width:"100%",mt:2,children:u.jsx(R,{variant:"contained",onClick:y,fullWidth:!0,disabled:n&&!c,children:"ثبت اطلاعات"})})]})},k6=({item:e,fetchdata:t})=>{const{role:r}=bu(o=>o.userSlice),a=k(),n=()=>{r.includes("KillHouse")&&a(a0())};return u.jsxs(i,{container:!0,direction:"column",gap:2,alignItems:"flex-start",m:"3",children:[u.jsx(i,{item:!0,container:!0,spacing:2,justifyContent:"center",width:"100%",m:"3"}),u.jsxs(i,{item:!0,container:!0,alignItems:"center",spacing:1,justifyContent:"start",sx:{border:"1px solid #ccc",borderRadius:2,width:"100%",p:1},children:[u.jsx(i,{item:!0,children:u.jsx(ye,{item:e,getLimitInformation:n},e.key)}),u.jsx(i,{item:!0,children:u.jsx(w,{children:"مجوز ثبت درخواست"})})]}),u.jsxs(i,{item:!0,container:!0,alignItems:"center",spacing:1,justifyContent:"start",sx:{border:"1px solid #ccc",borderRadius:2,width:"100%",p:1},children:[u.jsx(i,{item:!0,children:u.jsx(ye,{item:e,isDebt:!0},`${e.key}-isDebt`)}),u.jsx(i,{item:!0,children:u.jsx(w,{children:"محدودیت پنل"})})]}),u.jsx(i,{xs:12,container:!0,alignItems:"center",spacing:1,justifyContent:"start",sx:{border:"1px solid #ccc",borderRadius:2,width:"100%",p:1},children:u.jsx(i,{item:!0,xs:12,children:u.jsx(j6,{item:e,fetchdata:t},e.key)})}),V()==="AdminX"&&u.jsx(i,{item:!0,container:!0,alignItems:"center",spacing:1,justifyContent:"start",sx:{border:"1px solid #ccc",borderRadius:2,width:"100%",p:1},children:u.jsx(i,{item:!0,children:u.jsx(m6,{item:e,getLimitInformation:n,fetchdata:t},`limit-${e.key}`)})}),u.jsx(i,{item:!0,container:!0,alignItems:"center",spacing:1,justifyContent:"start",sx:{border:"1px solid #ccc",borderRadius:2,width:"100%",p:1},children:u.jsx(i,{item:!0,children:u.jsx(v6,{item:e,fetchdata:t},e.key)})}),u.jsx(i,{item:!0,container:!0,alignItems:"center",spacing:1,justifyContent:"start",sx:{border:"1px solid #ccc",borderRadius:2,width:"100%",p:1},children:u.jsx(i,{item:!0,children:u.jsx(F6,{item:e,fetchdata:t})})}),u.jsx(i,{item:!0,container:!0,alignItems:"center",spacing:1,justifyContent:"start",sx:{border:"1px solid #ccc",borderRadius:2,width:"100%",p:1},children:u.jsx(i,{item:!0,xs:12,children:u.jsx(E6,{item:e,fetchdata:t})})}),u.jsx(i,{item:!0,container:!0,alignItems:"center",spacing:1,justifyContent:"start",sx:{border:"1px solid #ccc",borderRadius:2,width:"100%",p:1},children:u.jsx(i,{item:!0,xs:12,children:u.jsx(S6,{item:e,fetchdata:t})})})]})},P6=({item:e})=>{var l;const t=bu(s=>s.userSlice.userPath),r=`${window.location.origin}/pay/${q0(t)}/${(l=e==null?void 0:e.wageInfo)==null?void 0:l.userToken}`,[a]=C.useContext(D),n=k(),o=()=>{navigator.clipboard.writeText(r).then(()=>{a({vertical:"top",horizontal:"center",msg:"لینک پرداخت کپی شد",severity:"success"}),n(K())})};return u.jsx(i,{xs:12,container:!0,spacing:3,alignItems:"center",direction:"column",children:u.jsxs(i,{container:!0,spacing:2,justifyContent:"center",alignItems:"center",children:[u.jsx(i,{children:u.jsx(R,{fullWidth:!0,variant:"contained",sx:{backgroundColor:"blue",color:"white"},onClick:()=>window.open(r,"_blank"),children:"پرداخت بدهی"})}),u.jsx(i,{children:u.jsx(R,{fullWidth:!0,variant:"outlined",sx:{color:"blue",borderColor:"blue"},onClick:o,children:"کپی لینک"})})]})})};var Ju={},I6=Oe;Object.defineProperty(Ju,"__esModule",{value:!0});var Ze=Ju.default=void 0,w6=I6(Be()),T6=u;Ze=Ju.default=(0,w6.default)((0,T6.jsx)("path",{d:"M2 12.5C2 9.46 4.46 7 7.5 7H18c2.21 0 4 1.79 4 4s-1.79 4-4 4H9.5C8.12 15 7 13.88 7 12.5S8.12 10 9.5 10H17v2H9.41c-.55 0-.55 1 0 1H18c1.1 0 2-.9 2-2s-.9-2-2-2H7.5C5.57 9 4 10.57 4 12.5S5.57 16 7.5 16H17v2H7.5C4.46 18 2 15.54 2 12.5"}),"Attachment");const R6=()=>{const e=k(),[t,r]=C.useState([]),[a,n]=C.useState([]),o=()=>{e(Fu()).then(l=>{n(l.payload.data)})};return C.useEffect(()=>{o()},[]),C.useEffect(()=>{const l=a==null?void 0:a.map((s,c)=>{var h,y,A,F,x,p,j,E,T,O,f,B,U;const d=s.killer?`کشتارکن ${(s==null?void 0:s.type)==="public"?"عمومی":"اختصاصی"} (${(h=s==null?void 0:s.killHouseForKiller)==null?void 0:h.killHouseName})`:"کشتارگاه";return[c+1,d,s.name,`${(A=(y=s==null?void 0:s.killHouseOperator)==null?void 0:y.user)==null?void 0:A.fullname} (${(x=(F=s==null?void 0:s.killHouseOperator)==null?void 0:F.user)==null?void 0:x.mobile})`,`${((j=(p=s==null?void 0:s.systemAddress)==null?void 0:p.province)==null?void 0:j.name)||""} - ${((T=(E=s==null?void 0:s.systemAddress)==null?void 0:E.city)==null?void 0:T.name)||""} - ${((O=s==null?void 0:s.systemAddress)==null?void 0:O.address)||""}`,(B=(f=s==null?void 0:s.wageInfo)==null?void 0:f.totalAmount)==null?void 0:B.toLocaleString(),u.jsx(ou,{title:"لینک پرداخت",placement:"left-start",children:u.jsx(G,{color:"primary",onClick:()=>{e(Y({title:"لینک پرداخت بدهی",content:u.jsx(P6,{item:s})}))},children:u.jsx(Ze,{})})},c),(U=s==null?void 0:s.allowPurchaseRequest)!=null&&U.limitation?"فعال":"غیر فعال",u.jsx(u.Fragment,{children:u.jsx(w,{children:s!=null&&s.maxKillLimit?s.totalKillCapacity:"-"})}),u.jsxs(u.Fragment,{children:[u.jsx(w,{children:s!=null&&s.maxKillLimit?`%${s.extraBarKillPercent}`:"-"})," "]}),u.jsxs(u.Fragment,{children:[u.jsx(w,{children:s!=null&&s.inProvinceSellingLimitationPercent?`%${s.inProvinceSellingLimitationPercent}`:"-"})," "]}),u.jsx(u.Fragment,{children:u.jsx(w,{children:s!=null&&s.outProvinceSellingLimitationPercent?`%${s.outProvinceSellingLimitationPercent}`:"-"})}),s!=null&&s.quota?"دارد":"ندارد",s!=null&&s.quota?s!=null&&s.quotaMaxKillLimit?"بر اساس سقف کشتار":s!=null&&s.quotaRequest?"بر اساس اعلام نیازها":"بر اساس حجم از سقف کشتار":"-",s!=null&&s.governmentalQuota?s==null?void 0:s.governmentalQuota:"-",s!=null&&s.quotaCustomQuantity?s==null?void 0:s.quotaCustomQuantity:"-",(s==null?void 0:s.maximumLoadVolumeIncrease)||0,(s==null?void 0:s.maximumLoadVolumeReduction)||0,s!=null&&s.wareHouseRemaininggWeightLimitationStatus?"فعال":"غیر فعال",s!=null&&s.wareHouseRemainingWeightLimitation?`${s==null?void 0:s.wareHouseRemainingWeightLimitation} کیلوگرم`:"-",s!=null&&s.wareHouseRemainingPercentLimitationStatus?"فعال":"غیر فعال",s!=null&&s.wareHouseRemainingPercentLimitation?`%${s==null?void 0:s.wareHouseRemainingPercentLimitation}`:"-",s!=null&&s.wareHouseRemainingWeightArchivePercent?`%${s==null?void 0:s.wareHouseRemainingWeightArchivePercent}`:"-",u.jsx(ou,{title:"محدودیت پنل",placement:"left-start",children:u.jsx(G,{"aria-label":"delete",color:"primary",onClick:()=>{e(vu({right:!(window.innerWidth<=700),bottom:window.innerWidth<=700,title:"محدودیت پنل",content:u.jsx(k6,{item:s,fetchdata:o})}))},children:u.jsx(du,{})})},c)]});r(l)},[a]),u.jsx(i,{children:u.jsx(uu,{paginated:!0,title:"مجوز خرید",columns:["ردیف","ماهیت","نام واحد","نام و نام خانوادگی (تلفن)","آدرس","مبلغ بدهی (ریال)","لینک پرداخت","سقف بدهی","محدودیت سقف کشتار","درصد افزایش بار","حداقل فروش داخل استان","حداکثر فروش خارج استان","الزام به خرید دولتی","نوع الزام","درصد الزام به خرید دولتی","حجم الزام خرید از سقف کشتار","حداکثر افزایش حجم ورود اطلاعات بار","حداکثر کاهش حجم ورود اطلاعات بار","محدودیت مانده انبار","حداکثز وزن باقی مانده انبار","محدودیت مانده روزانه انبار","درصد وزن باقی مانده روزانه انبار","حداکثر افت استاندارد لاشه","عملیات"],data:t,customColors:[{name:"مجوز ثبت درخواست",color:"red"},{name:"محدودیت براساس بدهی",color:"red"},{name:"محدودیت پنل",color:"red"}]})})},D6=()=>{const{pathname:e}=Ke();return u.jsxs(i,{container:!0,gap:q.SMALL,direction:"row",mt:q.MEDIUM,justifyContent:{xs:"center",lg:"flex-start"},xs:12,children:[u.jsx(tu,{to:V()==="SuperAdmin"?ze:V()==="AdminX"?Ue:zu,active:e===zu?"true":null,children:u.jsx(eu,{icon:u.jsx(M0,{size:30,color:"#244CCC"}),title:"شورای سیاست گذاری"})}),V()==="AdminX"&&u.jsx(tu,{to:V()==="AdminX"?Ou:Ou,active:e===Ou?"true":null,children:u.jsx(eu,{icon:u.jsx(H0,{size:30,color:"#244CCC"}),title:"سهم بندی"})}),u.jsx(tu,{to:V()==="SuperAdmin"?Uu:Ve,active:e===Uu?"true":null,children:u.jsx(eu,{icon:u.jsx(W0,{size:30,color:"#244CCC"}),title:"وضعیت اسناد"})}),V()==="AdminX"&&u.jsx(tu,{to:Vu,active:e===Vu?"true":null,children:u.jsx(eu,{icon:u.jsx(G0,{size:30,color:"#244CCC"}),title:"حساب ها"})}),(V()==="AdminX"||V()==="SuperAdmin")&&u.jsx(tu,{to:V()==="AdminX"?qu:qe,active:e===qu?"true":null,children:u.jsx(eu,{icon:u.jsx(Ce,{size:30,color:"#244CCC"}),title:"مدیریت ارسال تیکت"})}),V()==="AdminX"&&u.jsx(tu,{to:V()==="AdminX"?ku:ku,active:e===ku?"true":null,children:u.jsx(eu,{icon:u.jsx(Ce,{size:30,color:"#244CCC"}),title:"کرونجاب"})}),V()==="AdminX"&&u.jsx(tu,{to:V()==="AdminX"?Pu:Pu,active:e===Pu?"true":null,children:u.jsx(eu,{icon:u.jsx($0,{size:30,color:"#244CCC"}),title:"مدیریت ارسال پیامک"})}),u.jsx(tu,{to:V()==="SuperAdmin"?Me:Mu,active:e===Mu?"true":null,children:u.jsx(eu,{icon:u.jsx(K0,{size:30,color:"#244CCC"}),title:"مدیریت بازه وزنی"})}),u.jsx(tu,{to:V()==="SuperAdmin"?He:Hu,active:e===Hu?"true":null,children:u.jsx(eu,{icon:u.jsx(Y0,{size:30,color:"#244CCC"}),title:"دسته بندی وزنی"})}),u.jsx(tu,{to:V()==="SuperAdmin"?We:Wu,active:e===Wu?"true":null,children:u.jsx(eu,{icon:u.jsx(Q0,{size:30,color:"#244CCC"}),title:"جریمه"})}),u.jsx(tu,{to:V()==="SuperAdmin"?Ge:Gu,active:e===Gu?"true":null,children:u.jsx(eu,{icon:u.jsx(X0,{size:30,color:"#244CCC"}),title:"محدودیت توزیع لاشه"})})]})},O6=P("PROVINCE_PURGE_NEEDED_REQUEST_SERVICE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("kill_request/0/",{previous_requests:!0});return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),L6=P("PROVINCE_CREATE_KILLHOUSE_SERVICE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.post("kill_house/",e);return t(s0()),t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),N6={city:"",mobile:"",password:"",first_name:"",last_name:"",national_id:"",address:"",name:"",killer:!1},B6=M().shape({city:$().required("City is required"),mobile:$().required("Mobile is required"),password:$().required("Password is required"),first_name:$().required("First Name is required"),last_name:$().required("Last Name is required"),national_id:$().required("National ID is required"),address:$().required("Address is required"),name:$().required("Name is required")}),z6=()=>{const e=k(),[t]=C.useContext(D),{provinceGetCities:r}=bu(n=>n.provinceSlice),a=H({initialValues:N6,validationSchema:B6,onSubmit:n=>{const{first_name:o,last_name:l,mobile:s,city:c,password:d,national_id:h,address:y,name:A,killer:F}=n;e(L6({city:c,mobile:s,password:d,first_name:o,last_name:l,national_id:h,address:y,name:A,killer:F})).then(x=>{x.payload.error?t({vertical:"top",horizontal:"center",msg:x.payload.error,severity:"error"}):(e(pu()),e(xu()),e(vu({right:!1,bottom:!1,content:null})),t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}});return C.useEffect(()=>{e(o0())},[]),u.jsx("div",{children:u.jsx("form",{onSubmit:a.handleSubmit,children:u.jsxs(i,{container:!0,gap:q.SMALL,direction:"column",children:[u.jsx(S,{fullWidth:!0,id:"first_name",name:"first_name",label:"نام",value:a.values.first_name,onChange:a.handleChange,onBlur:a.handleBlur,error:a.touched.first_name&&!!a.errors.first_name,helperText:a.touched.first_name&&a.errors.first_name}),u.jsx(S,{fullWidth:!0,id:"last_name",name:"last_name",label:"نام خانوادگی",value:a.values.last_name,onChange:a.handleChange,onBlur:a.handleBlur,error:a.touched.last_name&&!!a.errors.last_name,helperText:a.touched.last_name&&a.errors.last_name}),u.jsx(S,{fullWidth:!0,id:"national_id",name:"national_id",label:"کدملی",value:a.values.national_id,onChange:a.handleChange,onBlur:a.handleBlur,error:a.touched.national_id&&!!a.errors.national_id,helperText:a.touched.national_id&&a.errors.national_id}),u.jsx(S,{select:!0,label:"شهر",variant:"outlined",fullWidth:!0,id:"city",name:"city",value:a.values.city,onChange:a.handleChange,error:a.touched.city&&!!a.errors.city,helperText:a.touched.city&&a.errors.city,children:r==null?void 0:r.map(n=>u.jsx(Cu,{value:n.name,children:n.name},n.id))}),u.jsx(S,{fullWidth:!0,id:"mobile",name:"mobile",label:"تلفن",value:a.values.mobile,onChange:a.handleChange,onBlur:a.handleBlur,error:a.touched.mobile&&!!a.errors.mobile,helperText:a.touched.mobile&&a.errors.mobile}),u.jsx(S,{fullWidth:!0,id:"name",name:"name",label:"نام واحد",value:a.values.name,onChange:a.handleChange,onBlur:a.handleBlur,error:a.touched.name&&!!a.errors.name,helperText:a.touched.name&&a.errors.name}),u.jsx(S,{fullWidth:!0,id:"address",name:"address",label:"آدرس",value:a.values.address,onChange:a.handleChange,onBlur:a.handleBlur,error:a.touched.address&&!!a.errors.address,helperText:a.touched.address&&a.errors.address}),u.jsx(S,{fullWidth:!0,id:"password",name:"password",label:"رمزعبور",type:"password",value:a.values.password,onChange:a.handleChange,onBlur:a.handleBlur,error:a.touched.password&&!!a.errors.password,helperText:a.touched.password&&a.errors.password}),u.jsx(v,{control:u.jsx(z,{id:"killer",name:"killer",checked:a.values.killer,onChange:a.handleChange}),label:"کشتارکن می باشد"}),u.jsx(R,{fullWidth:!0,type:"submit",variant:"contained",color:"primary",children:"ثبت"})]})})})},U6=P("PROVINCE_UPDATE_SLAUGHTER_IDENTITY_SERVICE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("kill_house_percent/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),V6=({killhouseType:e,slaughterKey:t})=>{const r=k(),[a]=C.useContext(D),[n,o]=C.useState(e),l=s=>{r(U6({percentage_key:t,identity:s.target.value})).then(c=>{c.payload.error?a({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(o(s.target.value),r(pu()),r(xu()),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})};return u.jsxs(Eu,{label:"Select Option",value:n,onChange:l,style:{width:140},size:"small",children:[u.jsx(Cu,{value:"KillHouse",children:"کشتارگاه"}),u.jsx(Cu,{value:"Killer",children:"کشتارکن"})]})},q6=({slaughterKey:e,disableSelect:t,killerType:r})=>{const a=k(),[n]=C.useContext(D),[o,l]=C.useState(r),s=c=>{a(Zu({kill_house_key:e,type:c.target.value})).then(d=>{d.payload.error?n({vertical:"top",horizontal:"center",msg:d.payload.error,severity:"error"}):(l(c.target.value),a(pu()),a(xu()),n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})};return u.jsx(u.Fragment,{children:t?"-":u.jsxs(Eu,{disabled:t,label:"Select Option",value:o,onChange:s,style:{width:140},size:"small",children:[u.jsx(Cu,{value:"public",children:"عمومی"}),u.jsx(Cu,{value:"exclusive",children:"اختصاصی"})]})})},M6=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState(),{provinceGetSlaughterhousesQuota:n}=bu(o=>o.provinceSlice);return C.useEffect(()=>{e(pu()),e(xu())},[]),C.useEffect(()=>{const o=n==null?void 0:n.map((l,s)=>{var d,h,y,A,F,x,p,j,E,T,O,f,B,U,m,X,W,iu,J,ju,fu,Su,L,au,ee,te,re,ne,ae,se;const c=(d=l==null?void 0:l.killHouse)!=null&&d.killer?"Killer":"KillHouse";return[s+1,V()==="ProvinceOperator"?(h=l==null?void 0:l.killHouse)!=null&&h.killer?"کشتارکن":"کشتارگاه":u.jsx(V6,{killhouseType:c,slaughterKey:l.key},s),V()==="ProvinceOperator"?(y=l==null?void 0:l.killHouse)!=null&&y.killer?((A=l==null?void 0:l.killHouse)==null?void 0:A.type)==="public"?"عمومی":"اختصاصی":"-":u.jsx(q6,{killerType:(F=l==null?void 0:l.killHouse)==null?void 0:F.type,disableSelect:c==="KillHouse",slaughterKey:(x=l==null?void 0:l.killHouse)==null?void 0:x.key},s),u.jsxs(i,{alignItems:"center",justifyContent:"center",children:[u.jsx(w,{variant:"caption",children:(p=l.killHouse)==null?void 0:p.name}),u.jsx(G,{size:"small",color:"primary","aria-label":"Delete",onClick:()=>{var oe;e(Y({title:"ویرایش",content:u.jsx(W6,{name:(oe=l.killHouse)==null?void 0:oe.name,item:l},l.key)}))},children:u.jsx(ru,{fontSize:"10px"})})]},l.key),u.jsxs(i,{container:!0,alignItems:"center",justifyContent:"center",children:[u.jsxs(w,{variant:"caption",children:[(T=(E=(j=l.killHouse)==null?void 0:j.killHouseOperator)==null?void 0:E.user)==null?void 0:T.fullname," (",(B=(f=(O=l.killHouse)==null?void 0:O.killHouseOperator)==null?void 0:f.user)==null?void 0:B.mobile,")"]}),u.jsx(G,{size:"small",color:"primary","aria-label":"Delete",onClick:()=>{e(Y({title:"ویرایش",content:u.jsx(G6,{item:l},l.key)}))},children:u.jsx(ru,{fontSize:"10px"})})]},l.key),l.killHouseVet?`${(X=(m=(U=l.killHouseVet)==null?void 0:U.vet)==null?void 0:m.user)==null?void 0:X.fullname} (${(J=(iu=(W=l.killHouseVet)==null?void 0:W.vet)==null?void 0:iu.user)==null?void 0:J.mobile})`:"-",`${(Su=(fu=(ju=l.killHouse)==null?void 0:ju.systemAddress)==null?void 0:fu.province)==null?void 0:Su.name} - ${(ee=(au=(L=l.killHouse)==null?void 0:L.systemAddress)==null?void 0:au.city)==null?void 0:ee.name} - ${(re=(te=l.killHouse)==null?void 0:te.systemAddress)==null?void 0:re.address}`,(ne=l==null?void 0:l.killHouse)!=null&&ne.killer?u.jsx(Z0,{slaughterKey:l.key,killHouseForKiller:l.killHouseForKiller,disabled:!1},((ae=l.killHouse)==null?void 0:ae.name)+s):(se=l.killHouse)==null?void 0:se.name,u.jsx(H6,{item:l},l.key)]});a(o)},[n]),u.jsxs(i,{mt:q.SMALL,children:[u.jsxs(i,{container:!0,justifyContent:"space-between",mb:q.SMALL,children:[u.jsxs(i,{children:[u.jsx(R,{variant:"contained",onClick:()=>{e(vu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"ایجاد خریدار",content:u.jsx(z6,{})}))},children:"ایجاد خریدار"}),u.jsx(ou,{title:"خروجی اکسل",children:u.jsx("a",{href:`${_.defaults.baseURL}kill_house_user_excel`,rel:"noreferrer",children:u.jsx(R,{color:"success",children:u.jsx(J0,{size:32})})})})]}),u.jsx(R,{variant:"contained",onClick:()=>{e(O6()).then(o=>{o.payload.error?t({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},children:"پاکسازی اعلام نیاز"})]}),u.jsx(uu,{paginated:!0,title:"کشتارگاه ها",columns:["ردیف","ماهیت","نوع کشتارکن","نام واحد","نام و نام خانوادگی (تلفن)","دامپزشک کشتارگاه (تلفن)","آدرس","محل کشتار","وضعیت"],data:r})]})},H6=({item:e})=>{const t=k(),[r,a]=C.useState(e.killHouse.active),n=o=>{a(o.target.checked);const l=`${_.defaults.baseURL}kill_house/0/`,s={kill_house_key:e.killHouse.key,active:o.target.checked};_.put(l,s).then(()=>{t(pu()),t(xu()),t(K())}).catch(c=>{console.error("Error:",c)})};return u.jsx(v,{control:u.jsx(lu,{checked:r,onChange:n,color:"primary"}),label:r?"فعال":"غیرفعال"})},W6=({name:e,item:t})=>{const r=k(),[a,n]=C.useState(e),o=l=>{n(l.target.value)};return u.jsxs(i,{container:!0,gap:q.TINY,children:[u.jsx(S,{label:"نام واحد",variant:"outlined",fullWidth:!0,value:a,onChange:o}),u.jsx(R,{variant:"contained",fullWidth:!0,onClick:()=>{const l=`${_.defaults.baseURL}kill_house/0/`,s={kill_house_key:t.killHouse.key,name:a};_.put(l,s).then(()=>{r(pu()),r(xu()),r(K())}).catch(c=>{console.error("Error:",c)})},children:"ثبت"})]})},G6=({item:e})=>{var y,A,F,x,p,j,E,T,O;const t=k(),[r,a]=C.useState((F=(A=(y=e.killHouse)==null?void 0:y.killHouseOperator)==null?void 0:A.user)==null?void 0:F.firstName),[n,o]=C.useState((j=(p=(x=e.killHouse)==null?void 0:x.killHouseOperator)==null?void 0:p.user)==null?void 0:j.lastName),[l,s]=C.useState((O=(T=(E=e.killHouse)==null?void 0:E.killHouseOperator)==null?void 0:T.user)==null?void 0:O.mobile),c=f=>{a(f.target.value)},d=f=>{o(f.target.value)},h=f=>{s(f.target.value)};return u.jsxs(i,{container:!0,gap:q.SMALL,children:[u.jsx(S,{label:"نام",variant:"outlined",fullWidth:!0,value:r,onChange:c}),u.jsx(S,{label:"نام خانوادگی",variant:"outlined",fullWidth:!0,value:n,onChange:d}),u.jsx(S,{label:"تلفن",variant:"outlined",fullWidth:!0,value:l,onChange:h}),u.jsx(R,{variant:"contained",fullWidth:!0,onClick:()=>{const f=`${_.defaults.baseURL}kill_house/0/`,B={kill_house_key:e.killHouse.key,first_name:r,last_name:n,mobile:l};_.put(f,B).then(()=>{t(pu()),t(xu()),t(K())}).catch(U=>{console.error("Error:",U)})},children:"ثبت"})]})},$6=P("PROVINCE_CHANGE_SLAUGHTER_CAR_PERMISSION_SERVICE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.post("province_allow_kill_house_register_car/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),K6=({state:e,killHouseKey:t})=>{const r=k(),[a,n]=C.useState(e),o=()=>{n(!a),r($6({allow:!e,kill_house_key:t})).then(l=>{r($e())})};return u.jsx(lu,{checked:a,onChange:o})},Y6=()=>{const e=k(),[t,r]=C.useState([]),{provinceGetOnlyKillHouses:a}=bu(n=>n.provinceSlice);return C.useEffect(()=>{e($e("kill_house"))},[]),C.useEffect(()=>{const n=a==null?void 0:a.map(o=>[o.killer?"کشتارکن":"کشتارگاه",o.name,u.jsx(K6,{killHouseKey:o.key,state:o.allowState},o.key)]);r(n)},[a]),u.jsx(i,{children:u.jsx(u6,{name:"خریداران",columns:["ماهیت","خریدار","دسترسی ثبت خودرو"],data:t})})};var ue={},Q6=Oe;Object.defineProperty(ue,"__esModule",{value:!0});var Je=ue.default=void 0,X6=Q6(Be()),Z6=u;Je=ue.default=(0,X6.default)((0,Z6.jsx)("path",{d:"M19 2H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h4l3 3 3-3h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2m-6 16h-2v-2h2zm2.07-7.75-.9.92C13.45 11.9 13 12.5 13 14h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25"}),"LiveHelp");const J6=P("PROVINCE_GET_POLICY_POULTRY_CHOOSE_KILL_HOUSE_SERVICE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.get("province_allow_poultry_choose_kill_house_total/");return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),ut=P("PROVINCE_POLICY_FREE_SALE_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.post("province_allow_poultry_sell_free_total/",e);return t(g()),{data:r,status:a}}),et=P("PROVINCE_POLICY_GET_FREE_SALE_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("province_allow_poultry_sell_free_total/",e);return t(g()),{data:r,status:a}}),_e=P("PROVINCE_POLICY_POULTRY_CHOOSE_KILL_HOUSE_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.post("province_allow_poultry_choose_kill_house_total/",e);return t(g()),{data:r,status:a}}),tt=P("PROVINCE_POLICY_AUTO_ACCEPT_SLAUGHTER_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.put("auto_accept_province_kill_requests/0/",e);return t(g()),{data:r,status:a}}),rt=P("PROVINCE_POLICY_GET_AUTO_ACCEPT_SLAUGHTER_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("auto_accept_province_kill_requests/",e);return t(g()),{data:r,status:a}}),nt=P("PROVINCE_POLICY_AUTO_ALLOCATE_CAR_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.put("auto_make_kill_house_requests/0/",e);return t(g()),{data:r,status:a}}),at=P("PROVINCE_POLICY_GET_AUTO_ALLOCATE_CAR_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("auto_make_kill_house_requests/",e);return t(g()),{data:r,status:a}}),st=P("GET_LOSSES_PERMISSION_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("losses_permission/");return t(g()),{data:r,status:a}}),me=P("UPDATE_LOSSES_PERMISSION_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.put("losses_permission/0/",e);return t(g()),{data:r,status:a}}),ot=()=>{const[e,t]=C.useState(!0),[r,a]=C.useState(""),[n,o]=C.useState(),l=k();C.useEffect(()=>{l(st()).then(d=>{t(d.payload.data.allow),a(d.payload.data.percent),o(d.payload.data)})},[]),C.useEffect(()=>{e||l(me({permission_key:n.key,allow:!1,percent:parseInt(r)}))},[e]);const s=d=>{t(d.target.checked)},c=d=>{const h=d.target.value;(/^\d*$/.test(h)||h==="")&&a(h)};return u.jsxs(i,{container:!0,alignItems:"center",gap:q.TINY,children:[u.jsx(v,{control:u.jsx(z,{checked:e,onChange:s,name:"item4"}),label:"اعمال درصد تلفات پیش فرض:"}),u.jsx(i,{children:u.jsx(S,{disabled:!e,type:"number",label:"درصد تلفات",size:"small",value:r,onChange:c,inputProps:{inputMode:"numeric",pattern:"[0-9]*"}})}),u.jsx(i,{children:u.jsx(R,{variant:"contained",disabled:!e||!r,onClick:()=>{l(me({permission_key:n.key,percent:parseInt(r),allow:e}))},children:"ثبت"})})]})},lt=P("GET_DIRECT_BUY_PERMISSION_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("allow_direct_buying_total/");return t(g()),{data:r,status:a}}),it=P("POST_DIRECT_BUY_PERMISSION_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.post("allow_direct_buying_total/",e);return t(g()),{data:r,status:a}}),ct=()=>{const e=Ye(),[t,r]=C.useState(!1),a=k();C.useEffect(()=>{a(lt()).then(o=>{r(o.payload.data.allowState)})},[]);const n=o=>{a(it({allow:o.target.checked})),r(o.target.checked)};return u.jsxs(i,{container:!0,alignItems:"center",gap:q.TINY,children:[u.jsx(v,{control:u.jsx(z,{checked:t,onChange:n,name:"item4"}),label:"دسترسی کشتارگاه/کشتارکن برای ثبت خرید مستقیم"}),u.jsx(ou,{title:"مدیریت",children:u.jsx(G,{disabled:!t,color:"success",onClick:()=>{e(`${V()==="AdminX"?l0:V()==="SuperAdmin"?i0:V()==="ProvinceFinancial"?c0:""}`)},children:u.jsx(du,{})})})]})},Ct=P("GET_HOUR_LIMIT_KILL_REQUEST_KILLHOUSE_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("kill_house_hour_limit/");return t(g()),{data:r,status:a}}),ve=P("HOUR_LIMIT_KILL_REQUEST_KILLHOUSE_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.post("kill_house_hour_limit/",e);return t(g()),{data:r,status:a}}),dt=()=>{const e=k(),t=Array.from({length:8},(l,s)=>s+8),[r,a]=C.useState(!1),[n,o]=C.useState("");return C.useEffect(()=>{e(Ct()).then(l=>{a(l.payload.data.active),o(l.payload.data.hour)})},[]),C.useEffect(()=>{r&&n&&e(ve({hour:n,active:r})),!r&&n&&(o(null),e(ve({hour:0,active:r})))},[n,r]),u.jsxs(i,{container:!0,gap:2,children:[u.jsx(v,{control:u.jsx(z,{checked:r,onChange:()=>a(!r)}),label:"محدودیت زمان درخواست کشتار کشتارگاه"}),r&&u.jsxs(Q,{style:{width:200},children:[u.jsx(Ku,{id:"hour-label",children:"ساعت پایان درخواست"}),u.jsx(Eu,{labelId:"hour-label",label:"ساعت پایان درخواست",id:"hour-select",value:n,onChange:l=>o(l.target.value),children:t.map(l=>u.jsxs(Cu,{value:l,children:[l,":00"]},l))})]})]})},ht=P("POLICY_CHANGE_PROVINCE_FEE_SERVICE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("share/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),pt=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState(),n=o=>{a(o.target.value)};return C.useEffect(()=>{e(C0()).then(o=>{a(o.payload.data.provinceUnion)})},[]),u.jsxs(i,{container:!0,alignItems:"center",gap:q.SMALL,children:[u.jsx(i,{children:u.jsx(w,{children:"مبلغ تعرفه استان:"})}),u.jsx(i,{children:u.jsx(S,{InputLabelProps:{shrink:!0},size:"small",label:"مبلغ تعرفه ",type:"number",value:r,onChange:n,style:{width:"160px"},InputProps:{endAdornment:u.jsx(Le,{position:"end",children:"﷼"})}})}),u.jsx(i,{children:u.jsx(R,{variant:"contained",onClick:()=>{e(ht({province_union:Number(r)})).then(o=>{o.payload.error?t({vertical:"top",horizontal:"center",msg:o.error,severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},children:"ثبت"})})]})},je=P("PROVINCE_GET_EVACUATION_PERMIT",async()=>{const{data:e,status:t}=await _.get("evacuation_permit/");return{data:e,status:t}}),xt=P("PROVINCE_EDIT_EVACUATION_PERMIT",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("evacuation_permit/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),gt=P("PROVINCE_SET_SELL_FOR_FREEZING_ACCESSS",async e=>{const{data:t,status:r}=await _.put("sell-for-freezing/0/",e);return{data:t,status:r}}),At=P("PROVINCE_GET_LIMITATION",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.get("operation-limitation/");return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}});function yt(e){return e.replace(/[A-Z]/g,function(t){return"_"+t.toLowerCase()})}const _t=P("PROVINCE_POLICY_UPDATE_LIMITATIONS",async(e,{dispatch:t})=>{t(b());try{const{data:r,status:a}=await _.put("operation-limitation/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),mt=()=>{const e=k(),[t,r]=C.useState();C.useEffect(()=>{e(At()).then(o=>{r(o.payload.data)})},[]);const a=o=>{const{name:l,checked:s}=o.target;r(c=>{const d={...c,[l]:s};return n(d),d})},n=o=>{const l={};for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const c=yt(s);l[c]=o[s]}e(_t(l))};return u.jsx(u.Fragment,{children:t&&u.jsxs(i,{display:"grid",xs:12,children:[u.jsx(v,{control:u.jsx(z,{onChange:a,name:"vetFarmLimitation",checked:t==null?void 0:t.vetFarmLimitation}),label:"محدودیت کد قرنطینه برای بار داخل استان"}),u.jsx(v,{control:u.jsx(z,{checked:t==null?void 0:t.vetFarmOutProvinceLimitation,onChange:a,name:"vetFarmOutProvinceLimitation"}),label:"بار خارج از استان"}),u.jsx(v,{control:u.jsx(z,{checked:t==null?void 0:t.provinceAllocationLimitation,onChange:a,name:"provinceAllocationLimitation"}),label:"محدودیت تخصیص استان به کشتارگاه"}),u.jsx(v,{control:u.jsx(z,{checked:t==null?void 0:t.killHouseAllocationLimitation,onChange:a,name:"killHouseAllocationLimitation"}),label:"محدودیت ایجاد بار برای کشتارگاه"}),u.jsx(v,{control:u.jsx(z,{checked:t==null?void 0:t.killHouseVetLimitation,onChange:a,name:"killHouseVetLimitation"}),label:"محدودیت تایید تخلیه برای دامپزشک"}),u.jsx(v,{control:u.jsx(z,{checked:t==null?void 0:t.vetCheckKillHouseAssignmentLimitation,onChange:a,name:"vetCheckKillHouseAssignmentLimitation"}),label:"محدودیت تایید تخلیه ورود اطلاعات بار"}),u.jsx(v,{control:u.jsx(z,{checked:t==null?void 0:t.killHouseAssignmentLimitation,onChange:a,name:"killHouseAssignmentLimitation"}),label:"محدودیت ورود اطلاعات بار کشتارگاه "}),u.jsx(v,{control:u.jsx(z,{checked:t==null?void 0:t.killHouseInputBarLimitation,onChange:a,name:"killHouseInputBarLimitation"}),label:"محدودیت ورود بار به انبار کشتارگاه"}),u.jsx(v,{control:u.jsx(z,{checked:t==null?void 0:t.killHouseStewardGuildAllocationLimitation,onChange:a,name:"killHouseStewardGuildAllocationLimitation"}),label:"محدودیت تخصیص کشتارگاه به مباشر یا صنف"}),u.jsx(v,{control:u.jsx(z,{checked:t==null?void 0:t.killHouseFreezingLimitation,onChange:a,name:"killHouseFreezingLimitation"}),label:"محدودیت انجماد برای کشتارگاه"}),u.jsx(v,{control:u.jsx(z,{checked:t==null?void 0:t.killHouseFreeSaleLimitation,onChange:a,name:"killHouseFreeSaleLimitation"}),label:"محدودیت فروش آزاد برای کشتارگاه"}),u.jsx(v,{control:u.jsx(z,{checked:t==null?void 0:t.killHouseFreeBuyLimitation,onChange:a,name:"killHouseFreeBuyLimitation"}),label:"محدودیت خرید آزاد برای کشتارگاه"})]})})},fe=P("PROVINCE_EDIT_APPROVED_PRICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.put("approved-price/0/",e);return t(g()),{data:r,status:a}}),Nu=P("PROVINCE_EDIT_KILL_APPROVED_PRICE",async(e,{dispatch:t})=>{t(b());try{const{data:r,status:a}=await _.put("broadcast-price/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),Bu=P("PROVINCE_UPDATE_POLICY_AVICULTURE_COMMIT_SERVICE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("free_sale_within_province/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),vt=({approvedState:e})=>{const t=k(),[r]=C.useContext(D),[a,n]=C.useState(""),[o,l]=C.useState(!1),[s,c]=C.useState(),[d,h]=C.useState("byWeight");C.useEffect(()=>{t(d0()).then(x=>{l(x.payload.data.allow),c(x.payload.data.key),x.payload.data.type==="weight"?(h("byWeight"),n(x.payload.data.weight)):(h("byPercent"),n(x.payload.data.percent))})},[]);const y=x=>{l(x.target.checked),t(Bu({free_sale_key:s,allow:x.target.checked})).then(p=>{p.payload.error?(r({vertical:"top",horizontal:"center",msg:p.payload.error,severity:"error"}),l(!1)):r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},A=x=>{const p=x.target.value;(/^\d*$/.test(p)||p==="")&&n(p)},F=x=>{h(x.target.value)};return C.useEffect(()=>{!e&&s&&(l(!1),t(Bu({free_sale_key:s,allow:!1})))},[e]),u.jsxs(i,{container:!0,alignItems:"center",gap:q.TINY,children:[u.jsx(i,{children:u.jsx(v,{control:u.jsx(z,{checked:o,onChange:y}),label:"تعهد تحویل مرغ به نرخ دولتی"})}),o&&u.jsxs(i,{container:!0,alignItems:"center",children:[u.jsx(i,{children:u.jsx(Q,{component:"fieldset",disabled:!o,children:u.jsxs(Z,{"aria-label":"options",name:"options",value:d,onChange:F,children:[u.jsx(v,{value:"byPercent",control:u.jsx(I,{}),label:"بر اساس درصد تحویل"}),u.jsx(v,{value:"byWeight",control:u.jsx(I,{}),label:"بر اساس وزن قطعه"})]})})}),d&&u.jsxs(i,{container:!0,gap:q.TINY,children:[u.jsx(i,{children:u.jsx(S,{disabled:!o,type:"number",style:{width:"200px"},InputProps:{endAdornment:u.jsx(Le,{position:"end",children:d==="byWeight"?"کیلوگرم":"درصد"})},size:"small",value:a,onChange:A,inputProps:{inputMode:"numeric",pattern:"[0-9]*"}})}),u.jsx(i,{children:u.jsx(R,{variant:"contained",disabled:!o||!a||Number(a)<1,onClick:()=>{t(Bu({free_sale_key:s,allow:o,weight:d==="byWeight"?Number(a):0,percent:d==="byPercent"?Number(a):0,type:d==="byWeight"?"weight":"percent"})).then(x=>{x.payload.error?r({vertical:"top",horizontal:"center",msg:x.payload.error,severity:"error"}):r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},children:"ثبت"})})]})]})]})},jt=({approvedState:e})=>{const t=k(),[r]=C.useContext(D),[a,n]=C.useState(!1),[o,l]=C.useState();C.useEffect(()=>{t(h0()).then(d=>{var h;l(d.payload.data),(h=d.payload.data)!=null&&h.active&&n(!0)})},[]);const s=H({initialValues:{kill_house_price:"",steward_price:"",guild_price:""},validationSchema:M({kill_house_price:N().required("این فیلد اجباری است"),steward_price:N().required("این فیلد اجباری است"),guild_price:N().required("این فیلد اجباری است")})});C.useEffect(()=>{s.validateForm()},[]),C.useEffect(()=>{o!=null&&o.killHousePrice&&a&&(s.setFieldValue("kill_house_price",o==null?void 0:o.killHousePrice),s.setFieldValue("steward_price",o==null?void 0:o.stewardPrice),s.setFieldValue("guild_price",o==null?void 0:o.guildPrice))},[o]);const c=d=>{n(d.target.checked),d.target.checked===!1&&t(Nu({active:!1})).then(h=>{h.payload.error?r({vertical:"top",horizontal:"center",msg:h.payload.error,severity:"error"}):r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})};return C.useEffect(()=>{a&&e&&(n(!1),t(Nu({active:!1})))},[e]),u.jsx(i,{container:!0,xs:12,alignItems:"center",justifyContent:"space-between",direction:"column",children:u.jsxs(i,{container:!0,xs:12,gap:2,alignItems:"center",justifyContent:"start",children:[u.jsx(i,{container:!0,direction:"column",textAlign:"initial",children:u.jsx(i,{children:u.jsx(v,{control:u.jsx(z,{checked:a,onChange:c}),label:"قیمت مصوب کشتارگاه، صنف و مباشر"})})}),a&&u.jsxs(u.Fragment,{children:[u.jsxs(i,{container:!0,xs:12,md:4,lg:4,spacing:1,children:[u.jsx(i,{children:u.jsx(S,{size:"small",label:"قیمت کشتارگاه",name:"kill_house_price",value:s.values.kill_house_price,onChange:s.handleChange,error:s.touched.kill_house_price&&!!s.errors.kill_house_price,helperText:s.touched.kill_house_price&&s.errors.kill_house_price,required:!0})}),u.jsx(i,{children:u.jsx(S,{size:"small",label:"قیمت مباشر",name:"steward_price",value:s.values.steward_price,onChange:s.handleChange,error:s.touched.steward_price&&!!s.errors.steward_price,helperText:s.touched.steward_price&&s.errors.steward_price,required:!0})}),u.jsx(i,{children:u.jsx(S,{size:"small",label:"قیمت صنف",name:"guild_price",value:s.values.guild_price,onChange:s.handleChange,error:s.touched.guild_price&&!!s.errors.guild_price,helperText:s.touched.guild_price&&s.errors.guild_price,required:!0})})]}),u.jsx(i,{container:!0,xs:12,md:2,children:u.jsx(R,{disabled:!s.isValid,variant:"contained",onClick:()=>{t(Nu({active:!0,guild_price:s.values.guild_price,kill_house_price:s.values.kill_house_price,steward_price:s.values.steward_price})).then(d=>{d.payload.error?r({vertical:"top",horizontal:"center",msg:d.payload.error,severity:"error"}):r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},children:"ثبت"})})]})]})})},ft=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState(!1),[n,o]=C.useState(!1),[l,s]=C.useState();C.useEffect(()=>{e(p0()).then(h=>{var y;s(h.payload.data),(y=h.payload.data)!=null&&y.approved&&a(!0)})},[]);const c=H({initialValues:{minWeight:"",maxWeight:"",minPrice:"",maxPrice:""},validationSchema:M({minWeight:N().required("این فیلد اجباری است"),maxWeight:N().required("این فیلد اجباری است"),minPrice:N().required("این فیلد اجباری است"),maxPrice:N().required("این فیلد اجباری است")})});C.useEffect(()=>{c.validateForm()},[]),C.useEffect(()=>{l!=null&&l.highestPrice&&r&&(c.setFieldValue("minWeight",l==null?void 0:l.lowestWeight),c.setFieldValue("maxWeight",l==null?void 0:l.highestWeight),c.setFieldValue("minPrice",l==null?void 0:l.lowestPrice),c.setFieldValue("maxPrice",l==null?void 0:l.highestPrice))},[l]);const d=h=>{a(h.target.checked),h.target.checked===!1&&(o(!0),e(fe({approved:!1})).then(y=>{y.error?t({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})}))};return u.jsxs(i,{container:!0,xs:12,alignItems:"center",justifyContent:"space-between",direction:"column",mt:4,children:[u.jsxs(i,{container:!0,xs:12,gap:2,alignItems:"center",justifyContent:"start",children:[u.jsx(i,{container:!0,direction:"column",textAlign:"initial",children:u.jsx(i,{children:u.jsx(v,{control:u.jsx(z,{checked:r,onChange:d}),label:"قیمت مصوب مرغ زنده"})})}),r&&u.jsxs(u.Fragment,{children:[u.jsxs(i,{container:!0,xs:12,md:4,lg:4,spacing:1,children:[u.jsx(i,{xs:6,children:u.jsx(S,{size:"small",label:"وزن کف (گرم)",name:"minWeight",value:c.values.minWeight,onChange:c.handleChange,error:c.touched.minWeight&&!!c.errors.minWeight,helperText:c.touched.minWeight&&c.errors.minWeight,required:!0})}),u.jsx(i,{xs:6,children:u.jsx(S,{size:"small",label:"وزن سقف (گرم)",name:"maxWeight",value:c.values.maxWeight,onChange:c.handleChange,error:c.touched.maxWeight&&!!c.errors.maxWeight,helperText:c.touched.maxWeight&&c.errors.maxWeight,required:!0})}),u.jsx(i,{xs:6,children:u.jsx(S,{size:"small",label:"قیمت وزن کف (ریال)",name:"minPrice",value:c.values.minPrice,onChange:c.handleChange,error:c.touched.minPrice&&!!c.errors.minPrice,helperText:c.touched.minPrice&&c.errors.minPrice,required:!0})}),u.jsx(i,{xs:6,children:u.jsx(S,{size:"small",label:"قیمت وزن سقف (ریال)",name:"maxPrice",value:c.values.maxPrice,onChange:c.handleChange,error:c.touched.maxPrice&&!!c.errors.maxPrice,helperText:c.touched.maxPrice&&c.errors.maxPrice,required:!0})})]}),u.jsx(i,{container:!0,xs:12,md:2,children:u.jsx(R,{disabled:!c.isValid||c.values.maxPrice<c.values.minPrice||c.values.maxWeight<c.values.minWeight,variant:"contained",onClick:()=>{e(fe({approved:!0,lowest_price:c.values.minPrice,highest_price:c.values.maxPrice,lowest_weight:c.values.minWeight,highest_weight:c.values.maxWeight})).then(h=>{h.error?t({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},children:"ارسال"})})]})]}),u.jsxs(i,{container:!0,xs:12,alignItems:"center",justifyContent:"space-between",mt:2,children:[u.jsx(le,{style:{width:"100%",backgroundColor:"black",marginBottom:"20px"}}),u.jsx(vt,{approvedState:r}),u.jsx(le,{style:{width:"100%",backgroundColor:"black",marginBottom:"20px"}}),u.jsx(jt,{approvedState:n})]})]})},Ft=P("GET_MIN_MAX_AGE_STATE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("chicken-age-range/");return t(g()),{data:r,status:a}}),Fe=P("PROVINCE_EDIT_MIN_MAX_AGE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.put("chicken-age-range/0/",e);return t(g()),{data:r,status:a}}),Et=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState("inactive"),[n,o]=C.useState();C.useEffect(()=>{e(Ft()).then(c=>{var d;o(c.payload.data),(d=c.payload.data)!=null&&d.active&&a("active")})},[]);const l=H({initialValues:{minAge:"",maxAge:""},validationSchema:M({minAge:N().required("این فیلد اجباری است"),maxAge:N().required("این فیلد اجباری است")})});C.useEffect(()=>{l.validateForm()},[]),C.useEffect(()=>{n!=null&&n.minimum&&(l.setFieldValue("minAge",n==null?void 0:n.minimum),l.setFieldValue("maxAge",n==null?void 0:n.maximum),l.validateForm())},[n]);const s=c=>{a(c.target.value)};return u.jsxs(i,{container:!0,xs:12,gap:2,alignItems:"center",justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(w,{variant:"body1",children:"حداقل و حداکثر سن کشتار"}),u.jsx(Q,{children:u.jsxs(Z,{"aria-labelledby":"demo-controlled-radio-buttons-group",name:"controlled-radio-buttons-group",value:r,onChange:s,row:!0,children:[u.jsx(v,{value:"active",control:u.jsx(I,{}),label:"فعال"}),u.jsx(v,{onClick:()=>{e(Fe({active:!1})).then(c=>{c.error?t({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},value:"inactive",control:u.jsx(I,{}),label:"غیر فعال"})]})}),r==="active"&&u.jsxs(u.Fragment,{children:[u.jsxs(i,{container:!0,xs:12,children:[u.jsx(i,{xs:6,children:u.jsx(S,{size:"small",label:"حداقل سن کشتار",name:"minAge",value:l.values.minAge,onChange:l.handleChange,error:l.touched.minAge&&!!l.errors.minAge,helperText:l.touched.minAge&&l.errors.minAge,required:!0})}),u.jsx(i,{xs:6,children:u.jsx(S,{size:"small",label:"حداکثر سن کشتار",name:"maxAge",value:l.values.maxAge,onChange:l.handleChange,error:l.touched.maxAge&&!!l.errors.maxAge,helperText:l.touched.maxAge&&l.errors.maxAge,required:!0})})]}),u.jsx(i,{container:!0,xs:12,md:2,children:u.jsx(R,{disabled:!l.isValid,variant:"contained",onClick:()=>{e(Fe({active:!0,maximum:parseInt(l.values.maxAge),minimum:parseInt(l.values.minAge)})).then(c=>{c.error?t({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},children:"ارسال"})})]})]})},bt=P("GET_MIN_MAX_AGE_STATE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("time-range/");return t(g()),{data:r,status:a}}),Ee=P("PROVINCE_POLICY_EDIT_TIME_RANGE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.put("time-range/0/",e);return t(g()),{data:r,status:a}}),nu=({value:e="",onChange:t,label:r="زمان",disabled:a=!1,className:n=""})=>{const[o,l]=C.useState(e),[s,c]=C.useState(!1),d=C.useRef(null),h=Array.from({length:24},(f,B)=>B.toString().padStart(2,"0")),y=Array.from({length:12},(f,B)=>(B*5).toString().padStart(2,"0"));C.useEffect(()=>{l(e)},[e]);const[A,F]=o?o.split(":"):"",x=A||"00",p=F||"00";C.useEffect(()=>{const f=B=>{d.current&&!d.current.contains(B.target)&&c(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const j=f=>{const B=`${f}:${p}:00`;l(B),t(B)},E=f=>{const B=`${x}:${f}:00`;l(B),t(B),c(!1)},T=f=>{const B=f.target.value;if((/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/.test(B)||B==="")&&(l(B),B.includes(":")&&B.length===5)){const U=`${B}:00`;t(U)}},O=()=>{(!o.includes(":")||o.length!==5)&&l(x+":"+p)};return u.jsxs("div",{className:`time-picker ${n}`,ref:d,children:[u.jsx(w,{children:r&&u.jsx("label",{className:"time-picker-label",children:r})}),u.jsxs("div",{className:"time-picker-input-container",children:[u.jsx("input",{type:"text",value:o.slice(0,5),onChange:T,onBlur:O,onFocus:()=>c(!0),placeholder:"hh:mm",className:"time-picker-input",disabled:a,"aria-haspopup":"listbox","aria-expanded":s}),u.jsx("button",{type:"button",className:"time-picker-toggle",onClick:()=>c(!s),disabled:a,"aria-label":"Toggle time picker",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("polyline",{points:"12 6 12 12 16 14"})]})})]}),s&&u.jsxs("div",{className:"time-picker-dropdown",children:[u.jsxs("div",{className:"time-picker-column",children:[u.jsx("div",{className:"time-picker-header",children:"دقیقه"}),u.jsx("div",{className:"time-picker-list",children:y.map(f=>u.jsx("button",{type:"button",className:`time-picker-item ${f===p?"selected":""}`,onClick:()=>E(f),children:f},f))})]}),u.jsxs("div",{className:"time-picker-column",children:[u.jsx("div",{className:"time-picker-header",children:"ساعت"}),u.jsx("div",{className:"time-picker-list",children:h.map(f=>u.jsx("button",{type:"button",className:`time-picker-item ${f===x?"selected":""}`,onClick:()=>j(f),children:f},f))})]})]})]})},St=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState([{start:"01:00:00",end:"24:00:00",name:"poultry_request",active:!0},{start:"01:00:00",end:"24:00:00",name:"kill_request",active:!1},{start:"01:00:00",end:"24:00:00",name:"province_kill_request",active:!1},{start:"01:00:00",end:"24:00:00",name:"kill_house_request",active:!1},{start:"01:00:00",end:"24:00:00",name:"vet_farm_check_request",active:!1}]);C.useEffect(()=>{e(bt()).then(o=>{const l=o.payload.data.timeRange;a(s=>s.map(c=>{const d=l.find(h=>h.name===c.name);return d?{...c,...d}:c}))})},[]);const n=o=>{let l="درخواست کشتار مرغدار";switch(o){case"poultry_request":l="درخواست کشتار مرغدار";break;case"kill_request":l="ثبت اعلام نیاز کشتارگاه";break;case"province_kill_request":l="تخصیص استان به کشتارگاه";break;case"kill_house_request":l="ایجاد بار کشتارگاه";break;case"vet_farm_check_request":l="ثبت کد قرنطینه";break}return l};return u.jsx(i,{container:!0,xs:12,justifyContent:"center",alignItems:"start",sx:{background:"#EAEFFF",borderRadius:"15px"},children:u.jsx(i,{container:!0,xs:12,justifyContent:"center",alignItems:"start",gap:2,my:2,children:r==null?void 0:r.map((o,l)=>u.jsxs(i,{container:!0,xs:12,alignItems:"center",justifyContent:"start",gap:2,isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(w,{sx:{color:"rgba(0, 0, 0, 0.6)"},children:n(o==null?void 0:o.name)}),u.jsxs(i,{container:!0,xs:12,alignItems:"end",justifyContent:"start",children:[u.jsx(i,{container:!0,direction:"column",children:u.jsx(Q,{children:u.jsxs(Z,{"aria-labelledby":"demo-controlled-radio-buttons-group",name:"controlled-radio-buttons-group",value:o.active,onChange:s=>{const c=r.map((d,h)=>h===l?{...d,active:s.target.value==="true"}:d);a(c),s.target.value==="false"&&e(Ee({time_range:c})).then(d=>{d.payload.error?t({vertical:"top",horizontal:"center",msg:d.payload.error,severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},row:!0,children:[u.jsx(v,{value:!0,control:u.jsx(I,{}),label:"فعال"}),u.jsx(v,{value:!1,control:u.jsx(I,{}),label:"غیر فعال"})]})})}),r[l].active===!0&&u.jsxs(i,{container:!0,justifyContent:"start",alignItems:"start",gap:1,mt:1,children:[u.jsx(i,{children:u.jsx(nu,{value:o==null?void 0:o.start,onChange:s=>{const c=r;c[l].start=s,a(c)},label:"از"})}),u.jsx(i,{children:u.jsx(nu,{value:o==null?void 0:o.end,onChange:s=>{const c=r;c[l].end=s,a(c)},label:"تا"})})]}),r[l].active===!0&&u.jsx(i,{container:!0,mt:1,children:u.jsx(R,{variant:"contained",disabled:(o==null?void 0:o.end)<(o==null?void 0:o.start),onClick:()=>{e(Ee({time_range:r})).then(s=>{s.payload.error?t({vertical:"top",horizontal:"center",msg:s.payload.error,severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},children:"ارسال"})})]})]},l))})})},kt=P("PROVINCE_POLICY_GET_PAYMENT_FRACTIONS",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("payment-gateway-percentage/");return t(g()),{data:r,status:a}}),Pt=P("PROVINCE_POLICY_EDIT_PAYMENT_FRACTIONS",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.put("payment-gateway-percentage/0/",e);return t(g()),{data:r,status:a}}),It=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState(),n=H({initialValues:{website:"",union:"",guilds:"",other:""},validationSchema:M({website:N().required("این فیلد اجباری است!").min(0,"درصدی بیش از 0 وارد کنید!"),union:N().required("این فیلد اجباری است!").min(0,"درصدی بیش از 0 وارد کنید!"),guilds:N().required("این فیلد اجباری است!").min(0,"درصدی بیش از 0 وارد کنید!"),other:N().required("این فیلد اجباری است!").min(0,"درصدی بیش از 0 وارد کنید!")}),onSubmit:o=>{e(Pt({company:o.website,union:o.union,guilds:o.guilds,other:o.other})).then(l=>{l.payload.error?t({vertical:"top",horizontal:"center",msg:l.error,severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})}});return C.useEffect(()=>{n.validateForm()},[]),C.useEffect(()=>{e(kt()).then(o=>{a(o.payload.data)})},[]),C.useEffect(()=>{(r!=null&&r.company||r!=null&&r.guilds||r!=null&&r.union)&&(n.setFieldValue("website",r.company),n.setFieldValue("union",r.union),n.setFieldValue("guilds",r.guilds),n.setFieldValue("other",r.other))},[r]),u.jsx("form",{onSubmit:n.handleSubmit,children:u.jsxs(su,{container:!0,spacing:2,alignItems:"center",children:[u.jsx(su,{container:!0,item:!0,xs:12,children:u.jsx(w,{variant:"body1",gutterBottom:!0,children:"سهم بندی کارمزدها"})}),u.jsx(su,{item:!0,xs:12,sm:3,md:2,children:u.jsx(S,{fullWidth:!0,id:"website",name:"website",label:"سامانه",value:n.values.website,onChange:n.handleChange,onBlur:n.handleBlur,error:n.touched.website&&!!n.errors.website,helperText:n.touched.website&&n.errors.website})}),u.jsx(su,{item:!0,xs:12,sm:3,md:2,children:u.jsx(S,{fullWidth:!0,id:"union",name:"union",label:"اتحادیه",value:n.values.union,onChange:n.handleChange,onBlur:n.handleBlur,error:n.touched.union&&!!n.errors.union,helperText:n.touched.union&&n.errors.union})}),u.jsx(su,{item:!0,xs:12,sm:3,md:2,children:u.jsx(S,{fullWidth:!0,id:"guilds",name:"guilds",label:"اصناف",value:n.values.guilds,onChange:n.handleChange,onBlur:n.handleBlur,error:n.touched.guilds&&!!n.errors.guilds,helperText:n.touched.guilds&&n.errors.guilds})}),u.jsx(su,{item:!0,xs:12,sm:3,md:2,children:u.jsx(S,{fullWidth:!0,id:"other",name:"other",label:"سایر",value:n.values.other,onChange:n.handleChange,onBlur:n.handleBlur,error:n.touched.other&&!!n.errors.other,helperText:n.touched.other&&n.errors.other})}),u.jsx(su,{item:!0,xs:12,sm:3,md:2,children:u.jsxs(w,{variant:"body1",color:"primary",children:["مجموع:"," ",Number(n.values.guilds)+Number(n.values.union)+Number(n.values.website)+Number(n.values.other)," ","درصد"]})}),u.jsx(su,{item:!0,xs:12,md:3,children:u.jsx(R,{disabled:!n.isValid||Number(n.values.guilds)+Number(n.values.union)+Number(n.values.website)+Number(n.values.other)>100,variant:"contained",color:"primary",type:"submit",fullWidth:!0,children:"ثبت"})})]})})},wt=P("PROVINCE_GET_FREE_SALE_STATUS",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.get("poultry-out-province-request/");return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),be=P("PROVINCE_EDIT_FREE_SALE_STATE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("poultry-out-province-request/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),Tt=()=>{const[e,t]=C.useState(!1),[r,a]=C.useState(!1),n=k(),[o]=C.useContext(D),l=H({initialValues:{maxLimit:""},validationSchema:M({maxLimit:N().required("این فیلد اجباری است").max(100,"درصدی بین 1 تا 100 وارد کنید!").min(1,"درصدی بین 1 تا 100 وارد کنید!")})}),s=()=>{n(wt()).then(c=>{t(c.payload.data.allow),c.payload.data.limitationStatus&&a(!0),l.setFieldValue("maxLimit",c.payload.data.limitation)})};return C.useEffect(()=>{s()},[]),C.useEffect(()=>{l.validateForm()},[]),u.jsxs(i,{container:!0,alignItems:"center",gap:2,justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(i,{children:u.jsx(w,{variant:"body1",children:"حداکثر فروش به خارج استان"})}),u.jsxs(i,{container:!0,xs:12,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:e,onClick:()=>{t(!0)}}),label:"فعال"}),u.jsx(v,{control:u.jsx(I,{checked:!e,onClick:()=>{n(be({allow:!1})).then(c=>{c.payload.error?o({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(s(),o({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},name:"item6"}),label:"بدون محدودیت"})]}),e&&u.jsxs(u.Fragment,{children:[u.jsx(i,{children:u.jsx(v,{control:u.jsx(z,{checked:r,onChange:()=>a(!r),color:"primary"}),label:"درصد محدودیت جوجه ریزی"})}),r&&u.jsx(i,{children:u.jsx(S,{size:"small",label:"درصد محدودیت",name:"maxLimit",value:l.values.maxLimit,onChange:l.handleChange,error:l.touched.maxLimit&&!!l.errors.maxLimit,helperText:l.touched.maxLimit&&l.errors.maxLimit,required:!0})}),u.jsx(i,{children:u.jsx(R,{disabled:r?!l.isValid:!1,variant:"contained",onClick:()=>{n(be({allow:!0,limitation_status:!!r,limitation:l.values.maxLimit})).then(c=>{c.payload.error?o({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(s(),o({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ثبت"})})]})]})},Se=P("PROVINCE_EDIT_EXPORT_STATE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("poultry-export/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),Rt=()=>{const[e,t]=C.useState(!1),[r,a]=C.useState(!1),n=k(),[o]=C.useContext(D),l=H({initialValues:{maxLimit:""},validationSchema:M({maxLimit:N().required("این فیلد اجباری است").max(100,"درصدی بین 1 تا 100 وارد کنید!").min(1,"درصدی بین 1 تا 100 وارد کنید!")})}),s=()=>{n(r6()).then(c=>{t(c.payload.data.allow),l.setFieldValue("maxLimit",c.payload.data.limitation)})};return C.useEffect(()=>{s()},[]),C.useEffect(()=>{l.validateForm()},[]),u.jsxs(i,{container:!0,alignItems:"center",gap:2,justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(i,{children:u.jsx(w,{variant:"body1",children:"مجوز صادرات"})}),u.jsxs(i,{container:!0,xs:12,children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:e,onClick:()=>{t(!0)}}),label:"فعال"}),u.jsx(v,{control:u.jsx(I,{checked:!e,onClick:()=>{n(Se({allow:!1})).then(c=>{c.payload.error?o({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(s(),o({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},name:"item6"}),label:"غیر فعال"})]}),e&&u.jsxs(u.Fragment,{children:[u.jsx(i,{children:u.jsx(v,{control:u.jsx(z,{checked:r,onChange:()=>a(!r),color:"primary"}),label:"درصد محدودیت جوجه ریزی"})}),r&&u.jsx(i,{children:u.jsx(S,{size:"small",label:"درصد محدودیت",name:"maxLimit",value:l.values.maxLimit,onChange:l.handleChange,error:l.touched.maxLimit&&!!l.errors.maxLimit,helperText:l.touched.maxLimit&&l.errors.maxLimit,required:!0})}),u.jsx(i,{children:u.jsx(R,{disabled:r?!l.isValid:!1,variant:"contained",onClick:()=>{n(Se({allow:!0,limitation_status:!!r,limitation:l.values.maxLimit})).then(c=>{c.payload.error?o({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(s(),o({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ثبت"})})]})]})},Dt=()=>{const[e,t]=C.useState(!1),r=k(),[a]=C.useContext(D),n=H({initialValues:{maxLimit:""},validationSchema:M({maxLimit:N().required("این فیلد اجباری است")})}),o=()=>{r(s6()).then(l=>{t(l.payload.data.allow),n.setFieldValue("maxLimit",l.payload.data.limitation)})};return C.useEffect(()=>{o()},[]),C.useEffect(()=>{n.validateForm()},[]),u.jsxs(i,{container:!0,alignItems:"center",gap:2,justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(i,{children:u.jsx(w,{variant:"body1",children:"مجوز ادغام بار (کد قرنطینه) "})}),u.jsxs(i,{container:!0,xs:12,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:e,onClick:()=>{t(!0)}}),label:"فعال"}),u.jsx(v,{control:u.jsx(I,{checked:!e,onClick:()=>{r(pe({allow:!1})).then(l=>{l.payload.error?a({vertical:"top",horizontal:"center",msg:l.payload.error,severity:"error"}):(o(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},name:"item6"}),label:"غیر فعال"})]}),e&&u.jsxs(u.Fragment,{children:[u.jsx(i,{children:u.jsx(S,{size:"small",label:"میزان محدودیت (براساس تعداد)",name:"maxLimit",value:n.values.maxLimit,onChange:n.handleChange,error:n.touched.maxLimit&&!!n.errors.maxLimit,helperText:n.touched.maxLimit&&n.errors.maxLimit,required:!0})}),u.jsx(i,{children:u.jsx(R,{disabled:!n.isValid,variant:"contained",onClick:()=>{r(pe({allow:!0,limitation:n.values.maxLimit})).then(l=>{l.payload.error?a({vertical:"top",horizontal:"center",msg:l.payload.error,severity:"error"}):(o(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ثبت"})})]})]})},Ot=()=>{const[e,t]=C.useState(!1),r=k(),[a]=C.useContext(D),n=H({initialValues:{maxLimit:""},validationSchema:M({maxLimit:N().required("این فیلد اجباری است")})}),o=()=>{r(o6()).then(l=>{t(l.payload.data.allow),n.setFieldValue("maxLimit",l.payload.data.limitation)})};return C.useEffect(()=>{o()},[]),C.useEffect(()=>{n.validateForm()},[]),u.jsxs(i,{container:!0,alignItems:"center",gap:2,justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(i,{children:u.jsx(w,{variant:"body1",children:"حداکثر حجم بار تخصیصی به خودرو"})}),u.jsxs(i,{container:!0,xs:12,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:e,onClick:()=>{t(!0)}}),label:"فعال"}),u.jsx(v,{control:u.jsx(I,{checked:!e,onClick:()=>{r(xe({allow:!1})).then(l=>{l.payload.error?a({vertical:"top",horizontal:"center",msg:l.payload.error,severity:"error"}):(o(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},name:"item6"}),label:"غیر فعال"})]}),e&&u.jsxs(u.Fragment,{children:[u.jsx(i,{children:u.jsx(S,{size:"small",label:"میزان محدودیت (براساس تعداد)",name:"maxLimit",value:n.values.maxLimit,onChange:n.handleChange,error:n.touched.maxLimit&&!!n.errors.maxLimit,helperText:n.touched.maxLimit&&n.errors.maxLimit,required:!0})}),u.jsx(i,{children:u.jsx(R,{fullWidth:!0,disabled:!n.isValid,variant:"contained",onClick:()=>{r(xe({allow:!0,limitation:n.values.maxLimit})).then(l=>{l.payload.error?a({vertical:"top",horizontal:"center",msg:l.payload.error,severity:"error"}):(o(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ثبت"})})]})]})},Lt=()=>{const[e,t]=C.useState(!1),r=k(),[a]=C.useContext(D),n=()=>{r(l6()).then(o=>{t(o.payload.data.allow)})};return C.useEffect(()=>{n()},[]),u.jsxs(i,{container:!0,alignItems:"center",gap:2,justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(i,{children:u.jsx(w,{variant:"body1",children:"ثبت قیمت خرید توسط کشتارگاه"})}),u.jsxs(i,{container:!0,xs:12,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:e,onClick:()=>{t(!0),r(ge({allow:!0})).then(o=>{o.payload.error?a({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(n(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}}),label:"فعال"}),u.jsx(v,{control:u.jsx(I,{checked:!e,name:"item6",onClick:()=>{t(!1),r(ge({allow:!1})).then(o=>{o.payload.error?a({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(n(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}}),label:"غیر فعال"})]})]})},Nt=P("GET_AUTO_DIRECT_BUYING",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("automatic-direct-buying-permission/");return t(g()),{data:r,status:a}}),ke=P("PROVINCE_AUTO_DIRECT_BUYING",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.put("automatic-direct-buying-permission/0/",e);return t(g()),{data:r,status:a}}),Bt=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState("inactive"),[n,o]=C.useState();C.useEffect(()=>{e(Nt()).then(c=>{var d;o(c.payload.data),(d=c.payload.data)!=null&&d.allow&&a("active")})},[]);const l=H({initialValues:{hour:"",hour2:"",minute:"",minute2:""},validationSchema:M({hour:$().required("این فیلد اجباری است"),hour2:$().required("این فیلد اجباری است")})});C.useEffect(()=>{l.validateForm()},[]),C.useEffect(()=>{n!=null&&n.allow&&(l.setFieldValue("hour",n==null?void 0:n.startTime),l.setFieldValue("hour2",n==null?void 0:n.endTime),l.validateForm())},[n]);const s=c=>{a(c.target.value)};return u.jsxs(i,{container:!0,xs:12,alignItems:"center",justifyContent:"start",isPolicy:!0,gap:2,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(w,{sx:{color:"rgba(0, 0, 0, 0.6)"},children:"تایید خودکار خرید مستقیم"}),u.jsxs(i,{container:!0,xs:12,alignItems:"end",justifyContent:"start",children:[u.jsx(i,{container:!0,direction:"column",children:u.jsx(Q,{children:u.jsxs(Z,{"aria-labelledby":"demo-controlled-radio-buttons-group",name:"controlled-radio-buttons-group",value:r,onChange:s,row:!0,children:[u.jsx(v,{value:"active",control:u.jsx(I,{}),label:"فعال"}),u.jsx(v,{onClick:()=>{e(ke({allow:!1})).then(c=>{c.error?t({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},value:"inactive",control:u.jsx(I,{}),label:"غیر فعال"})]})})}),r==="active"&&u.jsxs(i,{container:!0,justifyContent:"start",alignItems:"start",gap:1,mt:1,children:[u.jsx(i,{children:u.jsx(nu,{value:l.values.hour,onChange:c=>{l.setFieldValue("hour",c)},label:"از"})}),u.jsx(i,{children:u.jsx(nu,{value:l.values.hour2,onChange:c=>{l.setFieldValue("hour2",c)},label:"تا"})})]})]}),r==="active"&&u.jsx(i,{container:!0,children:u.jsx(R,{variant:"contained",disabled:!l.isValid||l.values.hour>l.values.hour2,onClick:()=>{e(ke({allow:!0,start_time:l.values.hour,end_time:l.values.hour2})).then(c=>{c.error?t({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},children:"ارسال"})})]})},zt=()=>{const[e,t]=C.useState(!1),r=k(),[a]=C.useContext(D),n=()=>{r(t6()).then(o=>{t(o.payload.data.poultryStatus)})};return C.useEffect(()=>{n()},[]),u.jsxs(i,{container:!0,alignItems:"center",gap:2,justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(i,{children:u.jsx(w,{variant:"body1",children:"احراز پیامکی قیمت مرغ برای مرغدار"})}),u.jsxs(i,{container:!0,xs:12,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:e,onClick:()=>{t(!0),r(de({poultry_status:!0})).then(o=>{o.payload.error?a({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(n(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}}),label:"فعال"}),u.jsx(v,{control:u.jsx(I,{checked:!e,name:"item6",onClick:()=>{t(!1),r(de({poultry_status:!1})).then(o=>{o.payload.error?a({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(n(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}}),label:"غیر فعال"})]})]})},Ut=P("PROVINCE_EDIT_DROP_LIMITED_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.put("/drop-limit/0/",e);return t(g()),{data:r,status:a}}),Vt=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState();C.useEffect(()=>{e(i6()).then(o=>{a(o.payload.data)})},[]);const n=H({initialValues:{limitDown:"",limitUp:""},validationSchema:M({limitDown:N().required("این فیلد اجباری است").min(0,"حداقل مقدار باید 0 باشد").max(100,"حداکثر مقدار باید 100 باشد"),limitUp:N().required("این فیلد اجباری است").min(0,"حداقل مقدار باید 0 باشد").max(100,"حداکثر مقدار باید 100 باشد")})});return C.useEffect(()=>{n.validateForm()},[]),C.useEffect(()=>{r!=null&&r.killHouseLimitPercentDown&&(n.setFieldValue("limitDown",r==null?void 0:r.killHouseLimitPercentDown),n.setFieldValue("limitUp",r==null?void 0:r.killHouseLimitPercentUp),n.validateForm())},[r]),u.jsxs(i,{container:!0,xs:12,gap:2,alignItems:"center",justifyContent:"space-between",sx:{width:"370px"},isPolicy:!0,children:[u.jsx(w,{variant:"body1",children:"حداقل و حداکثرافت برای کشتارگاه"}),u.jsxs(i,{container:!0,xs:12,children:[u.jsx(i,{xs:6,children:u.jsx(S,{size:"small",label:"حداقل افت کشتار (درصد)",name:"limitDown",value:n.values.limitDown,onChange:n.handleChange,error:n.touched.limitDown&&!!n.errors.limitDown,helperText:n.touched.limitDown&&n.errors.limitDown,required:!0,type:"number",inputProps:{min:0,max:100}})}),u.jsx(i,{xs:6,children:u.jsx(S,{size:"small",label:"حداکثر افت کشتار (درصد)",name:"limitUp",value:n.values.limitUp,onChange:n.handleChange,error:n.touched.limitUp&&!!n.errors.limitUp,helperText:n.touched.limitUp&&n.errors.limitUp,required:!0,type:"number",inputProps:{min:0,max:100}})})]}),u.jsx(i,{container:!0,xs:12,md:2,children:u.jsx(R,{disabled:!n.isValid,variant:"contained",onClick:()=>{e(Ut({active:!0,kill_house_limit_percent_up:parseInt(n.values.limitUp),kill_house_limit_percent_down:parseInt(n.values.limitDown)})).then(o=>{o.error?t({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},children:"ارسال"})})]})},qt=()=>{const[e,t]=C.useState(!1),r=k(),[a]=C.useContext(D),n=()=>{r(Ru()).then(o=>{t(o.payload.data.killHouseAllocation)})};return C.useEffect(()=>{n()},[]),u.jsxs(i,{container:!0,alignItems:"center",gap:2,justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(i,{children:u.jsx(w,{variant:"body1",children:"سند توزیع داخل استان کشتارگاه"})}),u.jsxs(i,{container:!0,xs:12,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:e,onClick:()=>{t(!0),r(hu({kill_house_allocation:!0})).then(o=>{o.payload.error?a({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(n(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}}),label:"اجباری"}),u.jsx(v,{control:u.jsx(I,{checked:!e,name:"item6",onClick:()=>{t(!1),r(hu({kill_house_allocation:!1})).then(o=>{o.payload.error?a({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(n(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}}),label:"اختیاری"})]})]})},Mt=()=>{const[e,t]=C.useState(!1),r=k(),[a]=C.useContext(D),n=()=>{r(Ru()).then(o=>{t(o.payload.data.killHouseFreeSale)})};return C.useEffect(()=>{n()},[]),u.jsxs(i,{container:!0,alignItems:"center",gap:2,justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(i,{children:u.jsx(w,{variant:"body1",children:"سند توزیع خارج استان کشتارگاه"})}),u.jsxs(i,{container:!0,xs:12,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:e,onClick:()=>{t(!0),r(hu({kill_house_free_sale:!0})).then(o=>{o.payload.error?a({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(n(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}}),label:"اجباری"}),u.jsx(v,{control:u.jsx(I,{checked:!e,name:"item6",onClick:()=>{t(!1),r(hu({kill_house_free_sale:!1})).then(o=>{o.payload.error?a({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(n(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}}),label:"اختیاری"})]})]})},Ht=()=>{const[e,t]=C.useState(!1),r=k(),[a]=C.useContext(D),n=()=>{r(Ru()).then(o=>{t(o.payload.data.stewardAllocation)})};return C.useEffect(()=>{n()},[]),u.jsxs(i,{container:!0,alignItems:"center",gap:2,justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(i,{children:u.jsx(w,{variant:"body1",children:"سند توزیع داخل استان مباشر"})}),u.jsxs(i,{container:!0,xs:12,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:e,onClick:()=>{t(!0),r(hu({steward_allocation:!0})).then(o=>{o.payload.error?a({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(n(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}}),label:"اجباری"}),u.jsx(v,{control:u.jsx(I,{checked:!e,name:"item6",onClick:()=>{t(!1),r(hu({steward_allocation:!1})).then(o=>{o.payload.error?a({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(n(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}}),label:"اختیاری"})]})]})},Wt=()=>{const[e,t]=C.useState(!1),r=k(),[a]=C.useContext(D),n=()=>{r(Ru()).then(o=>{t(o.payload.data.steward_free_sale)})};return C.useEffect(()=>{n()},[]),u.jsxs(i,{container:!0,alignItems:"center",gap:2,justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(i,{children:u.jsx(w,{variant:"body1",children:"سند توزیع خارج استان مباشر"})}),u.jsxs(i,{container:!0,xs:12,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:e,onClick:()=>{t(!0),r(hu({steward_free_sale:!0})).then(o=>{o.payload.error?a({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(n(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}}),label:"اجباری"}),u.jsx(v,{control:u.jsx(I,{checked:!e,name:"item6",onClick:()=>{t(!1),r(hu({steward_free_sale:!1})).then(o=>{o.payload.error?a({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(n(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}}),label:"اختیاری"})]})]})},Gt=P("DIRECT_EDIT_BUYING_VERIFICATION",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("direct-buying-verification/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),Pe=P("DIRECT_BUYING_VERIFICATION",async()=>{const{data:e,status:t}=await _.get("direct-buying-verification/");return{data:e,status:t}}),Ie=P("PAYMENT_EDIT_DEADLINES",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("direct-buying-verification/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),$t=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState(!1),[n,o]=C.useState(!1),l=H({initialValues:{payment_deadline_days:""},validationSchema:M({payment_deadline_days:N().required("این فیلد اجباری است").min(0,"حداقل مقدار باید 0 باشد").max(100,"حداکثر مقدار باید 100 باشد")})});C.useEffect(()=>{e(Pe()).then(h=>{var A;const y=(A=h.payload.data)==null?void 0:A.poultryCodeMandatory;a(y)}),e(c6()).then(h=>{var A,F,x,p;const y=((F=(A=h.payload)==null?void 0:A.data)==null?void 0:F.paymentDeadline)??!1;o(y),y&&((p=(x=h.payload)==null?void 0:x.data)!=null&&p.paymentDeadlineDays)&&l.setFieldValue("payment_deadline_days",h.payload.data.paymentDeadlineDays)})},[]);const s=h=>{e(Gt({poultry_code_mandatory:h})).then(()=>{e(Pe()).then(y=>{var A,F;a((F=(A=y.payload)==null?void 0:A.data)==null?void 0:F.poultryCodeMandatory)})})},c=h=>{const y=h===!0;y||e(Ie({payment_deadline:!1,payment_deadline_days:0})).then(A=>{A.error?t({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):t({vertical:"top",horizontal:"center",msg:"غیرفعال شد.",severity:"success"})}),o(y)},d=()=>{e(Ie({payment_deadline:!0,payment_deadline_days:parseInt(l.values.payment_deadline_days)})).then(h=>{h.error?t({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):t({vertical:"top",horizontal:"center",msg:"تنظیمات با موفقیت ذخیره شد.",severity:"success"})})};return u.jsxs(u.Fragment,{children:[u.jsxs(i,{container:!0,alignItems:"center",isPolicy:!0,gap:2,sx:{width:{xs:"100%",sm:"48%",lg:"19%"}},children:[u.jsx(w,{variant:"body1",children:"ثبت کداحراز خرید مستقیم مرغدار"}),u.jsxs(i,{xs:12,container:!0,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:r===!0,onClick:()=>{s(!0)}}),label:"اجباری"}),u.jsx(v,{control:u.jsx(I,{checked:r===!1,onClick:()=>{s(!1)},name:"item6"}),label:"اختیاری"})]})]}),u.jsxs(i,{container:!0,alignItems:"center",isPolicy:!0,gap:2,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(w,{variant:"body1",children:"حداکثر مهلت تسویه با مرغدار"}),u.jsxs(i,{xs:12,container:!0,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:n===!0,onClick:()=>c(!0)}),label:"فعال"}),u.jsx(v,{control:u.jsx(I,{checked:n===!1,onClick:()=>c(!1),name:"item6"}),label:"غیر فعال"})]}),n!==!1&&u.jsxs(u.Fragment,{children:[u.jsx(i,{xs:12,children:u.jsx(S,{size:"small",label:"تعداد روز",name:"payment_deadline_days",value:l.values.payment_deadline_days,onChange:l.handleChange,error:l.touched.payment_deadline_days&&!!l.errors.payment_deadline_days,helperText:l.touched.payment_deadline_days&&l.errors.payment_deadline_days,required:!0,type:"number",inputProps:{min:0,max:100}})}),u.jsx(i,{container:!0,xs:12,md:2,children:u.jsx(R,{variant:"contained",disabled:!l.values.payment_deadline_days||l.errors.payment_deadline_days,onClick:d,children:"ارسال"})})]})]})]})},Kt={start_time:"01:00:00",end_time:"24:00:00",allow:!1},Yt=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState(Kt);C.useEffect(()=>{e(C6()).then(l=>{const s=l.payload.data;a({start_time:s.startTime,end_time:s.endTime,allow:s.allow})})},[e]);const n=l=>{const s=l.target.value==="true",c={...r,allow:s};a(c),s||e(Ae({allow:!1})).then(d=>{var h;(h=d.payload)!=null&&h.error?t({vertical:"top",horizontal:"center",msg:d.payload.error,severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},o=()=>{e(Ae(r)).then(l=>{var s;(s=l.payload)!=null&&s.error?t({vertical:"top",horizontal:"center",msg:l.payload.error,severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})};return u.jsxs(i,{container:!0,xs:12,alignItems:"center",justifyContent:"start",gap:2,isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(w,{sx:{color:"rgba(0, 0, 0, 0.6)"},children:"بازه نمایش معاملات"}),u.jsxs(i,{container:!0,xs:12,alignItems:"end",justifyContent:"start",children:[u.jsx(i,{container:!0,direction:"column",children:u.jsx(Q,{children:u.jsxs(Z,{"aria-labelledby":"time-range-active",name:"time-range-active",value:String(r.allow),onChange:n,row:!0,children:[u.jsx(v,{value:"true",control:u.jsx(I,{}),label:"فعال"}),u.jsx(v,{value:"false",control:u.jsx(I,{}),label:"غیر فعال"})]})})}),r.allow&&u.jsxs(i,{container:!0,justifyContent:"start",alignItems:"start",gap:1,mt:1,children:[u.jsx(i,{children:u.jsx(nu,{value:r.start_time,onChange:l=>a(s=>({...s,start_time:l})),label:"از"})}),u.jsx(i,{children:u.jsx(nu,{value:r.end_time,onChange:l=>a(s=>({...s,end_time:l})),label:"تا"})})]}),r.allow&&u.jsx(i,{container:!0,mt:1,children:u.jsx(R,{variant:"contained",disabled:r.end_time<r.start_time,onClick:o,children:"ارسال"})})]})]})},Qt=()=>{const[e,t]=C.useState(!1),[r,a]=C.useState(null),n=k(),[o]=C.useContext(D);C.useEffect(()=>{(async()=>{try{n(b());const c=await _.get("/allow_register_code_for_steward_free_sale_bar_information");c.data&&(t(c.data.active),a(c.data.id)),n(g())}catch(c){console.error("Error fetching data:",c),n(g())}})()},[n]);const l=async s=>{if(r!==null)try{n(b()),await _.put(`/allow_register_code_for_steward_free_sale_bar_information/${r}/`,{active:s}),t(s),o({vertical:"top",horizontal:"center",msg:"تغییرات با موفقیت ثبت شد",severity:"success"}),n(g())}catch(c){console.error("Error updating data:",c),o({vertical:"top",horizontal:"center",msg:"خطا در ثبت تغییرات",severity:"error"}),n(g())}};return u.jsxs(i,{container:!0,alignItems:"center",isPolicy:!0,gap:2,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(w,{variant:"body1",children:"اجباری بودن کد احراز مباشر"}),u.jsxs(i,{xs:12,container:!0,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"supervisor-authentication",checked:e===!0,onClick:()=>l(!0)}),label:"فعال"}),u.jsx(v,{control:u.jsx(I,{name:"supervisor-authentication",checked:e===!1,onClick:()=>l(!1)}),label:"غیر فعال"})]})]})},Xt=()=>{const[e,t]=C.useState(!1),[r,a]=C.useState(null),n=k(),[o]=C.useContext(D);C.useEffect(()=>{(async()=>{try{n(b());const c=await _.get("/allow_register_code_for_kill_house_free_sale_bar_information");c.data&&(t(c.data.active),a(c.data.id)),n(g())}catch(c){console.error("Error fetching data:",c),n(g())}})()},[n]);const l=async s=>{if(r!==null)try{n(b()),await _.put(`/allow_register_code_for_kill_house_free_sale_bar_information/${r}/`,{active:s}),t(s),o({vertical:"top",horizontal:"center",msg:"تغییرات با موفقیت ثبت شد",severity:"success"}),n(g())}catch(c){console.error("Error updating data:",c),o({vertical:"top",horizontal:"center",msg:"خطا در ثبت تغییرات",severity:"error"}),n(g())}};return u.jsxs(i,{container:!0,alignItems:"center",isPolicy:!0,gap:2,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(w,{variant:"body1",children:"اجباری بودن کد احراز کشتارگاه"}),u.jsxs(i,{xs:12,container:!0,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"slaughterhouse-verification",checked:e===!0,onClick:()=>l(!0)}),label:"فعال"}),u.jsx(v,{control:u.jsx(I,{name:"slaughterhouse-verification",checked:e===!1,onClick:()=>l(!1)}),label:"غیر فعال"})]})]})},Zt=P("PROVINCE_POLICY_GET_DIRECT_PURCHASE_BAR_LIMITATION",async(e,{dispatch:t})=>{var r,a;try{t(b());const{data:n,status:o}=await _.get("limitation_for_direct_purchase_and_bar_information/");return t(g()),{data:n,status:o}}catch(n){return t(g()),{error:((a=(r=n.response)==null?void 0:r.data)==null?void 0:a.result)||"خطا در دریافت اطلاعات"}}}),we=P("PROVINCE_POLICY_EDIT_DIRECT_PURCHASE_BAR_LIMITATION",async({id:e,data:t},{dispatch:r})=>{var a,n;try{r(b());const{data:o,status:l}=await _.put(`limitation_for_direct_purchase_and_bar_information/${e}/`,t);return r(g()),{data:o,status:l}}catch(o){return r(g()),{error:((n=(a=o.response)==null?void 0:a.data)==null?void 0:n.result)||"خطا در ویرایش اطلاعات"}}}),Jt={id:null,key:null,active:!1,start_time:"08:00:00",end_time:"18:00:00",allowBuying:null},ur=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState(Jt);C.useEffect(()=>{e(Zt()).then(s=>{var c;if((c=s.payload)!=null&&c.data){const d=s.payload.data;a({id:d.id,key:d.key,active:d.active,start_time:d.startTime,end_time:d.endTime,allowBuying:d.allowBuying??null})}})},[e]);const n=s=>{const c=s.target.value==="true",d={...r,active:c};a(d),c||e(we({id:r.id,data:{active:!1}})).then(h=>{var y,A;if((y=h.payload)!=null&&y.error)t({vertical:"top",horizontal:"center",msg:h.payload.error,severity:"error"});else if((A=h.payload)!=null&&A.data){const F=h.payload.data;a(x=>({...x,id:F.id??x.id,key:F.key??x.key,active:F.active??x.active,start_time:F.startTime??x.start_time,end_time:F.endTime??x.end_time,allowBuying:F.allowBuying??x.allowBuying})),t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})}})},o=s=>{const c=s.target.value==="بلی";a(d=>({...d,allowBuying:c}))},l=()=>{e(we({id:r.id,data:{active:r.active,start_time:r.start_time,end_time:r.end_time,allow_buying:r.allowBuying}})).then(s=>{var c,d;if((c=s.payload)!=null&&c.error)t({vertical:"top",horizontal:"center",msg:s.payload.error,severity:"error"});else if((d=s.payload)!=null&&d.data){const h=s.payload.data;a({id:h.id??r.id,key:h.key??r.key,active:h.active??r.active,start_time:h.startTime??r.start_time,end_time:h.endTime??r.end_time,allowBuying:h.allowBuying??r.allowBuying}),t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})}})};return u.jsxs(i,{container:!0,xs:12,alignItems:"center",justifyContent:"start",gap:2,isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"19%",nxl:"19%"}},children:[u.jsx(w,{sx:{color:"rgba(0, 0, 0, 0.6)"},children:"بازهی اضطراری خرید و ایجاد بعدی"}),u.jsxs(i,{container:!0,xs:12,alignItems:"end",justifyContent:"start",children:[u.jsx(i,{container:!0,direction:"column",children:u.jsx(Q,{children:u.jsxs(Z,{"aria-labelledby":"limitation-active",name:"limitation-active",value:String(r.active),onChange:n,row:!0,children:[u.jsx(v,{value:"true",control:u.jsx(I,{}),label:"فعال"}),u.jsx(v,{value:"false",control:u.jsx(I,{}),label:"غیر فعال"})]})})}),r.active&&u.jsxs(i,{container:!0,justifyContent:"start",alignItems:"start",gap:1,mt:1,children:[u.jsx(i,{children:u.jsx(nu,{value:r.start_time,onChange:s=>a(c=>({...c,start_time:s})),label:"از"})}),u.jsx(i,{children:u.jsx(nu,{value:r.end_time,onChange:s=>a(c=>({...c,end_time:s})),label:"تا"})})]}),r.active&&u.jsxs(i,{mt:2,xs:12,children:[u.jsx(w,{sx:{color:"rgba(0, 0, 0, 0.6)",mb:1,fontSize:16,width:"fit-content"},justifyContent:"flex-start",children:"اجازه خرید دارد؟"}),u.jsx(Q,{children:u.jsxs(Z,{"aria-labelledby":"allow-buying-radio",name:"allow-buying-radio",value:r.allowBuying===!0?"بلی":r.allowBuying===!1?"خیر":"",onChange:o,row:!0,children:[u.jsx(v,{value:"بلی",control:u.jsx(I,{}),label:"بلی"}),u.jsx(v,{value:"خیر",control:u.jsx(I,{}),label:"خیر"})]})})]}),r.active&&u.jsx(i,{container:!0,mt:1,xs:12,children:u.jsx(R,{variant:"contained",disabled:r.end_time<r.start_time,onClick:l,children:"ارسال"})})]})]})},Iu=[{key:"includeTotalDiseaseLosses",apiKey:"include_total_disease_losses",label:"مجموع تلفات ناشی از بیماری"},{key:"includeTotalFlockDestruction",apiKey:"include_total_flock_destruction",label:"مجموع معدومسازی گله"},{key:"includeTotalNormalFlockLosses",apiKey:"include_total_normal_flock_losses",label:"مجموع تلفات عادی گله"},{key:"includeTotalForceMajeureLosses",apiKey:"include_total_force_majeure_losses",label:"مجموع تلفات ناشی از عوامل قهری و طبیعی"},{key:"includeTotalFireLosses",apiKey:"include_total_fire_losses",label:"مجموع تلفات ناشی از آتشسوزی"}],er=Iu.reduce((e,{key:t})=>({...e,[t]:!1}),{}),tr=()=>{const[e]=C.useContext(D),t=C.useCallback(({severity:F,msg:x,vertical:p="top",horizontal:j="center"})=>e({severity:F,msg:x,vertical:p,horizontal:j}),[e]),[r,a]=C.useState(er),[n,o]=C.useState(null),[l,s]=C.useState(!0),[c,d]=C.useState(!1);C.useEffect(()=>{(async()=>{var x,p,j,E;s(!0);try{const{data:T}=await _.get("hatching-loss-management/");o((T==null?void 0:T.id)??null),a(O=>Iu.reduce((f,{key:B})=>({...f,[B]:!!(T!=null&&T[B])}),{...O}))}catch(T){const O=((p=(x=T==null?void 0:T.response)==null?void 0:x.data)==null?void 0:p.detail)??((E=(j=T==null?void 0:T.response)==null?void 0:j.data)==null?void 0:E.message)??(T==null?void 0:T.message)??"خطایی در دریافت اطلاعات رخ داده است.";t({severity:"error",msg:O})}finally{s(!1)}})()},[]);const h=F=>x=>{const{checked:p}=x.target;a(j=>({...j,[F]:p}))},y=C.useMemo(()=>Iu.reduce((F,{key:x,apiKey:p})=>(F[p]=!!r[x],F),{}),[r]),A=async F=>{var p,j,E,T;F.preventDefault(),d(!0);const x=n??1;try{await _.patch(`hatching-loss-management/${x}/`,y),t({severity:"success",msg:"اطلاعات با موفقیت بهروزرسانی شد."})}catch(O){const f=((j=(p=O==null?void 0:O.response)==null?void 0:p.data)==null?void 0:j.detail)??((T=(E=O==null?void 0:O.response)==null?void 0:E.data)==null?void 0:T.message)??(O==null?void 0:O.message)??"خطایی در بهروزرسانی اطلاعات رخ داده است.";t({severity:"error",msg:f})}finally{d(!1)}};return u.jsx(su,{component:"section",xs:12,style:{padding:"20px",width:"100%"},children:l?u.jsx(e0,{direction:"row",justifyContent:"center",children:u.jsx(t0,{})}):u.jsxs(su,{component:"form",onSubmit:A,xs:12,children:[u.jsx(r0,{children:Iu.map(({key:F,label:x})=>u.jsx(v,{control:u.jsx(z,{checked:!!r[F],onChange:h(F),name:F,disabled:c}),label:x},F))}),u.jsx(cu,{children:u.jsx(R,{type:"submit",variant:"contained",disabled:c,color:"primary",children:c?"در حال ذخیره...":"بهروزرسانی"})})]})})},rr=()=>{const[e,t]=C.useState(!1),r=k(),[a]=C.useContext(D),n=H({initialValues:{quantity:""},validationSchema:M({quantity:N().required("این فیلد اجباری است").min(1,"حداقل مقدار باید 1 باشد")})}),o=()=>{r(n6()).then(s=>{var c;(c=s.payload)!=null&&c.data&&(t(s.payload.data.active),n.setFieldValue("quantity",s.payload.data.quantity))})};C.useEffect(()=>{o()},[]),C.useEffect(()=>{n.validateForm()},[]);const l=s=>{const c=V();r(a6({quantity:s?parseInt(n.values.quantity):0,active:s,register_role:c})).then(d=>{var h;(h=d.payload)!=null&&h.error?a({vertical:"top",horizontal:"center",msg:d.payload.error,severity:"error"}):(o(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})};return u.jsxs(i,{container:!0,alignItems:"center",gap:2,justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(i,{children:u.jsx(w,{variant:"body1",children:"سقف کشتار پنل معاملات"})}),u.jsxs(i,{container:!0,xs:12,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"marketDailyLimit",checked:e,onClick:()=>{t(!0)}}),label:"فعال"}),u.jsx(v,{control:u.jsx(I,{checked:!e,onClick:()=>{t(!1),l(!1)},name:"marketDailyLimit"}),label:"غیر فعال"})]}),e&&u.jsxs(u.Fragment,{children:[u.jsx(i,{children:u.jsx(S,{size:"small",label:"میزان محدودیت (براساس تعداد)",name:"quantity",type:"number",value:n.values.quantity,onChange:n.handleChange,error:n.touched.quantity&&!!n.errors.quantity,helperText:n.touched.quantity&&n.errors.quantity,required:!0})}),u.jsx(i,{children:u.jsx(R,{fullWidth:!0,disabled:!n.isValid,variant:"contained",onClick:()=>l(!0),children:"ثبت"})})]})]})},nr=P("PROVINCE_GET_HATCHING_ARCHIVE_PERCENT",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.get("/hatching-archive-percent/");return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),ar=P("PROVINCE_EDIT_HATCHING_ARCHIVE_PERCENT",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("/hatching-archive-percent/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),sr=()=>{const[e,t]=C.useState(!1),r=k(),[a]=C.useContext(D),n=H({initialValues:{percent:""},validationSchema:M({percent:N().required("این فیلد اجباری است").min(1,"حداقل مقدار باید 1 باشد").max(100,"حداکثر مقدار باید 100 باشد")})}),o=()=>{r(nr()).then(s=>{var c;(c=s.payload)!=null&&c.data&&(t(s.payload.data.active),n.setFieldValue("percent",s.payload.data.percent))})};C.useEffect(()=>{o()},[]),C.useEffect(()=>{n.validateForm()},[]);const l=s=>{r(ar({percent:s?parseInt(n.values.percent):0,active:s})).then(c=>{var d;(d=c.payload)!=null&&d.error?a({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(o(),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})};return u.jsxs(i,{container:!0,alignItems:"center",gap:2,justifyContent:"space-between",isPolicy:!0,sx:{width:{xs:"100%",sm:"48%",lg:"24%",nxl:"19%"}},children:[u.jsx(i,{children:u.jsx(w,{variant:"body1",children:"بایگانی خودکار جوجهریزی"})}),u.jsxs(i,{container:!0,xs:12,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"hatchingArchivePercent",checked:e,onClick:()=>{t(!0)}}),label:"فعال"}),u.jsx(v,{control:u.jsx(I,{checked:!e,onClick:()=>{t(!1),l(!1)},name:"hatchingArchivePercent"}),label:"غیر فعال"})]}),e&&u.jsxs(u.Fragment,{children:[u.jsx(i,{children:u.jsx(S,{size:"small",label:"درصد بایگانی",name:"percent",type:"number",value:n.values.percent,onChange:n.handleChange,error:n.touched.percent&&!!n.errors.percent,helperText:n.touched.percent&&n.errors.percent,required:!0})}),u.jsx(i,{children:u.jsx(R,{fullWidth:!0,disabled:!n.isValid,variant:"contained",onClick:()=>l(!0),children:"ثبت"})})]})]})},or=()=>{const[e,t]=C.useState(!0),[r,a]=C.useState("0"),[n,o]=C.useState(!1),[l,s]=C.useState(!1),[c,d]=C.useState(!1),[h,y]=C.useState(!1),A=k(),F=Ye(),x=Array.from({length:8},(L,au)=>au+8),[p,j]=C.useState(!1),[E,T]=C.useState(""),[O,f]=C.useState("optional"),[B,U]=C.useState(!1),[m,X]=C.useState(!1),[W,iu]=C.useState(!1),J=L=>{L.target.name==="item1"&&(o(L.target.checked),A(ut({allow:L.target.checked}))),L.target.name==="item6"&&(s(L.target.checked),A(_e({allow:L.target.checked,mandatory:W}))),L.target.name==="autoAcceptSlaughter"&&(d(L.target.checked),A(tt({allow:L.target.checked}))),L.target.name==="autoCarAllocateSlaughter"&&(y(L.target.checked),A(nt({allow:L.target.checked})))};C.useEffect(()=>{A(et()).then(L=>{o(L.payload.data)}),A(J6()).then(L=>{s(L.payload.data.allowState),iu(L.payload.data.mandatory)}),A(rt()).then(L=>{d(L.payload.data)}),A(at()).then(L=>{y(L.payload.data)}),A(je()).then(L=>{f(L.payload.data.type)}),A(he()).then(L=>{U(L.payload.data.permission)})},[]),C.useEffect(()=>{t(!1),e||A(_e({allow:l,mandatory:W}))},[W]),C.useEffect(()=>{p&&E&&A(ie({hour:E,active:p})),!p&&E&&(T(null),A(ie({hour:0,active:p})))},[E,p]),C.useEffect(()=>{A(e6()).then(L=>{j(L.payload.data.active),T(L.payload.data.hour)})},[]);const ju=L=>{A(xt({type:L})).then(()=>{A(je()).then(au=>{f(au.payload.data.type)})})},fu=L=>{A(gt({permission:L})).then(()=>{A(he()).then(au=>{U(au.payload.data.permission)})})},Su=(L,au)=>{a(au)};return u.jsxs(i,{container:!0,xs:12,justifyContent:"center",alignItems:"center",mb:4,sx:{background:"#F9F9F9",borderRadius:"15px"},children:[u.jsx(i,{container:!0,xs:12,justifyContent:"center",alignItems:"center",mb:4,mt:2,children:u.jsx(w,{xs:12,children:"مدیریت فرآیند"})}),u.jsxs(Ne,{value:r,onChange:Su,textColor:"secondary",indicatorColor:"secondary","aria-label":"secondary tabs example",children:[u.jsx(gu,{value:"0",label:"صدور مجوز"}),u.jsx(gu,{value:"1",label:"محدودیت و اولویت"}),u.jsx(gu,{value:"3",label:"قیمت مصوب"}),u.jsx(gu,{value:"4",label:"مدیریت تلفات"})]}),r==="0"&&u.jsx(i,{container:!0,xs:12,justifyContent:"center",alignItems:"center",mt:2,children:u.jsxs(i,{container:!0,xs:12,gap:2,alignItems:"start",className:"manage-process",direction:"column",children:[u.jsxs(i,{xs:12,container:!0,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsx(i,{isPolicy:!0,container:!0,justifyContent:"center",isLocked:!0,sx:{height:"60px",width:{xs:"100%",sm:"48%",lg:"19%"}},xs:12,children:u.jsx(v,{control:u.jsx(z,{checked:!0,onChange:J,name:"item4"}),label:"مدیر اجرایی (اتحادیه)"})}),u.jsxs(i,{isPolicy:!0,container:!0,justifyContent:"center",sx:{height:"60px",width:"340px"},children:[u.jsx(v,{control:u.jsx(z,{checked:n,onChange:J,name:"item1"}),label:"مجوز فروش به خارج استان (زنده)"}),u.jsx(ou,{title:"مدیریت",children:u.jsx(G,{disabled:!n,color:"success",onClick:()=>{F(V()==="ProvinceOperator"?x0:V()==="SuperAdmin"?g0:A0)},children:u.jsx(du,{})})})]})]}),u.jsxs(i,{xs:12,container:!0,justifyContent:"center",alignItems:"start",gap:2,px:2,children:[u.jsx($t,{}),u.jsxs(i,{container:!0,alignItems:"center",isPolicy:!0,gap:2,sx:{width:{xs:"100%",sm:"48%",lg:"19%"}},children:[u.jsx(w,{variant:"body1",children:"تخلیه با کد قرنطینه"}),u.jsxs(i,{xs:12,container:!0,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:O!=="optional",onClick:()=>{ju("force")}}),label:"اجباری"}),u.jsx(v,{control:u.jsx(I,{checked:O==="optional",onClick:()=>{ju("optional")},name:"item6"}),label:"اختیاری"})]})]}),u.jsxs(i,{container:!0,alignItems:"center",isPolicy:!0,gap:2,sx:{width:{xs:"100%",sm:"48%",lg:"19%"}},children:[u.jsx(w,{variant:"body1",children:"مجوز فروش مرغ برای انجماد"}),u.jsxs(i,{xs:12,container:!0,justifyContent:"space-between",children:[u.jsx(v,{control:u.jsx(I,{name:"item6",checked:B,onClick:()=>{fu(!0)}}),label:"فعال"}),u.jsx(v,{control:u.jsx(I,{checked:!B,onClick:()=>{fu(!1)},name:"item6"}),label:"غیر فعال"})]})]}),u.jsx(Dt,{}),u.jsx(Tt,{}),u.jsx(Rt,{}),u.jsx(Lt,{}),u.jsx(zt,{}),u.jsx(Ot,{}),u.jsx(Et,{}),u.jsx(Bt,{}),u.jsx(qt,{}),u.jsx(Mt,{}),u.jsx(Ht,{}),u.jsx(Wt,{}),u.jsx(Yt,{}),u.jsx(Qt,{}),u.jsx(Xt,{}),u.jsx(ur,{}),u.jsx(rr,{}),u.jsx(sr,{}),u.jsx(Vt,{})]}),u.jsx(St,{})]})}),r==="1"&&u.jsxs(i,{container:!0,xs:12,justifyContent:"center",alignItems:"start",direction:"column",mt:2,children:[u.jsx(mt,{}),u.jsxs(i,{container:!0,children:[u.jsx(v,{control:u.jsx(z,{checked:l,onChange:J,name:"item6"}),label:"اولویت بندی کشتارگاه توسط مرغدار"}),u.jsx(ou,{title:"مدیریت","aria-label":"choose-slaughter",children:u.jsx(G,{disabled:!l,color:"success",onClick:()=>{F(y0)},children:u.jsx(du,{})})}),l&&u.jsxs(u.Fragment,{children:[u.jsx(v,{control:u.jsx(I,{value:!0,name:"item6",checked:W===!0,onChange:()=>iu(!0)}),label:"اجباری"}),u.jsx(v,{control:u.jsx(I,{checked:W===!1,onChange:()=>iu(!1),value:!1,name:"item6"}),label:"اختیاری"})]})]}),u.jsx(v,{control:u.jsx(z,{checked:"",onChange:J,name:"item2"}),label:"فروش خارج از شبکه"}),u.jsx(v,{control:u.jsx(z,{checked:"",onChange:J,name:"item3"}),label:"فعال سازی پنل بورس"}),u.jsxs(i,{container:!0,children:[u.jsx(v,{control:u.jsx(z,{checked:"",onChange:J,name:"item5"}),label:"تسویه حساب مالی"}),u.jsx(ou,{title:"در صورت فعال بودن این فیلتر امکان تخصیص حجم بار به کشتارگاه یا کشتارکن که بدهی از قبل دارد وجود ندارد.",open:m,placement:"bottom",children:u.jsx(G,{"aria-label":"help",onMouseOver:()=>X(!0),onMouseLeave:()=>X(!1),children:u.jsx(Je,{})})})]}),(V()==="ProvinceOperator"||V()==="SuperAdmin")&&u.jsx(dt,{}),(V()==="ProvinceOperator"||V()==="SuperAdmin")&&u.jsxs(i,{container:!0,gap:2,children:[u.jsx(v,{control:u.jsx(z,{checked:p,onChange:()=>j(!p)}),label:"محدودیت زمان درخواست کشتار مرغدار"}),p&&u.jsxs(Q,{style:{width:200},children:[u.jsx(Ku,{id:"hour-label",children:"ساعت پایان درخواست"}),u.jsx(Eu,{labelId:"hour-label",label:"ساعت پایان درخواست",id:"hour-select",value:E,onChange:L=>T(L.target.value),children:x.map(L=>u.jsxs(Cu,{value:L,children:[L,":00"]},L))})]})]}),u.jsx(v,{control:u.jsx(z,{name:"autoAcceptSlaughter",checked:c,onChange:J}),label:"تایید خودکار حجم تخصیصی به کشتارگاه"}),u.jsx(v,{control:u.jsx(z,{checked:h,onChange:J,name:"autoCarAllocateSlaughter",disabled:"true"}),label:"ایجاد خودروی حمل بار برای کشتارگاه"}),u.jsx(v,{control:u.jsx(z,{checked:"",onChange:J,name:"item2"}),label:"عدم امکان وارد کردن اطلاعات بار در صورت تایید نکردن تخلیه دامپزشک کشتارگاه"}),u.jsx(ot,{}),u.jsx(ct,{}),u.jsx(pt,{})]}),r==="2"&&u.jsx(i,{container:!0,xs:12,justifyContent:"center",alignItems:"center",children:u.jsx(It,{})}),r==="3"&&u.jsx(i,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:u.jsx(ft,{})}),r==="4"&&u.jsx(i,{container:!0,xs:12,justifyContent:"center",alignItems:"center",children:u.jsx(tr,{})})]})},lr=P("PROVINCE_POLICY_SUBMIT_DOCUMENT_STATE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.post("bar-documents-status/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),ir=P("PROVINCE_POLICY_SUBMIT_DOCUMENT_STATE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("bar-documents-status/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),cr=P("PROVINCE_POLICY_DELETE_DOCUMENT_STATE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.delete("bar-documents-status/"+e+"/");return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),Cr=()=>{const e=k(),[t,r]=C.useState([]),[a,n]=C.useState(!1),[o,l]=C.useState([]),[s,c]=C.useState([]),d=(F,x)=>{const p=[...o];p[x]={...p[x],value:parseInt(F.target.value)},l(p)},[h]=C.useContext(D),y=()=>{e(h6()).then(F=>{var p;c(F.payload.data);const x=(p=F.payload.data)==null?void 0:p.map(j=>({key:j==null?void 0:j.key,value:j==null?void 0:j.priorityId}));l(x)})};C.useEffect(()=>{const F=s==null?void 0:s.map((x,p)=>{var j;return[a?u.jsx(S,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:100},value:((j=o[p])==null?void 0:j.value)||(x==null?void 0:x.priorityId),onChange:E=>d(E,p)},p):x==null?void 0:x.priorityId,x==null?void 0:x.title,x!=null&&x.sms?"دارد":"ندارد",x!=null&&x.isError?u.jsx(w,{color:"error",variant:"body2",children:"ندارد"},p):u.jsx(w,{color:"primary",variant:"body2",children:"دارد"},p),u.jsx(i,{container:!0,justifyContent:"center",children:u.jsx(A,{onEdit:()=>{e(Y({title:"ویرایش وضعیت",content:u.jsx(Te,{fetchData:y,isEdit:!0,item:x})}))},onDelete:()=>{e(cr(x==null?void 0:x.id)).then(E=>{E.payload.error?h({vertical:"top",horizontal:"center",msg:E.payload.error,severity:"error"}):(y(),h({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}})},p)]});r(F)},[s,o,a]),C.useEffect(()=>{y()},[]);const A=({onEdit:F,onDelete:x})=>{const[p,j]=C.useState(null),E=!!p,T=U=>{j(U.currentTarget)},O=()=>{j(null)},f=()=>{F(),O()},B=()=>{x(),O()};return u.jsxs(i,{children:[u.jsx(ou,{title:"تنظیمات",children:u.jsx(G,{color:"primary",onClick:T,children:u.jsx(du,{})})}),u.jsx(Yu,{open:E,anchorEl:p,onClose:O,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},children:u.jsxs(Qu,{sx:{minWidth:140,p:1},children:[u.jsxs(yu,{onClick:f,sx:{py:1},children:[u.jsx(_u,{children:u.jsx(ru,{color:"primary"})}),u.jsx(mu,{primary:u.jsx(w,{variant:"body2",color:"textPrimary",children:"ویرایش"})})]}),u.jsxs(yu,{onClick:B,sx:{py:1},children:[u.jsx(_u,{children:u.jsx(Xu,{color:"error"})}),u.jsx(mu,{primary:u.jsx(w,{variant:"body2",color:"textPrimary",children:"حذف"})})]})]})})]})};return u.jsx(i,{container:!0,xs:12,alignItems:"center",justifyContent:"space-between",children:u.jsxs(i,{container:!0,style:{width:"100%"},mt:2,alignItems:"center",gap:2,children:[u.jsx(w,{variant:"body1",children:"وضعیت اسناد"}),u.jsxs(i,{container:!0,alignItems:"center",gap:1,children:[u.jsx(R,{variant:"contained",onClick:()=>{e(Y({title:"ایجاد وضعیت جدید",content:u.jsx(Te,{fetchData:y})}))},children:"ساخت وضعیت جدید"}),a?u.jsxs(i,{container:!0,alignItems:"center",gap:1,children:[u.jsx(R,{variant:"contained",onClick:()=>{e(d6({priority_list:o})).then(F=>{F.payload.error?h({vertical:"top",horizontal:"center",msg:F.payload.error,severity:"error"}):(y(),a(!1),h({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ذخیره تغییرات"}),u.jsx(R,{variant:"contained",onClick:()=>{n(!1)},color:"error",children:"لغو"})]}):u.jsx(R,{variant:"contained",onClick:()=>{n(!0)},children:"ویرایش اولویت ها"})]}),u.jsx(p6,{style:{width:"100%"},columns:["اولویت","عنوان","ارسال پیامک","مجوز ویرایش سند","عملیات"],data:t})]})})},Te=({fetchData:e,isEdit:t,item:r})=>{const[a,n]=C.useState(!!(r!=null&&r.sms)),[o,l]=C.useState(!!(r!=null&&r.isError)),s=k(),c=A=>{n(A.target.checked)},d=A=>{l(A.target.checked)},h=H({initialValues:{stateTitle:r!=null&&r.title?r==null?void 0:r.title:"",priority:r!=null&&r.priorityId?r==null?void 0:r.priorityId:1},validationSchema:M({stateTitle:$().required("این فیلد اجباری است!").typeError("لطفا عنوان وضعیت را وارد کنید!"),priority:N().required("این فیلد اجباری است!").typeError("لطفا عنوان وضعیت را وارد کنید!").min(1,"عدد مثبت وارد کنید!")})});C.useEffect(()=>{h.validateForm()},[]);const[y]=C.useContext(D);return u.jsxs(i,{container:!0,xs:12,alignItems:"center",justifyContent:"center",gap:1,children:[u.jsx(S,{fullWidth:!0,id:"stateTitle",label:"عنوان وضعیت",value:h.values.stateTitle,error:h.touched.stateTitle?!!h.errors.stateTitle:null,onChange:h.handleChange,onBlur:h.handleBlur,helperText:h.touched.stateTitle&&h.errors.stateTitle?h.errors.stateTitle:null,autoComplete:"current-password",variant:"outlined"}),t&&u.jsx(S,{fullWidth:!0,id:"priority",label:"اولویت",value:h.values.priority,error:h.touched.priority?!!h.errors.priority:null,onChange:h.handleChange,onBlur:h.handleBlur,helperText:h.touched.priority&&h.errors.priority?h.errors.priority:null,autoComplete:"current-password",variant:"outlined"}),u.jsxs(i,{container:!0,children:[u.jsx(v,{control:u.jsx(z,{checked:a,onChange:c,inputProps:{"aria-label":"controlled"}}),label:"ارسال پیامک"}),u.jsx(v,{control:u.jsx(z,{checked:o,onChange:d,inputProps:{"aria-label":"controlled"}}),label:"محدود کننده"})]}),u.jsx(R,{disabled:!h.isValid,variant:"contained",fullWidth:!0,onClick:()=>{t?s(ir({title:h.values.stateTitle,sms:a,is_error:o,bar_documents_status_key:r==null?void 0:r.key,priority_id:h.values.priority})).then(A=>{A.payload.error?y({vertical:"top",horizontal:"center",msg:A.payload.error,severity:"error"}):(e(),s(K()),y({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))}):s(lr({title:h.values.stateTitle,sms:a,is_error:o})).then(A=>{A.payload.error?y({vertical:"top",horizontal:"center",msg:A.payload.error,severity:"error"}):(e(),s(K()),y({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ثبت"})]})},dr=P("PROVINCE_POLICY_GET_ACCOUNTS_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("zarinpal-accounts/");return t(g()),{data:r,status:a}}),hr=P("PROVINCE_POLICY_EDIT_ACCOUNTS_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.put("zarinpal-accounts/0/",e);return t(g()),{data:r,status:a}}),pr=P("PROVINCE_POLICY_GET_BENEFICIARY_ACCOUNTS_SERVICE",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("beneficiary-accounts/");return t(g()),{data:r,status:a}}),xr=P("PROVINCE_POLICY_SUBMIT_BENEFICIARY_ACCOUNTS_SERVICE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.post("beneficiary-accounts/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),$u=P("PROVINCE_POLICY_EDIT_BENEFICIARY_ACCOUNTS_SERVICE",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.put("beneficiary-accounts/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),gr=P("PROVINCE_POLICY_DELETE_BENEFICIARY_ACCOUNTS_SERVICE",async(e,{dispatch:t})=>{t(b());try{const{data:r,status:a}=await _.delete("beneficiary-accounts/0/?account_key="+e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),Ar=({fetchData:e,item:t})=>{const[r]=C.useContext(D),a=k(),n=H({initialValues:{account:t!=null&&t.account?t==null?void 0:t.account:""},validationSchema:M({account:$().required("این فیلد اجباری است!").typeError("لطفا فیلد را پر کنید!").max(26,"شماره شبا نامعتبر است!").min(26,"شماره شبا نامعتبر است!")})});return C.useEffect(()=>{n.validateForm()},[]),u.jsxs(i,{xs:12,container:!0,direction:"column",gap:2,children:[u.jsxs(w,{variant:"body1",color:"primary",children:["ویرایش حساب ",t==null?void 0:t.name]}),u.jsx(S,{id:"account",label:"شماره شبا",variant:"outlined",sx:{width:"100%",height:"100%"},value:n.values.account,error:n.touched.account&&n.values.account!=="-"?!!n.errors.account:null,onChange:n.handleChange,onBlur:n.handleBlur,helperText:n.touched.account&&n.values.account!=="-"&&n.errors.account?n.errors.account:null}),u.jsx(i,{children:u.jsx(R,{fullWidth:!0,variant:"contained",disabled:!n.isValid&&n.values.account!=="-",onClick:()=>{a(hr({account_key:t==null?void 0:t.key,account:n.values.account})).then(o=>{o.payload.error?r({vertical:"top",horizontal:"center",msg:o.payload.error,severity:"error"}):(r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),a(K()),e())})},children:"ویرایش شماره شبا"})})]})},yr=M().shape({sheba:$().required("شبا الزامی است").matches(/^IR[0-9]{24}$/,"شماره شبا باید با IR شروع شود و شامل 24 رقم باشد"),name:$().required("نام ذینفع الزامی است"),percentage:N().required("درصد الزامی است").min(0,"درصد نمیتواند کمتر از 0 باشد").max(100,"درصد نمیتواند بیشتر از 100 باشد")}),u0=({fetchData:e,item:t})=>{const[r]=C.useContext(D),a=k(),n=l=>{l.payload.error?r({vertical:"top",horizontal:"center",msg:l.payload.error,severity:"error"}):(e(),r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),a(vu({right:!1,bottom:!1,content:null})))},o=H({initialValues:{name:(t==null?void 0:t.name)||"",sheba:(t==null?void 0:t.shaba)||"IR",percentage:(t==null?void 0:t.percent)||""},validationSchema:yr,onSubmit:l=>{t?a($u({name:l.name,percent:l.percentage,shaba:l.sheba,account_key:t==null?void 0:t.key})).then(s=>{n(s)}):a(xr({name:l.name,percent:l.percentage,shaba:l.sheba})).then(s=>{n(s)})}});return u.jsxs(i,{container:!0,xs:12,direction:"grid",gap:2,children:[u.jsx(S,{id:"name",label:"نام",variant:"outlined",sx:{width:"100%",height:"100%"},value:o.values.name,error:o.touched.name?!!o.errors.name:null,onChange:o.handleChange,onBlur:o.handleBlur,helperText:o.touched.name&&o.errors.name?o.errors.name:null}),u.jsx(S,{id:"sheba",label:"شماره شبا",variant:"outlined",sx:{width:"100%"},value:o.values.sheba,error:o.touched.sheba?!!o.errors.sheba:null,onChange:o.handleChange,onBlur:o.handleBlur,helperText:o.touched.sheba&&o.errors.sheba?o.errors.sheba:null}),u.jsx(S,{fullWidth:!0,id:"percentage",name:"percentage",label:"درصد",variant:"outlined",type:"number",value:o.values.percentage,onChange:o.handleChange,onBlur:o.handleBlur,error:o.touched.percentage&&!!o.errors.percentage,helperText:o.touched.percentage&&o.errors.percentage,inputProps:{min:0,max:100,step:"0.01"}}),u.jsx(R,{fullWidth:!0,variant:"contained",onClick:o.handleSubmit,children:"ثبت"})]})},_r=({item:e,fetchData:t})=>{const[r,a]=C.useState(null),n=k(),o=h=>{a(h.currentTarget)},[l]=C.useContext(D),s=()=>{a(null)},c=!!r,d=c?"popover":void 0;return u.jsxs(i,{container:!0,children:[u.jsx(G,{"aria-describedby":d,variant:"contained",color:"primary",onClick:o,children:u.jsx(du,{})}),u.jsx(Yu,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:d,open:c,anchorEl:r,onClose:s,children:u.jsxs(Qu,{sx:{minWidth:140,p:1},children:[u.jsxs(yu,{onClick:()=>{s(),n(vu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(u0,{fetchData:t,item:e}),title:" ویرایش حساب ذینفع"}))},children:[u.jsx(_u,{children:u.jsx(ru,{color:"primary"})}),u.jsx(mu,{primary:u.jsx(w,{variant:"body2",color:"textPrimary",children:"ویرایش"})})]}),u.jsxs(yu,{onClick:()=>{s(),n(Y({title:"حذف حساب",content:u.jsxs(i,{container:!0,xs:12,justifyContent:"center",alignItems:"center",children:[u.jsx(w,{variant:"body2",color:"red",children:"آیا از حذف حساب اطمینان دارید؟"}),u.jsxs(i,{container:!0,xs:12,mt:2,justifyContent:"center",alignItems:"center",spacing:2,children:[u.jsx(i,{item:!0,xs:6,children:u.jsx(R,{onClick:()=>{n(gr(e==null?void 0:e.key)).then(h=>{h.payload.error?l({vertical:"top",horizontal:"center",msg:h.payload.error,severity:"error"}):(l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),t(),n(K()))})},variant:"contained",color:"error",fullWidth:!0,children:"تایید"})}),u.jsx(i,{item:!0,xs:6,children:u.jsx(R,{variant:"contained",color:"primary",fullWidth:!0,children:"رد"})})]})]})}))},children:[u.jsx(_u,{children:u.jsx(Xu,{color:"error"})}),u.jsx(mu,{primary:u.jsx(w,{variant:"body2",color:"textPrimary",children:"حذف"})})]})]})})]})},mr=()=>{const e=k(),[t,r]=C.useState(),[a,n]=C.useState(),[o,l]=C.useState(),[s,c]=C.useState(),[d,h]=C.useState(0),y=(p,j)=>{h(j)},A=()=>{e(dr()).then(p=>{l(p.payload.data)}),e(pr()).then(p=>{c(p.payload.data)})},[F]=C.useContext(D),x=p=>{p.payload.error?F({vertical:"top",horizontal:"center",msg:p.payload.error,severity:"error"}):(A(),F({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))};return C.useEffect(()=>{const p=o==null?void 0:o.map((E,T)=>[T+1,E==null?void 0:E.name,E==null?void 0:E.account,u.jsx(G,{"aria-label":"delete",color:"primary",className:"avicultureActiveRequestsBtn",onClick:()=>{e(Y({title:"ویرایش حساب",content:u.jsx(Ar,{item:E,fetchData:A})}))},children:u.jsx(ru,{})},T)]);r(p);const j=s==null?void 0:s.map((E,T)=>[T+1,E==null?void 0:E.name,E==null?void 0:E.percent,E==null?void 0:E.shaba,u.jsx(z,{checked:E.inProvince,onChange:()=>e($u({in_province:!(E!=null&&E.inProvince),account_key:E==null?void 0:E.key})).then(O=>{x(O)})},T),u.jsx(z,{checked:E==null?void 0:E.outProvince,onChange:()=>e($u({out_province:!(E!=null&&E.outProvince),account_key:E==null?void 0:E.key})).then(O=>{x(O)})},T),u.jsx(_r,{item:E,fetchData:A},T)]);n(j)},[o,s]),C.useEffect(()=>{A()},[e,d]),u.jsxs(i,{container:!0,xs:12,justifyContent:"center",alignItems:"center",children:[u.jsxs(Ne,{scrollButtons:"auto",variant:"scrollable",allowScrollButtonsMobile:!0,value:d,onChange:y,children:[u.jsx(gu,{label:"حساب ها",value:0}),u.jsx(gu,{label:"حساب های ذینفع",value:1})]}),d===0&&u.jsx(uu,{noPagination:!0,columns:["ردیف","نام","شماره حساب","ویرایش"],data:t,title:"حساب ها",customColors:[{name:"تعداد تخصیص بدون بار",color:"yellow"},{name:"نام",color:"cyan"},{name:"شماره حساب",color:"orange"}]}),d===1&&u.jsxs(i,{xs:12,container:!0,mt:2,children:[u.jsx(R,{variant:"contained",onClick:()=>{e(vu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(u0,{fetchData:A}),title:" افزودن حساب ذینفع"}))},children:"افزودن حساب ذینفع"}),u.jsx(uu,{noPagination:!0,columns:["ردیف","نام ذینفع","درصد سهم","شماره شبا","سهم داخل استان","سهم خارج استان","عملیات"],data:a,title:"حساب های ذینفع"})]})]})},vr=P("PROVINCE_POLICY_GET_TICKETS",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("ticket-permission/");return t(g()),{data:r,status:a}}),jr=P("PROVINCE_POLICY_SUBMIT_TICKET_PERMISSION",async(e,{dispatch:t})=>{try{t(b());const{data:r,status:a}=await _.post("ticket-permission/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),fr=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState(),[n,o]=C.useState();C.useEffect(()=>{e(vr()).then(s=>{a(s.payload.data)})},[]);const l=(s,c)=>{const{target:{value:d}}=s,h=[...r];h[c]={...h[c],roles:typeof d=="string"?d.split(","):d},a(h)};return C.useEffect(()=>{const s=r==null?void 0:r.map((c,d)=>{var h;return[d+1,Lu(c==null?void 0:c.role)!=="نامشخص"?Lu(c==null?void 0:c.role):c==null?void 0:c.role,u.jsx(i,{container:!0,justifyContent:"center",style:{margin:"3px"},children:u.jsxs(Q,{fullWidth:!0,children:[u.jsx(Ku,{id:"demo-simple-select-label",children:"مجوز ارسال تیکت"}),u.jsx(Eu,{size:"small",sx:{width:{xs:"110px",sm:"220px"}},labelId:"demo-simple-select-label",label:"مجوز ارسال تیکت",value:c==null?void 0:c.roles,onChange:y=>l(y,d),multiple:!0,renderValue:y=>y.map(A=>Lu(A)).join(", "),children:(h=x6())==null?void 0:h.map((y,A)=>u.jsxs(Cu,{value:y.role,alignItems:"center",children:[(c==null?void 0:c.roles.includes(y.role))&&u.jsx(g6,{sx:{marginRight:"8px",color:"#00796b"}}),y.translation]},A))})]})},d),u.jsx(G,{color:"primary",onClick:()=>{e(jr({roles:c==null?void 0:c.roles,role:c==null?void 0:c.role})).then(y=>{if(y.payload.error){t({vertical:"top",horizontal:"center",msg:y.payload.error,severity:"error"});return}else t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},children:u.jsx(A6,{})},d)]});o(s)},[r]),u.jsx(i,{container:!0,xs:12,justifyContent:"center",alignItems:"center",mb:2,children:u.jsx(uu,{paginated:!0,title:"اجازه ثبت تیکت",columns:["ردیف","نقش","مجوز ارسال","ثبت"],data:n,customColors:[{name:"ردیف",color:"#74b9ff"},{name:"نقش",color:"#81ecec"},{name:"مجوز ارسال",color:"#636e72",text:"white"}]})})},Fr=()=>{const[e]=C.useContext(D),t=async(n,o)=>{try{(await _.get(o)).status===200&&e({vertical:"top",horizontal:"center",msg:`"${n}" با موفقیت ارسال شد`,severity:"success"})}catch{e({vertical:"top",horizontal:"center",msg:`خطا در ارسال "${n}"`,severity:"error"})}},[r,a]=C.useState([{disabled:!1,title:"اس ام اس های بدهی ساعت 9 صبح",description:"اس ام اس های بدهی",link:`${_.defaults.baseURL}send_gate_way_sms_manual/`},{disabled:!1,title:" اس ام اس های بسته شدن پنل برای بدهی",description:" اس ام اس های بسته شدن پنل برای بدهی",link:`${_.defaults.baseURL}send_deactivate_panel_debt_sms_manual/`},{disabled:!1,title:"وارد کردن بارهای خارج استان به انبار",description:"وارد کردن بارهای خارج استان به انبار",link:`${_.defaults.baseURL}add_free_bar_to_warehouse_manual/`},{disabled:!1,title:"ساخت بارهای خارج استان",description:"ساخت بارهای خارج استان",link:`${_.defaults.baseURL}create_kill_house_free_bar/`},{disabled:!1,title:"آپدیت جوجه ریزی ها",description:"آپدیت جوجه ریزی ها",link:`${_.defaults.baseURL}api_update_poultry_hatching_from_rsi/`},{disabled:!1,title:"تیکت اخطاریه بار های واردنشده به انبار خارج استانی",description:"تیکت اخطاریه بار های واردنشده به انبار خارج استانی",link:`${_.defaults.baseURL}warning_free_bar_to_warehouse_manual/`,isTicket:!0},{disabled:!1,title:"تیکت تخصیصات بدون بار",description:"تیکت تخصیصات بدون بار",link:`${_.defaults.baseURL}warning_province_kill_request_without_bar_manual/`,isTicket:!0},{disabled:!1,title:"وارد کردن بارهای داخل استانی به انبار",description:"وارد کردن بارهای داخل استانی به انبار",link:`${_.defaults.baseURL}add_to_warehouse_manual/`},{disabled:!1,title:"خارج کردن تمام افراد",description:"خارج کردن تمام افراد",link:`${_.defaults.baseURL}remove_access_token_manual/`},{disabled:!1,title:"چک کردن تعداد کد قرنطینه داخل استان",description:"چک کردن تعداد کد قرنطینه داخل استان",link:`${_.defaults.baseURL}find_gid_code_manual/`},{disabled:!1,title:"آپدیت سن جموجه ریزی",description:"آپدیت سن جموجه ریزی",link:`${_.defaults.baseURL}update_chicken_age_from_login_manual/`},{disabled:!1,title:"چک کردن کد قرنطینه خارج استان",description:"چک کردن کد قرنطینه خارج استان",link:`${_.defaults.baseURL}get_gid_out_province_manual/`},{disabled:!1,title:"پیغام تعرفه کل ساعت 4 ایتا",description:"پیغام تعرفه کل ساعت 4 ایتا",link:`${_.defaults.baseURL}daily_manual_transaction_for_eata/`},{disabled:_.defaults.baseURL.includes("testbackend.rasadyar.com"),title:"ارسال دستی پیامک گزارش توزیع گوشت مرغ داخل استان",description:"ارسال دستی پیامک گزارش توزیع گوشت مرغ داخل استان",link:`${_.defaults.baseURL}send_daily_distribution_report_sms_manual/`},{disabled:_.defaults.baseURL.includes("testbackend.rasadyar.com"),title:"ارسال دستی پیامک اطلاعات کشتار مرغ گوشتی",description:"ارسال دستی پیامک اطلاعات کشتار مرغ گوشتی",link:`${_.defaults.baseURL}send_daily_slaughter_statistics_sms_manual/`},{disabled:!1,title:"ارسال دستی بارها به ایتا",description:"ارسال دستی بارها به ایتا",link:`${_.defaults.baseURL}send_all_bar_to_eitaa/`},{disabled:!1,title:"ارسال دستی تخصیصات به ایتا فقط برای مرکزی کار میکنه",description:"ارسال دستی تخصیصات به ایتا فقط برای مرکزی کار میکنه",link:`${_.defaults.baseURL}bot_eitaa_for_province_kill_request/`}]);return u.jsx(ce.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:u.jsx(cu,{display:"flex",justifyContent:"center",alignItems:"center",children:u.jsx(i,{container:!0,direction:"column",xs:12,sm:12,md:10,lg:12,children:u.jsx(i,{container:!0,xs:12,justifyContent:"center",mb:2,px:1,children:(r||[]).map((n,o)=>{var l,s,c,d,h;return u.jsx(i,{item:!0,xs:6,sm:4,md:4,lg:2,p:1,children:u.jsx(cu,{style:{outline:"none",color:"#727272"},onClick:()=>{if(!(n!=null&&n.disabled)){const y=r.map((A,F)=>F===o?{...A,disabled:!0}:A);a(y),t(n==null?void 0:n.title,n==null?void 0:n.link)}},sx:{cursor:"pointer"},children:u.jsx(ce.div,{whileHover:{scale:n!=null&&n.disabled?null:1.05},whileTap:{scale:n!=null&&n.disabled?null:.9},children:u.jsxs(cu,{p:((l=q)==null?void 0:l.SMALL)||2,border:"1px solid #E6E6E6",borderRadius:((s=q)==null?void 0:s.SMALL)||1,bgcolor:"#FCFCFC",display:"flex",flexDirection:"column",alignItems:"center",sx:{cursor:n!=null&&n.disabled?"not-allowed":"pointer"},minHeight:"11rem",maxHeight:"11rem",children:[u.jsx(cu,{sx:{width:60,minWidth:60,height:60,minHeight:60,borderRadius:"50%",backgroundColor:n!=null&&n.disabled?"gray":"#244CCC",display:"flex",justifyContent:"center",alignItems:"center",marginBottom:((c=q)==null?void 0:c.SMALL)||1},children:(n==null?void 0:n.icon)||u.jsx(y6,{size:24,color:"#FFFFFF"})}),u.jsx(w,{variant:"body1",mt:((d=q)==null?void 0:d.TINY)||.5,sx:{color:"#727272",minHeight:"50px",fontWeight:{xs:600,md:600},fontSize:{xs:"13px",md:"16px"}},children:(n==null?void 0:n.title)||""}),u.jsx(w,{mt:((h=q)==null?void 0:h.TINY)||.5,sx:{color:"#727272",fontSize:{xs:"10px",md:"12px"}},children:(n==null?void 0:n.description)||""})]})})})},(n==null?void 0:n.id)||o)})})})})})},Er=P("MANAGEMENT_SEND_SMS",async(e,{dispatch:t})=>{var r,a;try{t(b());const{id:n,...o}=e,{data:l,status:s}=await _.put(`management-send-sms/${n}/`,o);return t(g()),{data:l,status:s}}catch(n){return t(g()),{error:((a=(r=n.response)==null?void 0:r.data)==null?void 0:a.result)||"خطا در ارسال پیامک"}}}),br=({item:e,item_id:t,updateTable_data:r})=>{const a=k(),[n]=C.useContext(D),o=()=>{a(Y({title:"ویرایش",content:u.jsx(l,{})}))},l=()=>{const s=M({username:$().required("نام کاربری الزامی است").min(3,"حداقل ۳ کاراکتر وارد کنید"),password:$().required("رمز عبور الزامی است").min(6,"حداقل ۶ کاراکتر وارد کنید")});return u.jsx(_0,{initialValues:{username:(e==null?void 0:e.username)||"",password:(e==null?void 0:e.password)||""},enableReinitialize:!0,validationSchema:s,onSubmit:(c,{setSubmitting:d})=>{const h={id:t,username:c.username,password:c.password};a(Er(h)).then(y=>{d(!1),y.error?n({vertical:"top",horizontal:"center",msg:y.error,severity:"error"}):(r(),a(K()),n({vertical:"top",horizontal:"center",msg:"ویرایش با موفقیت انجام شد",severity:"success"}))})},children:({values:c,errors:d,touched:h,handleChange:y,handleBlur:A,isSubmitting:F})=>u.jsx(m0,{children:u.jsxs(cu,{display:"flex",flexDirection:"column",gap:2,children:[u.jsx(S,{label:"نام کاربری",name:"username",value:c.username,onChange:y,onBlur:A,error:h.username&&!!d.username,helperText:h.username&&d.username,fullWidth:!0}),u.jsx(S,{label:"رمز عبور",name:"password",type:"text",value:c.password,onChange:y,onBlur:A,error:h.password&&!!d.password,helperText:h.password&&d.password,fullWidth:!0}),u.jsx(R,{variant:"contained",color:"primary",type:"submit",disabled:!t||F,children:"ثبت"})]})})})};return u.jsx(i,{container:!0,children:u.jsx(ou,{title:"ویرایش",children:u.jsx(G,{color:"primary",onClick:o,children:u.jsx(du,{})})})})},Sr=()=>{const e=k(),[t,r]=C.useState([]),[a,n]=C.useState(1),[o,l]=C.useState(10),[s,c]=C.useState([]),[d,h]=C.useState(0),y=C.useCallback(async()=>{var p;e(b());try{const j=await _.get("management-send-sms/");e(g()),r((j==null?void 0:j.data)||[]),h(((p=j==null?void 0:j.data)==null?void 0:p.count)||0)}catch(j){e(g()),console.error("Error fetching users:",j)}},[e]);C.useEffect(()=>{y(1)},[y]);const A=C.useCallback(()=>{y(1)},[y]),F=p=>{n(p),y(p)},x=(p,j)=>{l(p)};return C.useEffect(()=>{const p=t==null?void 0:t.map((j,E)=>[a===1?E+1:E+o*(a-1)+1,j==null?void 0:j.name,j==null?void 0:j.username,j==null?void 0:j.password,u.jsx(br,{updateTable_data:A,item:j,item_id:j==null?void 0:j.id},`ops-${E}`)]);c(p)},[t]),u.jsxs(u.Fragment,{children:[u.jsx(i,{container:!0,alignItems:"center",mb:q.SMALL,gap:q.SMALL}),u.jsx(uu,{data:s,columns:["ردیف","نام","نام کابری","رمز عبور","ویرایش"],handlePageChange:F,handlePerRowsChange:x,totalRows:d,title:"مدیریت ارسال پیامک"})]})},kr=({item:e,updateTable:t})=>{const r={market_capacity_percent:(e==null?void 0:e.marketCapacityPercent)??0,market_light_capacity:(e==null?void 0:e.marketLightCapacity)??!1,market_light_capacity_percent:(e==null?void 0:e.marketLightCapacityPercent)??0,total_kill_capacity:(e==null?void 0:e.totalKillCapacity)??0,total_kill_capacity_percent:(e==null?void 0:e.totalKillCapacityPercent)??0},a=k(),[n]=C.useContext(D),[o,l]=C.useState((e==null?void 0:e.marketBuying)||!1),[s,c]=C.useState((e==null?void 0:e.marketBuyingLimitation)||!1),[d,h]=C.useState((e==null?void 0:e.marketBuyingCapacityPercentStatus)||!1),[y,A]=C.useState(!!r.market_light_capacity),F=(j,E)=>M({market_capacity_percent:j&&d?N().required("درصد خرید کل الزامی است").min(0,"حداقل مقدار 0 است").max(100,"حداکثر مقدار 100 است").typeError("فقط عدد مجاز است"):N().notRequired(),total_kill_capacity:s&&!d?N().required("سقف کشتار الزامی است!").typeError("فقط عدد مجاز است"):N().notRequired(),total_kill_capacity_percent:s&&!d?N().required("درصد از سقف کشتار الزامی است!").typeError("فقط عدد مجاز است").min(0,"حداقل مقدار 0 است").max(100,"حداکثر مقدار 100 است"):N().notRequired(),market_light_capacity_percent:j&&y&&s?N().required("درصد خرید سبک الزامی است").min(0,"حداقل مقدار 0 است").max(100,"حداکثر مقدار 100 است").typeError("فقط عدد مجاز است"):N().notRequired()}),x=C.useMemo(()=>F(o),[o,y,s,d]);C.useEffect(()=>{p.validateForm()},[o,y,s,d]);const p=H({initialValues:{market_capacity_percent:r.market_capacity_percent??"",total_kill_capacity:r.total_kill_capacity??"",total_kill_capacity_percent:r.total_kill_capacity_percent??"",market_light_capacity_percent:r.market_light_capacity_percent??""},validationSchema:x,validateOnBlur:!0,validateOnChange:!0,onSubmit:(j,E)=>{const T={key:e==null?void 0:e.key,market_buying:o,market_buying_limitation:s,market_buying_capacity_percent_status:!!(o&&s&&d),market_capacity_percent:o&&s&&d?Number(j.market_capacity_percent):0,total_kill_capacity_percent:o&&s&&!d?j==null?void 0:j.total_kill_capacity_percent:0,market_light_capacity:y,market_light_capacity_percent:y&&s?Number(j.market_light_capacity_percent):0};a(Au(T)).then(O=>{O.payload.error?n({vertical:"top",horizontal:"center",msg:O.payload.error,severity:"error"}):(a(K()),t(),n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))}),E.setSubmitting(!1)}});return u.jsxs(i,{container:!0,xs:12,children:[u.jsxs(i,{container:!0,gap:2,xs:12,children:[u.jsx(i,{xs:12,children:u.jsxs(Q,{component:"fieldset",children:[u.jsx(Du,{component:"legend",children:"اجازه خرید"}),u.jsxs(Z,{fullWidth:!0,row:!0,name:"market_buying",value:o?"true":"false",onChange:j=>l(j.target.value==="true"),children:[u.jsx(v,{value:"true",control:u.jsx(I,{}),label:"دارد"}),u.jsx(v,{value:"false",control:u.jsx(I,{}),label:"ندارد"})]})]})}),o&&u.jsxs(i,{container:!0,gap:2,xs:12,children:[u.jsx(i,{xs:12,children:u.jsxs(Q,{component:"fieldset",children:[u.jsx(Du,{component:"legend",children:"محدودیت کشتار"}),u.jsxs(Z,{fullWidth:!0,row:!0,name:"market_buying",value:s?"true":"false",onChange:j=>c(j.target.value==="true"),children:[u.jsx(v,{value:"true",control:u.jsx(I,{}),label:"دارد"}),u.jsx(v,{value:"false",control:u.jsx(I,{}),label:"ندارد"})]})]})}),s&&u.jsx(i,{xs:12,children:u.jsxs(Q,{component:"fieldset",children:[u.jsx(Du,{component:"legend",children:"نوع محدودیت"}),u.jsxs(Z,{fullWidth:!0,row:!0,name:"market_buying",value:d?"true":"false",onChange:j=>h(j.target.value==="true"),children:[u.jsx(v,{value:"false",control:u.jsx(I,{}),label:"درصد از سقف کشتار"}),u.jsx(v,{value:"true",control:u.jsx(I,{}),label:"درصد از اعلام کشتارها"})]})]})}),s&&d&&u.jsx(i,{item:!0,xs:12,children:u.jsx(S,{size:"small",fullWidth:!0,label:"درصد از کل کشتار",name:"market_capacity_percent",value:p.values.market_capacity_percent,onChange:p.handleChange,onBlur:p.handleBlur,error:p.touched.market_capacity_percent&&!!p.errors.market_capacity_percent,helperText:p.touched.market_capacity_percent&&p.errors.market_capacity_percent})}),s&&!d&&u.jsx(i,{item:!0,xs:12,children:u.jsx(S,{disabled:!0,size:"small",fullWidth:!0,label:"سقف کشتار",name:"total_kill_capacity",value:p.values.total_kill_capacity,onChange:p.handleChange,onBlur:p.handleBlur,error:p.touched.total_kill_capacity&&!!p.errors.total_kill_capacity,helperText:p.touched.total_kill_capacity&&p.errors.total_kill_capacity})}),s&&!d&&u.jsx(i,{item:!0,xs:12,children:u.jsx(S,{size:"small",fullWidth:!0,label:"درصد از سقف کشتار",name:"total_kill_capacity_percent",value:p.values.total_kill_capacity_percent,onChange:p.handleChange,onBlur:p.handleBlur,error:p.touched.total_kill_capacity_percent&&!!p.errors.total_kill_capacity_percent,helperText:p.touched.total_kill_capacity_percent&&p.errors.total_kill_capacity_percent})}),s&&u.jsx(i,{item:!0,xs:12,children:u.jsx(Q,{component:"fieldset",children:u.jsx(v,{control:u.jsx(lu,{checked:y,onChange:j=>A(j.target.checked),name:"market_light_capacity"}),label:"اولویت خرید سبک"})})}),y&&s&&u.jsx(i,{item:!0,xs:12,children:u.jsx(S,{fullWidth:!0,type:"number",name:"market_light_capacity_percent",label:"درصد خرید سبک",value:p.values.market_light_capacity_percent,onChange:p.handleChange,onBlur:p.handleBlur,error:p.touched.market_light_capacity_percent&&!!p.errors.market_light_capacity_percent,helperText:p.touched.market_light_capacity_percent&&p.errors.market_light_capacity_percent})})]})]}),u.jsx(i,{container:!0,xs:12,sx:{width:"100%"},mt:2,children:u.jsx(R,{onClick:p.handleSubmit,type:"submit",variant:"contained",fullWidth:!0,disabled:!p.isValid,children:"ثبت"})})]})},Pr=()=>{const e=O=>{d(O.target.value)},t=k(),[r,a]=C.useState([]),[n,o]=C.useState(0),[l,s]=C.useState(10),[c,d]=C.useState(""),[h,y]=C.useState(1),[A,F]=C.useState([]),x=async O=>{let f;t(b()),f=await _.get(`market-kill-houses/?search=filter&value=${c}&role=${V()}&page=${O}&page_size=${l}`),t(g()),a(f.data.results),o(f.data.count)},p=O=>{x(O),y(O)},j=O=>{s(O),y(1)},E=()=>{x(h!==0?h:1)};C.useEffect(()=>{const O=r==null?void 0:r.map((f,B)=>{var U,m;return[h===1?B+1:B+l*(h-1)+1,f==null?void 0:f.name,`${f==null?void 0:f.fullname} (${f==null?void 0:f.mobile})`,f!=null&&f.killer?"کشتارکن":"کشتارگاه",f!=null&&f.marketBuying?"دارد":"ندارد",(U=f==null?void 0:f.totalKillCapacity)==null?void 0:U.toLocaleString(),(m=f==null?void 0:f.totalKillCapacityPercent)==null?void 0:m.toLocaleString(),`%${f==null?void 0:f.marketCapacityPercent}`,f!=null&&f.marketLightCapacity?"دارد":"ندارد",f!=null&&f.marketLightCapacity?`%${f==null?void 0:f.marketLightCapacityPercent}`:"-",u.jsx(ou,{title:"تعیین درصد",placement:"left-start",children:u.jsx(G,{"aria-label":"delete",color:"primary",onClick:()=>{t(Y({title:"تعیین درصد",content:u.jsx(kr,{updateTable:E,item:f})}))},children:u.jsx(v0,{})})},B)]});F(O)},[r]),C.useEffect(()=>{x(1)},[t,l]);const T=async O=>{O.preventDefault(),t(b());try{const f=await _.get(`market-kill-houses/?role=${V()}&search=filter&value=${c}&page=1&page_size=${l}`);a(f.data.results),o(f.data.count),t(g())}catch(f){console.error("Error fetching data:",f)}};return u.jsxs(i,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsx(i,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:u.jsx(i,{children:u.jsxs("form",{onSubmit:T,children:[u.jsx(S,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:e}),u.jsx(R,{type:"submit",onClick:T,endIcon:u.jsx(Xe,{}),children:"جستجو"})]})})}),u.jsx(uu,{data:A,columns:["ردیف","نام","نام مالک","نوع واحد","اجازه خرید","سقف کشتار","درصد از سقف کشتار","درصد از کل خرید","اولویت خرید سبک"," خرید سبک","عملیات"],handlePageChange:p,totalRows:n,page:h,perPage:l,handlePerRowsChange:j,title:"کشتارگاه ها"})]})};function Ir(e){var o,l;let t=String(e).replace(/[^0-9.]/g,"");const r=t.indexOf(".");r!==-1&&(t=t.slice(0,r+1)+t.slice(r+1).replace(/\./g,"")),t.length===2&&!t.includes(".")&&(t=`${t[0]}.${t[1]}`);const a=t.split(".");if(((o=a[0])==null?void 0:o.length)>1){const s=a[0][0],c=((l=a[0])==null?void 0:l.slice(1))+(a[1]||"");t=c?`${s}.${c.replace(/\D/g,"").slice(0,1)}`:`${s}`}if(t.includes(".")){const[s,c=""]=t.split(".");t=`${s}.${c.slice(0,1)}`}t=t.replace(/^0(\d)/,"$1"),t==="."&&(t="");const n=parseFloat(t);return Number.isNaN(n)||(n>=10&&(t="9.9"),n<0&&(t="0")),t}const wr=M({from_age:N().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!"),to_age:N().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!"),from_weight:$().required("این فیلد اجباری است!").test("is-weight","Format: d.d and < 10",e=>e==null||e===""?!0:/^\d(\.\d)?$/.test(String(e))&&parseFloat(e)<10),to_weight:$().required("این فیلد اجباری است!").test("is-weight","Format: d.d and < 10",(e,t)=>{if(e==null||e==="")return!0;if(!(/^\d(\.\d)?$/.test(String(e))&&parseFloat(e)<10))return!1;const a=parseFloat(t.parent.from_weight),n=parseFloat(e);return!Number.isNaN(a)&&!Number.isNaN(n)?n>=a||t.createError({message:"حداکثر وزن از حداقل وزن باید بیشتر باشد!"}):!0})}),Re=({item:e,fetchData:t})=>{const r=k(),[a]=C.useContext(D),n=H({initialValues:{from_age:e==null?void 0:e.fromAge,to_age:e==null?void 0:e.toAge,from_weight:e==null?void 0:e.fromWeight,to_weight:e==null?void 0:e.toWeight},validationSchema:wr,validateOnChange:!0,validateOnBlur:!0,onSubmit:s=>{const c={from_age:Number(s.from_age),to_age:Number(s.to_age),from_weight:s.from_weight===""?null:Number(s.from_weight),to_weight:s.to_weight===""?null:Number(s.to_weight)};r((e?j0:f0)({...c,...e?{id:e==null?void 0:e.id}:{}})).then(h=>{h.payload.error?a({vertical:"top",horizontal:"center",msg:h.payload.error,severity:"error"}):(a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),r(K()),t())})}});C.useEffect(()=>{n.validateForm()},[]);const o=s=>{["e","E","+","-",","].includes(s.key)&&s.preventDefault()},l=s=>c=>{const d=Ir(c.target.value);n.setFieldValue(s,d)};return u.jsxs(i,{container:!0,xs:12,gap:2,justifyContent:"center",alignItems:"center",dierction:"column",children:[u.jsx(S,{fullWidth:!0,label:"از سن",name:"from_age",type:"number",value:n.values.from_age,onChange:n.handleChange,onBlur:n.handleBlur,inputProps:{step:1,inputMode:"numeric",pattern:"[0-9]*",min:0,max:150},onKeyDown:o,error:!!(n.touched.from_age&&n.errors.from_age),helperText:n.touched.from_age&&n.errors.from_age}),u.jsx(S,{fullWidth:!0,label:"تا سن",name:"to_age",type:"number",value:n.values.to_age,onChange:n.handleChange,onBlur:n.handleBlur,inputProps:{step:1,inputMode:"numeric",pattern:"[0-9]*",min:0,max:150},onKeyDown:o,error:!!(n.touched.to_age&&n.errors.to_age),helperText:n.touched.to_age&&n.errors.to_age}),u.jsx(S,{fullWidth:!0,label:"از وزن",name:"from_weight",value:n.values.from_weight,onChange:l("from_weight"),onBlur:n.handleBlur,inputProps:{inputMode:"decimal"},onKeyDown:o,error:!!(n.touched.from_weight&&n.errors.from_weight),helperText:n.touched.from_weight&&n.errors.from_weight}),u.jsx(S,{fullWidth:!0,label:"تا وزن",name:"to_weight",value:n.values.to_weight,onChange:l("to_weight"),onBlur:n.handleBlur,inputProps:{inputMode:"decimal"},onKeyDown:o,error:!!(n.touched.to_weight&&n.errors.to_weight),helperText:n.touched.to_weight&&n.errors.to_weight}),u.jsx(R,{disabled:n.values.to_age<=n.values.from_age,fullWidth:!0,type:"submit",variant:"contained",onClick:n.handleSubmit,children:e?"ویرایش":"ثبت"})]})},Tr=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState(),[n,o]=C.useState(),l=()=>{e(E0()).then(c=>{a(c.payload.data)})};C.useEffect(()=>{l()},[]),C.useEffect(()=>{const c=r==null?void 0:r.map((d,h)=>[h+1,d==null?void 0:d.fromAge,d==null?void 0:d.toAge,d==null?void 0:d.fromWeight,d==null?void 0:d.toWeight,u.jsx(s,{onEdit:()=>{e(Y({title:"ویرایش بازه",content:u.jsx(Re,{fetchData:l,item:d})}))},onDelete:()=>{e(Y({title:"آیا مطمئن هستید؟",content:u.jsxs(i,{container:!0,spacing:2,children:[u.jsx(i,{item:!0,children:u.jsx(R,{variant:"contained",color:"error",onClick:()=>{e(F0(d==null?void 0:d.id)).then(y=>{y.payload.error?t({vertical:"top",horizontal:"center",msg:y.payload.error,severity:"error"}):(l(),e(K()),t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"تایید"})}),u.jsx(i,{item:!0,children:u.jsx(R,{onClick:()=>{e(K())},children:"لغو"})})]})}))}},`actions-${h}`)]);o(c)},[r]);const s=({onEdit:c,onDelete:d})=>{const[h,y]=C.useState(null),A=!!h,F=E=>{y(E.currentTarget)},x=()=>{y(null)},p=()=>{c(),x()},j=()=>{d(),x()};return u.jsxs(i,{container:!0,justifyContent:"center",children:[u.jsx(G,{color:"primary",onClick:F,children:u.jsx(du,{})}),u.jsx(Yu,{open:A,anchorEl:h,onClose:x,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},children:u.jsxs(Qu,{sx:{minWidth:150,p:1},children:[u.jsxs(yu,{onClick:p,sx:{py:1},children:[u.jsx(_u,{children:u.jsx(ru,{color:"primary"})}),u.jsx(mu,{primary:u.jsx(w,{variant:"body2",color:"textPrimary",children:"ویرایش"})})]}),u.jsxs(yu,{onClick:j,sx:{py:1},children:[u.jsx(_u,{children:u.jsx(Xu,{color:"error"})}),u.jsx(mu,{primary:u.jsx(w,{variant:"body2",color:"textPrimary",children:"حذف"})})]})]})})]})};return u.jsxs(i,{container:!0,xs:12,justifyContent:"start",alignItems:"center",children:[u.jsx(R,{variant:"contained",color:"primary",onClick:()=>{e(Y({title:"ایجاد بازه جدید",content:u.jsx(Re,{fetchData:l})}))},children:"ایجاد بازه جدید"}),u.jsx(uu,{title:"بازه وزنی",columns:["ردیف","از سن","تا سن","حداقل وزن","حداکثر وزن","عملیات"],data:n,paginated:!0})]})},Rr=P("PROVINCE_POLICY_GET_WEIGHT_CATEGORY",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("index-weight-category/");return t(g()),{data:r,status:a}});P("PROVINCE_POLICY_SUBMIT_WEIGHT_CATEGORY",async(e,{dispatch:t})=>{t(b());try{const{data:r,status:a}=await _.post("index-weight-category/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}});const Dr=P("PROVINCE_POLICY_EDIT_WEIGHT_CATEGORY",async(e,{dispatch:t})=>{t(b());try{const{data:r,status:a}=await _.put("index-weight-category/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}});P("PROVINCE_DELETE_WEIGHT_CATEGORY",async(e,{dispatch:t})=>{t(b());try{const{data:r,status:a}=await _.delete(`index-weight-category/${e}/`);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}});const Or=({item:e,fetchData:t})=>{const r=k(),[a]=C.useContext(D),n=H({initialValues:{min_value:(e==null?void 0:e.minValue)||"",max_value:(e==null?void 0:e.maxValue)||""},validationSchema:M({min_value:N().typeError("لطفا فیلد را به صورت عددی وارد کنید.!").required("این فیلد اجباری است!"),max_value:N().typeError("لطفا فیلد را به صورت عددی وارد کنید.!").required("این فیلد اجباری است!")}),onSubmit:async o=>{r(Dr({...o,key:e==null?void 0:e.key})).then(l=>{l.payload.error?a({vertical:"top",horizontal:"center",msg:l.payload.error,severity:"error"}):(a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),t(),r(K()))})}});return u.jsx(i,{container:!0,xs:12,direction:"column",children:u.jsx("form",{onSubmit:n.handleSubmit,children:u.jsxs(i,{container:!0,xs:12,gap:2,direction:"column",children:[u.jsx(S,{fullWidth:!0,id:"min_value",size:"small",label:"حداقل وزن",variant:"outlined",sx:{width:"100%"},value:n.values.min_value,error:n.touched.min_value?!!n.errors.min_value:null,onChange:n.handleChange,onBlur:n.handleBlur,helperText:n.touched.min_value&&n.errors.min_value?n.errors.min_value:null}),u.jsx(S,{fullWidth:!0,id:"max_value",size:"small",label:"حداکثر وزن",variant:"outlined",sx:{width:"100%"},value:n.values.max_value,error:n.touched.max_value?!!n.errors.max_value:null,onChange:n.handleChange,onBlur:n.handleBlur,helperText:n.touched.max_value&&n.errors.max_value?n.errors.max_value:null}),u.jsx(R,{variant:"contained",fullWidth:!0,onClick:n.handleSubmit,children:"ویرایش"})]})})})},Lr=()=>{const e=k(),[t,r]=C.useState(),[a,n]=C.useState(),o=()=>{e(Rr()).then(l=>{r(l.payload.data)})};return C.useEffect(()=>{o()},[]),C.useEffect(()=>{const l=t==null?void 0:t.map((s,c)=>[c+1,s==null?void 0:s.name,s==null?void 0:s.minValue,s==null?void 0:s.maxValue,u.jsx(i,{container:!0,alignItems:"center",gap:12,justifyContent:"center",children:u.jsx(G,{color:"primary",onClick:()=>{e(Y({title:"ویرایش دسته بندی وزنی",content:u.jsx(Or,{fetchData:o,item:s})}))},children:u.jsx(ru,{})})},c)]);n(l)},[t]),u.jsx(i,{container:!0,xs:12,justifyContent:"start",alignItems:"center",children:u.jsx(uu,{title:"دسته بندی وزنی",columns:["ردیف","نام","حداقل وزن","حداکثر وزن","ویرایش"],data:a,paginated:!0})})},Nr=P("PROVINCE_POLICY_GET_FINE_PERMISSION",async(e,{dispatch:t})=>{t(b());const{data:r,status:a}=await _.get("fine-permission/");return t(g()),{data:r,status:a}}),Br=P("PROVINCE_POLICY_EDIT_WEIGHT_FINE_PERMISSION",async(e,{dispatch:t})=>{t(b());try{const{data:r,status:a}=await _.put("fine-permission/0/",e);return t(g()),{data:r,status:a}}catch(r){return t(g()),{error:r.response.data.result}}}),zr=({item:e,fetchData:t})=>{const r=k(),[a]=C.useContext(D),[n,o]=C.useState({start_time:(e==null?void 0:e.startTime)||"01:00:00",end_time:(e==null?void 0:e.endTime)||"24:00:00",fine:(e==null?void 0:e.fine)||!1}),l=H({initialValues:{fine_coefficient:(e==null?void 0:e.fineCoefficient)||0},validationSchema:M({fine_coefficient:N().typeError("لطفا فیلد را به صورت عددی وارد کنید!").required("این فیلد اجباری است!")}),onSubmit:async s=>{const c={key:e==null?void 0:e.key,fine:n.fine,start_time:n.fine?n.start_time:"00:00:00",end_time:n.fine?n.end_time:"00:00:00",fine_coefficient:n.fine?s.fine_coefficient:0};r(Br(c)).then(d=>{d.payload.error?a({vertical:"top",horizontal:"center",msg:d.payload.error,severity:"error"}):(a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),t(),r(K()))})}});return u.jsx(i,{container:!0,xs:12,direction:"column",justifyContent:"center",children:u.jsx("form",{onSubmit:l.handleSubmit,children:u.jsxs(i,{container:!0,xs:12,gap:2,direction:"column",children:[u.jsx(i,{item:!0,display:"flex",justifyContent:"start",children:u.jsxs(Z,{row:!0,value:n.fine?"active":"inactive",onChange:s=>o(c=>({...c,fine:s.target.value==="active"})),children:[u.jsx(v,{value:"active",control:u.jsx(I,{}),label:"فعال"}),u.jsx(v,{value:"inactive",control:u.jsx(I,{}),label:"غیرفعال"})]})}),n.fine&&u.jsxs(i,{item:!0,display:"flex",alignItems:"center",sx:{flexDirection:{xs:"column",md:"row"}},gap:2,children:[u.jsx(S,{id:"fine_coefficient",size:"small",label:"ضریب جریمه",variant:"outlined",value:l.values.fine_coefficient,error:l.touched.fine_coefficient?!!l.errors.fine_coefficient:null,onChange:l.handleChange,onBlur:l.handleBlur,helperText:l.touched.fine_coefficient&&l.errors.fine_coefficient?l.errors.fine_coefficient:null,sx:{width:363,marginTop:"26px"}}),u.jsxs(i,{item:!0,display:"flex",alignItems:"center",gap:2,children:[u.jsx(nu,{value:n.start_time,onChange:s=>o(c=>({...c,start_time:s})),label:"از"}),u.jsx(nu,{value:n.end_time,onChange:s=>o(c=>({...c,end_time:s})),label:"تا"})]})]}),u.jsx(R,{variant:"contained",fullWidth:!0,type:"submit",children:"ویرایش"})]})})})},Ur=()=>{const e=k(),[t,r]=C.useState(),[a,n]=C.useState(),o=()=>{e(Nr()).then(l=>{r(l.payload.data)})};return C.useEffect(()=>{o()},[]),C.useEffect(()=>{const l=t==null?void 0:t.map((s,c)=>[c+1,s==null?void 0:s.name,s!=null&&s.startTime&&(s!=null&&s.endTime)&&(s==null?void 0:s.startTime)!=="00:00:00"&&(s==null?void 0:s.endTime)!=="00:00:00"?`از ${s==null?void 0:s.startTime.slice(0,5)} تا ${s==null?void 0:s.endTime.slice(0,5)}`:"-",s==null?void 0:s.fineCoefficient,s!=null&&s.fine?"فعال":"غیر فعال",u.jsx(i,{container:!0,alignItems:"center",gap:12,justifyContent:"center",children:u.jsx(G,{color:"primary",onClick:()=>{e(Y({title:"ویرایش جریمه",content:u.jsx(zr,{fetchData:o,item:s})}))},children:u.jsx(ru,{})})},c)]);n(l)},[t]),u.jsx(i,{container:!0,xs:12,justifyContent:"start",alignItems:"center",children:u.jsx(uu,{name:"جریمه",columns:["ردیف","نام","زمان","ضریب جریمه","وضعیت","ویرایش"],data:a,paginated:!0})})},Vr=M({percentInsideProvince:N().typeError("باید عدد وارد کنید").min(0,"نمیتواند کمتر از 0 باشد").max(100,"نمیتواند بیشتر از 100 باشد").required("الزامی"),percentOutsideProvince:N().typeError("باید عدد وارد کنید").min(0,"نمیتواند کمتر از 0 باشد").max(100,"نمیتواند بیشتر از 100 باشد").required("الزامی"),percentSegmentation:N().typeError("باید عدد وارد کنید").min(0,"نمیتواند کمتر از 0 باشد").max(100,"نمیتواند بیشتر از 100 باشد").required("الزامی")}).test("total-percentage","مجموع درصدها نمیتواند بیشتر از 100 باشد",function(e){const{percentInsideProvince:t,percentOutsideProvince:r,percentSegmentation:a}=e;return(t||0)+(r||0)+(a||0)<=100}),De=({item:e,updateTable:t,type:r})=>{const[a]=C.useContext(D),n=k(),o=H({initialValues:{percentInsideProvince:r==="gov"?e==null?void 0:e.inProvinceGovernmentalSellingPercent:(e==null?void 0:e.inProvinceFreeSellingPercent)||0,percentOutsideProvince:r==="gov"?e==null?void 0:e.outProvinceGovernmentalSellingPercent:(e==null?void 0:e.outProvinceFreeSellingPercent)||0,percentSegmentation:r==="gov"?e==null?void 0:e.segmentationGovernmentalPercent:(e==null?void 0:e.segmentationFreeSellingPercent)||0,percentColdHouse:r==="gov"?e==null?void 0:e.coldHouseGovernmentalPercent:(e==null?void 0:e.coldHouseFreePercent)||0},validationSchema:Vr,onSubmit:c=>{n(Au({key:e==null?void 0:e.key,...r==="gov"?{governmental_selling_permission:!0,in_province_governmental_selling_percent:c.percentInsideProvince,segmentation_governmental_percent:c.percentSegmentation,out_province_governmental_selling_percent:c.percentOutsideProvince,cold_house_governmental_percent:c.percentColdHouse}:{free_selling_permission:!0,in_province_free_selling_percent:c.percentInsideProvince,out_province_free_selling_percent:c.percentOutsideProvince,segmentation_free_selling_percent:c.percentSegmentation,cold_house_free_percent:c.percentColdHouse}})).then(d=>{d.payload.error?a({vertical:"top",horizontal:"center",msg:d.payload.error,severity:"error"}):a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),n(K()),t()})}}),s=(()=>{const{percentInsideProvince:c,percentOutsideProvince:d,percentSegmentation:h,percentColdHouse:y}=o.values;return(c||0)+(d||0)+(y||0)+(h||0)})();return u.jsx(cu,{component:"form",onSubmit:o.handleSubmit,sx:{width:"100%"},children:u.jsxs(i,{container:!0,spacing:2,alignItems:"flex-start",children:[u.jsx(i,{item:!0,xs:12,sm:6,children:u.jsx(S,{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(i,{item:!0,xs:12,sm:6,children:u.jsx(S,{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(i,{item:!0,xs:12,sm:6,children:u.jsx(S,{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.jsx(i,{item:!0,xs:12,sm:6,children:u.jsx(S,{fullWidth:!0,id:"percentColdHouse",name:"percentColdHouse",label:"حداکثر انجماد",type:"number",value:o.values.percentColdHouse,onChange:o.handleChange,onBlur:o.handleBlur,error:o.touched.percentColdHouse&&!!o.errors.percentColdHouse,helperText:o.touched.percentColdHouse&&o.errors.percentColdHouse,inputProps:{min:0,max:100,step:.1},size:"small"})}),u.jsxs(i,{container:!0,xs:12,justifyContent:"center",spacing:1,children:[u.jsx(i,{xs:6,children:u.jsx(R,{onClick:o.handleSubmit,variant:"contained",color:"primary",disabled:!o.isValid||s>100,fullWidth:!0,children:"ثبت"})}),u.jsx(i,{xs:6,children:u.jsx(R,{onClick:()=>n(K()),variant:"contained",color:"error",fullWidth:!0,children:"انصراف"})})]})]})})},qr=()=>{const e=U=>{h(U.target.value)},[t]=C.useContext(D),r=k(),[a,n]=C.useState([]),[o,l]=C.useState(0),[s,c]=C.useState(10),[d,h]=C.useState(""),[y,A]=C.useState(1),[F,x]=C.useState([]),p=async U=>{let m;r(b()),m=await _.get(`market-kill-houses/?search=filter&value=${d}&role=${V()}&page=${U}&page_size=${s}`),r(g()),n(m.data.results),l(m.data.count)},j=U=>{p(U),A(U)},E=U=>{c(U),A(1)},T=()=>{p(y!==0?y:1)},O=U=>{r(Y({title:"فروش دولتی",content:u.jsx(De,{item:U,updateTable:T,type:"gov"})}))},f=U=>{r(Y({title:"فروش آزاد",content:u.jsx(De,{item:U,updateTable:T,type:"free"})}))};C.useEffect(()=>{const U=a==null?void 0:a.map((m,X)=>[y===1?X+1:X+s*(y-1)+1,m==null?void 0:m.name,`${m==null?void 0:m.fullname} (${m==null?void 0:m.mobile})`,m!=null&&m.killer?"کشتارکن":"کشتارگاه",u.jsx(_6,{amount:m==null?void 0:m.outProvinceFreeBuyingCommitmentPercent,updateTable:T,item:m},X),u.jsx(z,{checked:m==null?void 0:m.freeSaleFromFreeQuotaInProvince,onClick:()=>{r(Au({key:m==null?void 0:m.key,free_sale_from_free_quota_in_province:!(m!=null&&m.freeSaleFromFreeQuotaInProvince)})).then(W=>{W.payload.error?t({vertical:"top",horizontal:"center",msg:W.payload.error,severity:"error"}):(T(),t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}},X),u.jsx(z,{checked:m==null?void 0:m.freeSaleFormGovernmentalQuota,onClick:()=>{r(Au({key:m==null?void 0:m.key,free_sale_form_governmental_quota:!(m!=null&&m.freeSaleFormGovernmentalQuota)})).then(W=>{W.payload.error?t({vertical:"top",horizontal:"center",msg:W.payload.error,severity:"error"}):(T(),t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}},X),u.jsxs(i,{container:!0,alignItems:"center",xs:12,justifyContent:"start",direction:"row",children:[u.jsx(i,{xs:6,children:u.jsx(z,{checked:m==null?void 0:m.governmentalSellingPermission,onChange:()=>{const W=!(m!=null&&m.governmentalSellingPermission);r(Au({key:m==null?void 0:m.key,governmental_selling_permission:W,...W===!1?{in_province_governmental_selling_percent:0,segmentation_governmental_percent:0,out_province_governmental_selling_percent:0}:{}})).then(iu=>{W===!0?O(m):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),T()})}})}),(m==null?void 0:m.governmentalSellingPermission)&&u.jsx(i,{xs:6,children:u.jsx(G,{size:"small",onClick:()=>O(m),color:"primary",children:u.jsx(ru,{})})})]},X),u.jsxs(i,{container:!0,alignItems:"center",xs:12,justifyContent:"center",direction:"row",children:[u.jsx(i,{xs:6,children:u.jsx(z,{checked:m==null?void 0:m.freeSellingPermission,onChange:()=>{const W=!(m!=null&&m.freeSellingPermission);r(Au({key:m==null?void 0:m.key,free_selling_permission:W,...W===!1?{in_province_free_selling_percent:0,out_province_free_selling_percent:0,segmentation_free_selling_percent:0}:{}})).then(iu=>{W===!0?f(m):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),T()})}})}),u.jsxs(i,{xs:6,children:[(m==null?void 0:m.freeSellingPermission)&&u.jsx(G,{size:"small",onClick:()=>f(m),color:"primary",children:u.jsx(ru,{})})," "]})]},X),m==null?void 0:m.inProvinceGovernmentalSellingPercent,m==null?void 0:m.outProvinceGovernmentalSellingPercent,m==null?void 0:m.segmentationGovernmentalPercent,m==null?void 0:m.coldHouseGovernmentalPercent,m==null?void 0:m.inProvinceFreeSellingPercent,m==null?void 0:m.outProvinceFreeSellingPercent,m==null?void 0:m.segmentationFreeSellingPercent,m==null?void 0:m.coldHouseFreePercent]);x(U)},[a]),C.useEffect(()=>{p(1)},[r,s]);const B=async U=>{U.preventDefault(),r(b());try{const m=await _.get(`market-kill-houses/?role=${V()}&search=filter&value=${d}&page=1&page_size=${s}`);n(m.data.results),l(m.data.count),r(g())}catch(m){console.error("Error fetching data:",m)}};return u.jsxs(i,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsx(i,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:u.jsx(i,{children:u.jsxs("form",{onSubmit:B,children:[u.jsx(S,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:e}),u.jsx(R,{type:"submit",onClick:B,endIcon:u.jsx(Xe,{}),children:"جستجو"})]})})}),u.jsx(uu,{data:F,columns:["ردیف","نام","نام مالک","نوع واحد","درصد تحویل خرید خارج استان","فروش آزاد به داخل استان","فروش آزاد از سهمیه دولتی","فروش دولتی","فروش آزاد","درصد فروش دولتی داخل استان","درصد فروش دولتی خارج استان","درصد فروش دولتی قطعه بندی","درصد فروش دولتی انجماد","درصد فروش آزاد داخل استان","درصد فروش آزاد خارج استان","درصد فروش آزاد قطعه بندی","درصد فروش آزاد انجماد"],handlePageChange:j,totalRows:o,page:y,perPage:s,handlePerRowsChange:E,title:"کشتارگاه ها"})]})},Mr=({item:e,fetchData:t})=>{const r=k(),[a]=C.useContext(D),[n,o]=C.useState({time:(e==null?void 0:e.time)||"16:00:00",allow:(e==null?void 0:e.allow)!==void 0?e==null?void 0:e.allow:!0}),l=async s=>{var c,d;s.preventDefault(),r(b());try{await _.put(`restriction_carcass_distribution/${e==null?void 0:e.id}/`,{time:n.time,allow:n.allow}),r(g()),a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),t(),r(K())}catch(h){r(g()),a({vertical:"top",horizontal:"center",msg:((d=(c=h==null?void 0:h.response)==null?void 0:c.data)==null?void 0:d.message)||"خطا در ویرایش اطلاعات",severity:"error"}),console.error("Error updating data:",h)}};return u.jsx(i,{container:!0,xs:12,direction:"column",justifyContent:"center",children:u.jsx("form",{onSubmit:l,children:u.jsxs(i,{container:!0,xs:12,gap:2,direction:"column",children:[u.jsx(i,{item:!0,display:"flex",justifyContent:"start",children:u.jsxs(Z,{row:!0,value:n.allow?"allow":"disallow",onChange:s=>o(c=>({...c,allow:s.target.value==="allow"})),children:[u.jsx(v,{value:"allow",control:u.jsx(I,{}),label:"فعال"}),u.jsx(v,{value:"disallow",control:u.jsx(I,{}),label:"غیر فعال"})]})}),u.jsx(i,{item:!0,display:"flex",alignItems:"center",gap:2,children:u.jsx(nu,{value:n.time,onChange:s=>o(c=>({...c,time:s})),label:"زمان"})}),u.jsx(R,{variant:"contained",fullWidth:!0,type:"submit",children:"ویرایش"})]})})})},Hr=()=>{const e=k(),[t]=C.useContext(D),[r,a]=C.useState([]),[n,o]=C.useState([]),l=async()=>{var c,d;e(b());try{const h=await _.get("restriction_carcass_distribution/");e(g()),a((h==null?void 0:h.data)||[])}catch(h){e(g()),t({vertical:"top",horizontal:"center",msg:((d=(c=h==null?void 0:h.response)==null?void 0:c.data)==null?void 0:d.message)||"خطا در دریافت اطلاعات",severity:"error"}),console.error("Error fetching data:",h)}};C.useEffect(()=>{l()},[]);const s=c=>({KillHouse:"کشتارگاه",Steward:"مباشر"})[c]||c;return C.useEffect(()=>{const c=r==null?void 0:r.map((d,h)=>[h+1,s(d==null?void 0:d.distributionType),d!=null&&d.out?"خارج استان":"داخل استان",(d==null?void 0:d.time)||"-",d!=null&&d.allow?"فعال":"غیر فعال",u.jsx(i,{container:!0,alignItems:"center",gap:12,justifyContent:"center",children:u.jsx(G,{color:"primary",onClick:()=>{e(Y({title:"ویرایش محدودیت توزیع لاشه",content:u.jsx(Mr,{fetchData:l,item:d})}))},children:u.jsx(ru,{})})},h)]);o(c)},[r]),u.jsx(u.Fragment,{children:u.jsx(uu,{title:"محدودیت توزیع لاشه",columns:["ردیف","نوع توزیع","محل توزیع","زمان","وضعیت","ویرایش"],data:n,paginated:!0})})},Tn=()=>{const{pathname:e}=Ke();return u.jsx(u.Fragment,{children:u.jsx(cu,{display:"flex",justifyContent:"center",children:u.jsxs(i,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,children:[e===b0||e===S0||e===k0?u.jsxs(i,{justifyContent:"center",my:q.MEDIUM,children:[u.jsx(i,{children:u.jsx(w,{variant:"h6",children:"مدیریت فرآیند"})}),u.jsx(D6,{})]}):u.jsx(n0,{}),u.jsx(i,{container:!0,justifyContent:"space-between",gap:q.SMALL,children:u.jsxs(i,{mt:q.SMALL,xs:12,children:[(e===zu||e===ze||e===Ue)&&u.jsx(or,{}),(e===P0||e===I0)&&u.jsx(Pr,{}),(e===w0||e===T0)&&u.jsx(qr,{}),(e===R0||e===D0||e===O0)&&u.jsx(Y6,{}),(e===L0||e===N0||e===B0)&&u.jsx(M6,{}),(e===z0||e===U0||e===V0)&&u.jsx(R6,{}),(e===Uu||e===Ve)&&u.jsx(Cr,{}),e===Vu&&u.jsx(mr,{}),(e===qu||e===qe)&&u.jsx(fr,{}),e===ku&&u.jsx(Fr,{}),e===Pu&&u.jsx(Sr,{}),(e===Mu||e===Me)&&u.jsx(Tr,{}),(e===Hu||e===He)&&u.jsx(Lr,{}),(e===Wu||e===We)&&u.jsx(Ur,{}),(e===Gu||e===Ge)&&u.jsx(Hr,{})]})})]})})})};export{Tn as default};
|