3 lines
86 KiB
JavaScript
3 lines
86 KiB
JavaScript
import{i as w6,j as u,aO as u0,aP as e0,aQ as r0,aR as l0,aS as n0,aT as a0,T as j,ak as f,B as R,p as o0,ao as t0,ap as n6,aq as a6,al as l6,aa as I6,ag as Gu,ah as Ju,am as s6,av as s0,aw as i0,ax as wu,aU as c0,I as Nu,aX as C0,ai as Ou,aj as zu,bi as h6,b0 as A6,an as v6,b4 as p6,ar as i6,d as Yu,b2 as L6,b3 as Wu}from"./mui-vendor-CkIVaoQP.js";import{r as D6,A as bu,$ as d0,u as Du,c as _u,M as X,X as W,G as o,S as $,m as h0,L as U,fc as _6,K as k6,a1 as c6,h as D,fd as A0,N as yu,O as Vu,C as Lu,j as G,a0 as S6,fe as v0,ff as T6,du as p0,b as Iu,c2 as x0,v as Tu,W as Uu,fg as E6,p as Qu}from"./index-N50kY0pn.js";import{r as i,b as R6}from"./react-vendor-CmFgShSM.js";import{u as fu,a as ku,f as mu}from"./redux-vendor-B7uoacJt.js";import{g as $6}from"./useRequestFile-h5jRetwP.js";import{A as F0}from"./index-Bx8c0ul7.js";import{R as o6,a as u6}from"./index.esm-Bu7XMDZU.js";import{L as g0}from"./LabelField-Mkfcpni4.js";import{a as y0}from"./aviculture-get-hatching-data-CTLuezos.js";import{d as P6}from"./Delete-CiVJBR3T.js";import{d as Zu}from"./Add-CXfAQ_ni.js";import{N as C6}from"./NumberFormatCustom-DwWPj40N.js";import{D as b0}from"./DialogAlert-CXpCXybP.js";import{d as f0}from"./Done-Bxcdr1Ky.js";import{a as j0}from"./aviculture-get-unions-CbrTkSKO.js";import{C as N6}from"./CarPelak-CHF4xuMZ.js";import{b as d6}from"./index-Cyn2oTqg.js";import{i as _0}from"./isValidIndexWeight-C_ik-uYa.js";import{R as Hu}from"./ResponsiveTable-C_snJsEO.js";import{d as x6}from"./Tune-DIGF0Mp6.js";import{d as F6}from"./Edit-D7uewMTe.js";import{d as M6}from"./Close-Cnq7tLoz.js";import{V as k0}from"./VetFarmSubmitClearanceCode-CsUWGWiM.js";import{d as S0}from"./ToggleOn-B-LGzCNG.js";import{d as E0}from"./ToggleOff-DK7z4xut.js";import{d as $0}from"./Check-8fvrNeqF.js";import{d as P0}from"./Sms-DeT2Qg-t.js";var g6={},q0=w6;Object.defineProperty(g6,"__esModule",{value:!0});var B0=g6.default=void 0,w0=q0(D6()),I0=u;B0=g6.default=(0,w0.default)((0,I0.jsx)("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Create");const L0=({id:r,file:s,updateTable:n})=>{var O,H,_,m,M;const[v,,g,,c,,]=i.useContext(bu),[C]=i.useState(!1),[d]=d0(),x=Du({initialValues:{rejectText:"",canHaching:"False"},validationSchema:_u({rejectText:X().required("این فیلد اجباری است!").typeError("لطفا دلیل خود را بیان کنید.")})}),[E,I]=i.useState(!1),Z=((O=s==null?void 0:s.hatching)==null?void 0:O.allowHatching)==="pending"&&((H=s==null?void 0:s.hatching)==null?void 0:H.leftOver)!==0,B=!x.values.canHaching&&Z,y=fu(),h=W()==="ProvinceOperator"?"تایید اطلاعات بجای شهرستان":"ثبت اطلاعات و ارسال به استان";return u.jsx(u.Fragment,{children:!C&&u.jsxs(u0,{sx:{alignSelf:"flex-start",width:"100%"},children:[u.jsxs(e0,{children:[u.jsx(r0,{color:"secondary"}),u.jsx(l0,{})]}),u.jsxs(o,{container:!0,direction:"column",flexWrap:"nowrap",flex:"1",xs:12,children:[u.jsxs(o,{container:!0,children:[u.jsx(o,{children:u.jsx(n0,{variant:"body1",fontWeight:"bold",color:"secondary",children:"انجام عملیات"})}),u.jsx(o,{children:u.jsx(a0,{color:"textSecondary",children:u.jsx(j,{variant:"body2",children:"در این مرحله درخواست را تایید یا رد کنید."})})})]}),u.jsx(o,{container:!0,xs:12,children:u.jsx(o,{xs:12,children:u.jsx(o,{container:!0,gap:$.SMALL,padding:$.SMALL,xs:12,children:u.jsx(F0,{children:E?u.jsx(h0.div,{animate:{x:-10,opacity:1},transition:{duration:.3},initial:{opacity:0},exit:{opacity:0},children:u.jsxs(o,{flexDirection:"column",container:!0,gap:$.SMALL,xs:12,children:[u.jsx(o,{children:u.jsx(f,{multiline:!0,rows:4,fullWidth:!0,id:"rejectText",label:"پیام خود را وارد کنید",variant:"outlined",value:x.values.rejectText,error:x.touched.rejectText?!!x.errors.rejectText:null,onChange:x.handleChange,onBlur:x.handleBlur,helperText:x.touched.rejectText&&x.errors.rejectText?x.errors.rejectText:null})}),u.jsxs(o,{container:!0,gap:$.SMALL,xs:12,children:[u.jsx(o,{children:u.jsx(R,{fullWidth:!0,variant:"outlined",color:"secondary",onClick:()=>{I(!1)},children:"لغو"})}),u.jsx(o,{container:!0,xs:12,children:u.jsx(R,{fullWidth:!0,disabled:!x.values.rejectText,variant:"outlined",onClick:()=>{y(U()),y(_6({message:x.values.rejectText,key:s==null?void 0:s.key,allow_hatching:x.values.canHaching,state:"reject",role:W()})).then(z=>{n&&n(),y(k6({selectedDate1:g,selectedDate2:c})),y(c6({selectedDate1:g,selectedDate2:c})),$6(d,r,y),y(D())})},children:"رد اطلاعات و پیام به مرغدار"})})]})]})}):u.jsxs(o,{container:!0,direction:"column",alignItems:"start",gap:$.SMALL,children:[u.jsxs(o,{container:!0,gap:$.TINY,direction:"column",alignItems:"start",children:[u.jsxs(o,{container:!0,gap:$.TINY,children:[u.jsx(j,{variant:"body2",fontWeight:"bold",children:"تعداد درخواست کشتار:"}),u.jsxs(j,{children:[(_=s==null?void 0:s.quantity)==null?void 0:_.toLocaleString()," قطعه"]})]}),u.jsxs(o,{container:!0,gap:$.TINY,children:[u.jsx(j,{variant:"body2",fontWeight:"bold",children:"تعداد باقی مانده از جوجه ریزی:"}),u.jsxs(j,{children:[(M=(m=s==null?void 0:s.hatching)==null?void 0:m.leftOver)==null?void 0:M.toLocaleString()," قطعه"]})]}),!!Z&&u.jsx(o,{container:!0,gap:$.TINY,alignItems:"start"})]}),u.jsxs(o,{container:!0,gap:$.SMALL,xs:12,children:[u.jsx(R,{fullWidth:!0,disabled:B,variant:"outlined",color:"error",onClick:()=>{I(!0)},children:"رد اطلاعات و پیام به مرغدار"}),u.jsx(o,{xs:12,children:u.jsx(R,{fullWidth:!0,disabled:B,variant:"outlined",onClick:()=>{y(U()),y(_6({key:s==null?void 0:s.key,allow_hatching:x.values.canHaching,state:"accept",role:W()})).then(z=>{$6(d,r,y),y(D()),z.error?v({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(n&&n(),y(k6({selectedDate1:g,selectedDate2:c})),y(c6({selectedDate1:g,selectedDate2:c})),y(A0({selectedDate1:g,selectedDate2:c})),y(yu({right:!1,bottom:!1,content:null})),v({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),W()==="ProvinceOperator"&&y(Vu({title:"عملیات با موفقیت انجام شد.",content:u.jsxs(o,{xs:12,container:!0,direction:"column",gap:$.MEDIUM,alignItems:"center",justifyContent:"center",children:[u.jsx(o,{children:u.jsx(j,{color:"green",children:"پرونده به کارتابل (در انتظار تخصیص) انتقال پیدا کرد."})}),u.jsx(o,{children:u.jsx(R,{variant:"contained",color:"success",onClick:()=>{y(Lu())},children:"تایید"})})]})})))})},children:h})})]})]})})})})})]})]})})};L0.propTypes={file:o0.PropTypes.object};const D0=ku("PROVINCE_GET_POULTRY",async(r,{dispatch:s})=>{s(U());const{data:n,status:v}=await G.get("get-all-poultry/",{params:{role:W(),active_hatching:!0,...r}});return s(D()),{data:n,status:v}}),y6=ku("AVICULTURE_GET_WAGE_TYPE",async()=>{const{data:r,status:s}=await G.get("poultry-out-province-wage-type");return{data:r,status:s}}),T0=({fetchApiData:r})=>{var f6,j6;const[s]=i.useContext(bu),[n,v]=i.useState(""),[g,c]=i.useState(""),[C,d]=i.useState(""),[x,E]=i.useState(""),[I,Z]=i.useState(""),[B,y]=i.useState(""),[h,O]=i.useState(""),[H,_]=i.useState(""),[m]=i.useState(!1),[M,z]=i.useState(!1),[V,p]=i.useState(),[K,Au]=i.useState(""),[Q,cu]=i.useState(""),[F,Y]=i.useState(),[e,lu]=i.useState([]),[eu,tu]=i.useState(),[w,P]=i.useState(),[b,nu]=i.useState(),[J,k]=i.useState("poultry"),[L,Cu]=i.useState(!1),[ru,du]=i.useState([]),[au,hu]=i.useState(!1),q=l=>{var A;k(l.target.value),l.target.value==="poultry"?iu.setFieldValue("mobile",(A=F==null?void 0:F.user)==null?void 0:A.mobile):w?iu.setFieldValue("mobile",w.mobile):iu.setFieldValue("mobile","")},[a,vu]=i.useState([]),Su=(l,A,uu,gu)=>{vu([l,A,uu,gu])},Eu=[{type:"text",id:1,value:""}],$u=[{type:"text",id:1,value:""}],[su,pu]=i.useState(Eu),[xu,Fu]=i.useState($u),[ju,Pu]=i.useState(),{weightRange:Mu}=mu(l=>l.provinceSlice),T=fu(),{avicultureChickenPrice:S}=mu(l=>l.avicultureSlice);i.useEffect(()=>{T(U()),T(S6()),T(v0()),T(y6()).then(l=>{Pu(l.payload.data.status)}),T(T6()).then(l=>{lu(l.payload.data)}),T(D())},[]);const[ou,Ru]=i.useState(),[Xu,U6]=i.useState();i.useEffect(()=>{T(U()),T(p0()),T(j0()).then(l=>{var A,uu,gu,Ku;((uu=(A=l==null?void 0:l.payload)==null?void 0:A.data)==null?void 0:uu.length)>0?Ru((Ku=(gu=l==null?void 0:l.payload)==null?void 0:gu.data[0])==null?void 0:Ku.key):Ru([])}),T(D())},[]);const K6=()=>{su.length<3&&(pu(l=>[...l,{type:"text",value:""}]),Fu(l=>[...l,{type:"text",value:""}]))},G6=()=>{const l=su.length-1;if(l!==0){const A=su.filter((gu,Ku)=>Ku!==l),uu=xu.filter((gu,Ku)=>Ku!==l);pu(A),Fu(uu)}},Q6=l=>{l.preventDefault();const A=l.target.id;pu(uu=>{const gu=uu.slice();return gu[A].value=l.target.value,gu})},qu=l=>{l.preventDefault();const A=l.target.id;Fu(uu=>{const gu=uu.slice();return gu[A].value=l.target.dataset.value,gu})};i.useEffect(()=>{S&&p(S==null?void 0:S.key)},[S]);const t=Du({initialValues:{noChicken:"",sellType:{cash:!0,haveTime:!1},price1:"",price2:"",price3:"",slaughterDate:Tu(Date()).format("YYYY-MM-DD"),period1:"4",period2:"4",period3:"4",weight:"",losses:"0",isUnion:m,isStockMarket:M,isAccepted:!1,selectedSlaughters:[],killer_kill_house_city:"",killer_kill_house_province:"",killer_kill_house_unit_name:"",kill_house_unique_id:"",interface_number:""},validationSchema:_u({noChicken:X().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!").min(0,"تعداد وارد شده از حداقل ممکن کمتر است").max(Q,"تعداد وارد شده از کل موجودی بیشتر است"),isAccepted:x0().test("req","باید تعهد نامه را بپذیرید!",(l,A)=>A.originalValue&&A.originalValue===!0).required("این فیلد اجباری است!"),price1:Iu().typeError("لطفا عدد وارد کنید!").min(S==null?void 0:S.floorPrice,"قیمت وارد شده از کف قیمت امروز کمتر است").max(S==null?void 0:S.ceilingPrice,"قیمت وارد شده از سقف قیمت امروز بیشتر است"),price2:Iu().typeError("لطفا عدد وارد کنید!").min(S==null?void 0:S.floorPrice,"قیمت وارد شده از کف قیمت امروز کمتر است").max(S==null?void 0:S.ceilingPrice,"قیمت وارد شده از سقف قیمت امروز بیشتر است"),price3:Iu().typeError("لطفا عدد وارد کنید!").min(S==null?void 0:S.floorPrice,"قیمت وارد شده از کف قیمت امروز کمتر است").max(S==null?void 0:S.ceilingPrice,"قیمت وارد شده از سقف قیمت امروز بیشتر است"),weight:Iu().test("weight","وزن را تا دو رقم اعشار وارد کنید",(l,A)=>A.originalValue&&A.originalValue.toString().length<=4).required("این فیلد اجباری است!").typeError("لطفا وزن را وارد کنید!"),losses:Iu().required("این فیلد اجباری است!").max(B,"تلفات وارد شده از باقیمانده بیشتر است!").typeError("لطفا تعداد تلفات را وارد کنید!"),sellType:_u().test("sellType","نحوه فروش را انتخاب کنید!",(l,A)=>A.originalValue&&Object.values(A.originalValue).some(uu=>uu===!0)).required("این فیلد اجباری است!"),interface_number:X().min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد")})}),N=Du({initialValues:{driverName:"",driverMobile:"",driverCar:"",driverhealthCode:""},validationSchema:_u({driverName:X().required("این فیلد اجباری است!"),driverMobile:X().required("این فیلد اجباری است!").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),driverCar:X().required("این فیلد اجباری است!"),driverhealthCode:X().required("این فیلد اجباری است!").matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!")})}),iu=Du({initialValues:{mobile:"",weight:"",quantity:""},validationSchema:_u({mobile:X().required("شماره موبایل الزامی است").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),weight:Iu(),quantity:Iu()})}),Bu=Du({initialValues:{healthCode:""},validationSchema:_u({healthCode:X().required("این فیلد اجباری است!").matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!")})}),X6=()=>{Bu.values.healthCode.trim()&&(du([...ru,Bu.values.healthCode]),Bu.resetForm(),hu(!1))},Z6=l=>{du(ru.filter((A,uu)=>uu!==l))};i.useEffect(()=>{var l;iu.setFieldValue("mobile",(l=F==null?void 0:F.user)==null?void 0:l.mobile)},[F]);const t6=t.values.noChicken*1e3,J6=u.jsxs(u.Fragment,{children:[u.jsxs(j,{variant:"body1",children:["اینجانب ",(f6=F==null?void 0:F.user)==null?void 0:f6.fullname," موافقت خود را نسبت به موارد ذکر شده اعلام می نمایم."]}),u.jsxs(t0,{children:[u.jsx(n6,{children:u.jsx(f0,{})}),u.jsx(a6,{primary:` بر اساس این توافق نامه در صورت لغو فروش ${t.values.noChicken} قطعه
|
||
مرغ ${t6==null?void 0:t6.toLocaleString()} ریال جریمه خواهم شد.`})]}),u.jsx(j,{})]});i.useEffect(()=>{T(U()),T(D0()).then(l=>{E(l.payload.data),T(D())})},[]),i.useEffect(()=>{let l=t.values.weight;const A=t.values.weight.toString().split(".").join("");t.values.weight&&A.length<=3&&(A.length===2&&(l=A[0]+"."+A[1]),A.length===3&&(l=A[0]+"."+A[1]+A[2])),isNaN(Number.parseFloat(l))?t.setFieldValue("weight",""):t.setFieldValue("weight",Number.parseFloat(l))},[t.values.weight]),i.useEffect(()=>{M&&T(S6()).then(l=>{Array.isArray(l.payload.data)?(s({vertical:"top",horizontal:"center",msg:"قیمت روز مرغ در سامانه ثبت نشده است.",severity:"error"}),T(yu({right:!1,bottom:!1,content:null}))):T(D())})},[M]),i.useEffect(()=>{t.validateForm(),N.validateForm()},[]),i.useEffect(()=>{I&&(T(U()),T(y0(I)).then(l=>{l.payload.data?(c(l.payload.data),T(D())):s({vertical:"top",horizontal:"center",msg:"اطلاعات جوجه ریزی یافت نشد!",severity:"error"}),T(D())}))},[I,F]),i.useEffect(()=>{cu(C==null?void 0:C.leftOver)},[t.values.losses,H,t.values.noChicken,C]),i.useEffect(()=>{y(C==null?void 0:C.quantity),O(C==null?void 0:C.losses),_(C==null?void 0:C.leftOver)},[C]);const e6=()=>(w==null?void 0:w.type)==="killer"?t.values.killer_kill_house_city&&t.values.killer_kill_house_province&&t.values.killer_kill_house_unit_name:!0,r6=()=>ju?iu.isValid:!0,m6=()=>J==="poultry"?L?t.isValid&&r6()&&eu&&N&&a[0]&&e6():t.isValid&&r6()&&eu&&e6():L?t.isValid&&eu&&N&&a[0]&&e6()&&r6():t.isValid&&eu&&e6()&&r6();return u.jsxs(o,{container:!0,gap:$.SMALL,direction:"column",display:"flex",children:[u.jsxs(o,{container:!0,gap:$.SMALL,direction:"column",children:[u.jsx(o,{minWidth:210,children:u.jsx(l6,{disablePortal:!0,id:"combo-box-demo",getOptionDisabled:l=>l.disabled,options:x?x.map(l=>({id:l.key,label:`${l.unitName} / ${l.user.mobile} / ${l.lastHatchingRemainQuantity.toLocaleString()} `,item:l,disabled:!l.lastHatchingRemainQuantity})):[],onChange:(l,A)=>{d(null),v(null),nu(null),Z(A.id),Y(A.item)},renderInput:l=>u.jsx(f,{...l,label:"محل پرورش/تلفن/مانده جوجه ریزی"})})}),F!=null&&F.provinceAllowSellFree?u.jsxs(o,{container:!0,direction:"column",gap:$.SMALL,width:"100%",children:[u.jsx(o,{minWidth:210,children:u.jsx(l6,{disablePortal:!0,id:"hatching",value:b,options:g?g.map(l=>{var A,uu;return{id:l.key,race:l.chickenBreed,selected:l,label:`دوره ${l.period} سالن ${l.hall} نژاد ${l.chickenBreed} باقیمانده ${(A=l==null?void 0:l.lastHatchingDiffrentRequestQuantity)!=null&&A.leftOver?(uu=l==null?void 0:l.lastHatchingDiffrentRequestQuantity)==null?void 0:uu.leftOver:l.leftOver} قطعه`}}):[],onChange:(l,A)=>{nu(A.label),v(A.id),d(A.selected);let uu=A.race;uu.includes("-")&&(uu="ترکیبی"),Au(uu)},renderInput:l=>u.jsx(f,{...l,label:"دوره جوجه ریزی"})})}),u.jsx(o,{children:u.jsx(f,{disabled:!0,fullWidth:!0,id:"outlined-read-only-input",label:"تعداد جوجه ریزی",value:B||"نامشخص",InputProps:{readOnly:!0}})}),u.jsx(o,{children:u.jsx(f,{disabled:!0,fullWidth:!0,id:"outlined-read-only-input",label:"جمع تلفات ثبت شده دامپزشک و مرغدار",value:h||"نامشخص",InputProps:{readOnly:!0}})}),u.jsx(o,{children:u.jsx(f,{disabled:!0,fullWidth:!0,id:"outlined-read-only-input",label:"باقیمانده",value:Q||"نامشخص",InputProps:{readOnly:!0}})})]}):F&&u.jsx(j,{color:"error",variant:"body",children:"مرغدار اجازه فروش مستقیم ندارد!"})]}),C&&u.jsxs(o,{container:!0,gap:$.SMALL,direction:"column",children:[u.jsx(j,{children:"اطلاعات کشتار"}),u.jsxs(o,{container:!0,gap:$.TINY,children:[u.jsxs(o,{container:!0,gap:$.TINY,children:[u.jsx(j,{color:l=>l.palette.grey.A700,variant:"caption",children:"باقیمانده:"}),u.jsx(j,{variant:"button",children:Q}),u.jsx(j,{variant:"button",children:"قطعه"})]}),u.jsx(o,{container:!0,children:u.jsxs(o,{container:!0,gap:$.TINY,alignItems:"center",children:[u.jsx(j,{color:l=>l.palette.grey.A700,variant:"caption",children:"سن مرغ:"}),u.jsx(j,{variant:"button",children:C.age}),u.jsx(j,{variant:"button",children:"روزه"})]})}),u.jsx(o,{container:!0,xs:12,children:u.jsx(Uu,{label:"تاریخ کشتار",id:"slaughterDate",renderInput:l=>u.jsx(f,{fullWidth:!0,...l}),value:t.values.slaughterDate,error:t.touched.slaughterDate?!!t.errors.slaughterDate:null,onChange:l=>{t.setFieldValue("slaughterDate",Tu(l).format("YYYY-MM-DD"))},onBlur:t.handleBlur,helperText:t.touched.slaughterDate&&t.errors.slaughterDate?t.errors.slaughterDate:null})}),u.jsx(o,{container:!0,xs:12,children:u.jsx(C6,{allowLeadingZeros:!0,thousandSeparator:",",id:"noChicken",label:"تعداد مرغ برای کشتار",variant:"outlined",value:t.values.noChicken,error:t.touched.noChicken?!!t.errors.noChicken:null,onChange:t.handleChange,onBlur:t.handleBlur,helperText:t.touched.noChicken&&t.errors.noChicken?t.errors.noChicken:null})}),u.jsx(o,{container:!0,xs:12,children:u.jsx(f,{id:"weight",label:"وزن تقریبی مرغ",variant:"outlined",InputProps:{endAdornment:u.jsx(I6,{position:"end",children:"کیلوگرم"})},value:t.values.weight,error:t.touched.weight?!!t.errors.weight:null,onChange:t.handleChange,onBlur:t.handleBlur,helperText:t.touched.weight&&t.errors.weight?t.errors.weight:null})})]}),t.values.weight&&u.jsxs(j,{variant:"body2",style:{color:"green"},children:["وزن کل:"," ",parseInt(parseInt(t.values.noChicken)*parseFloat(t.values.weight)).toLocaleString()," ","کیلوگرم"]}),u.jsx(o,{display:"none",children:u.jsx(Gu,{children:u.jsx(Ju,{"aria-labelledby":"demo-radio-buttons-group-label",defaultValue:"فروش اتحادیه",name:"radio-buttons-group",onChange:l=>{z(l.currentTarget.value)},children:M==="فروش مزایده ای"&&u.jsxs(o,{container:!0,gap:$.SMALL,children:[u.jsxs(o,{container:!0,gap:$.SMALL,alignItems:"center",children:[u.jsx(j,{color:l=>l.palette.grey.A700,variant:"caption",children:"کف قیمت امروز:"}),u.jsxs(j,{color:"secondary",variant:"button",children:[S!=null&&S.floorPrice?S==null?void 0:S.floorPrice.toLocaleString():"نامشخص"," "," ","ریال"]})]}),u.jsxs(o,{container:!0,gap:$.SMALL,alignItems:"center",children:[u.jsx(j,{color:l=>l.palette.grey.A700,variant:"caption",children:"سقف قیمت امروز:"}),u.jsxs(j,{color:"secondary",variant:"button",children:[S!=null&&S.ceilingPrice?S==null?void 0:S.ceilingPrice.toLocaleString():"نامشخص"," "," ","ریال"]})]}),u.jsx(s6,{style:{width:"100%"}}),su.map((l,A)=>u.jsxs(o,{gap:$.SMALL,container:!0,sx:{minWidth:210},children:[u.jsxs(j,{mb:$.SMALL,display:"flex",children:["پیشنهاد ",A+1]}),u.jsx(C6,{allowLeadingZeros:!0,thousandSeparator:",",error:!1,fullWidth:!0,label:"قیمت پیشنهادی",variant:"outlined",onChange:Q6,id:A}),u.jsxs(Gu,{fullWidth:!0,children:[u.jsx(s0,{id:"demo-simple-select-label",children:"بازه زمانی (ساعت)"}),u.jsxs(i0,{id:A,labelId:"demo-simple-select-label",label:"بازه زمانی (ساعت)",children:[u.jsx(wu,{onClick:qu,id:A,value:"1",children:"1"}),u.jsx(wu,{onClick:qu,id:A,value:"2",children:"2"}),u.jsx(wu,{onClick:qu,id:A,value:"3",children:"3"}),u.jsx(wu,{onClick:qu,id:A,value:"4",children:"4"}),u.jsx(wu,{onClick:qu,id:A,value:"5",children:"5"}),u.jsx(wu,{onClick:qu,id:A,value:"6",children:"6"}),u.jsx(wu,{onClick:qu,id:A,value:"7",children:"7"}),u.jsx(wu,{onClick:qu,id:A,value:"8",children:"8"}),u.jsx(wu,{onClick:qu,id:A,value:"9",children:"9"}),u.jsx(wu,{onClick:qu,id:A,value:"10",children:"10"})]}),u.jsx(c0,{children:t.touched.period1&&t.errors.period1?t.errors.period1:null})]})]},l==null?void 0:l.id)),u.jsxs(o,{container:!0,children:[su.length>1&&u.jsx(Nu,{onClick:G6,"aria-label":"delete",color:"secondary",children:u.jsx(P6,{})}),su.length<3&&u.jsxs(Nu,{xs:12,onClick:K6,"aria-label":"add",color:"primary",children:[u.jsx(Zu,{}),u.jsx(j,{children:"افزودن پیشنهاد جدید"})]})]}),u.jsx(o,{container:!0,sx:{width:"100%"},children:u.jsxs(j,{variant:"body2",children:["در صورت عدم فروش در بورس، از طریق اتحادیه فروش برود",u.jsx(C0,{id:"isUnion",onChange:t.handleChange})]})})]})})})}),u.jsxs(o,{container:!0,gap:$.SMALL,direction:"column",children:[u.jsx(j,{variant:"body1",children:"اطلاعات خریدار"}),u.jsx(l6,{disablePortal:!0,id:"combo-box-demo",getOptionDisabled:l=>l.disabled,options:e?e==null?void 0:e.map(l=>({id:l.key,label:l.type==="killhouse"?`کشتارگاه ${l==null?void 0:l.unitName} / ${l.mobile} / استان ${l==null?void 0:l.province}/ ${l==null?void 0:l.city}`:`کشتارکن ${l==null?void 0:l.fullname} / ${l.mobile} / استان ${l==null?void 0:l.province}/ ${l==null?void 0:l.city}`,item:l,mobile:l.mobile})):[],onChange:(l,A)=>{tu(A.id),P(A.item),J==="buyer"&&iu.setFieldValue("mobile",A.mobile)},renderInput:l=>u.jsx(f,{...l,label:"انتخاب خریدار"})}),(w==null?void 0:w.type)==="killer"&&u.jsxs(o,{container:!0,direction:"column",gap:$.SMALL,children:[u.jsx(f,{id:"killer_kill_house_unit_name",label:"نام کشتارگاه",variant:"outlined",sx:{width:"100%",height:"100%"},value:t.values.killer_kill_house_unit_name,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.killer_kill_house_unit_name?!!t.errors.killer_kill_house_unit_name:null,helperText:t.touched.killer_kill_house_unit_name&&t.errors.killer_kill_house_unit_name?t.errors.killer_kill_house_unit_name:null}),u.jsx(f,{id:"kill_house_unique_id",label:"شناسه یکتا کشتارگاه",variant:"outlined",sx:{width:"100%",height:"100%"},value:t.values.kill_house_unique_id,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.kill_house_unique_id?!!t.errors.kill_house_unique_id:null,helperText:t.touched.kill_house_unique_id&&t.errors.kill_house_unique_id?t.errors.kill_house_unique_id:null}),u.jsx(f,{id:"killer_kill_house_province",label:"استان کشتارگاه",variant:"outlined",sx:{width:"100%",height:"100%"},value:t.values.killer_kill_house_province,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.killer_kill_house_province?!!t.errors.killer_kill_house_province:null,helperText:t.touched.killer_kill_house_province&&t.errors.killer_kill_house_province?t.errors.killer_kill_house_province:null}),u.jsx(f,{id:"killer_kill_house_city",label:"شهر کشتارگاه",variant:"outlined",sx:{width:"100%",height:"100%"},value:t.values.killer_kill_house_city,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.killer_kill_house_city?!!t.errors.killer_kill_house_city:null,helperText:t.touched.killer_kill_house_city&&t.errors.killer_kill_house_city?t.errors.killer_kill_house_city:null})]})]}),(w==null?void 0:w.key)&&u.jsxs(u.Fragment,{children:[u.jsxs(o,{container:!0,xs:12,alignItems:"center",justifyContent:"center",gap:$.SMALL,children:[u.jsxs(Nu,{color:L?"error":"primary",onClick:()=>{Cu(!L)},children:[u.jsxs(j,{variant:"body1",color:L?"error":"primary",children:[" ","افزودن خودرو"]}),L?u.jsx(d6,{}):u.jsx(Zu,{})]}),L&&u.jsxs(o,{container:!0,xs:12,alignItems:"center",justifyContent:"center",gap:$.SMALL,children:[u.jsx(j,{variant:"body1",children:"اطلاعات خودرو حمل"}),u.jsx(f,{label:"نام و نام خانوادگی راننده",name:"driverName",value:N.values.driverName,onChange:N.handleChange,error:N.touched.driverName&&!!N.errors.driverName,helperText:N.touched.driverName&&N.errors.driverName,required:!0,fullWidth:!0}),u.jsx(f,{label:"تلفن راننده",name:"driverMobile",value:N.values.driverMobile,onChange:N.handleChange,onBlur:t.handleBlur,error:N.touched.driverMobile&&!!N.errors.driverMobile,helperText:N.touched.driverMobile&&N.errors.driverMobile,required:!0,fullWidth:!0}),u.jsx(f,{label:"مدل خودرو",name:"driverCar",value:N.values.driverCar,onChange:N.handleChange,error:N.touched.driverCar&&!!N.errors.driverCar,helperText:N.touched.driverCar&&N.errors.driverCar,type:"tel",required:!0,fullWidth:!0}),u.jsx(N6,{width:"100%",handleChange:Su}),u.jsx(f,{id:"driverhealthCode",label:"کد بهداشتی حمل",variant:"outlined",sx:{width:"100%",height:"100%"},value:N.values.driverhealthCode,onChange:N.handleChange,onBlur:N.handleBlur,error:N.touched.driverhealthCode?!!N.errors.driverhealthCode:null,helperText:N.touched.driverhealthCode&&N.errors.driverhealthCode?N.errors.driverhealthCode:null})]})]}),u.jsxs(o,{container:!0,xs:12,spacing:$,alignItems:"center",justifyContent:"center",mt:2,children:[u.jsx(o,{item:!0,xs:12,mb:$.SMALL,children:u.jsx(j,{variant:"body1",sx:{mb:1},children:"کدهای بهداشتی حمل و نقل"})}),ru.length>0&&u.jsx(o,{item:!0,xs:12,mb:2,children:ru.map((l,A)=>u.jsxs(o,{container:!0,spacing:1,alignItems:"center",sx:{mb:1},children:[u.jsx(o,{item:!0,xs:10,children:u.jsx(f,{value:l,disabled:!0,fullWidth:!0,variant:"outlined",label:`کد بهداشتی ${A+1}`})}),u.jsx(o,{item:!0,xs:2,children:u.jsx(Nu,{color:"error",onClick:()=>Z6(A),"aria-label":"حذف",children:u.jsx(P6,{})})})]},A))}),au&&u.jsx(o,{item:!0,xs:12,children:u.jsxs(o,{container:!0,spacing:2,alignItems:"center",children:[u.jsx(o,{item:!0,xs:9,children:u.jsx(f,{label:"کد بهداشتی حمل و نقل جدید",name:"healthCode",value:Bu.values.healthCode,onChange:Bu.handleChange,onBlur:Bu.handleBlur,error:Bu.touched.healthCode&&!!Bu.errors.healthCode,helperText:Bu.touched.healthCode&&Bu.errors.healthCode,variant:"outlined"})}),u.jsx(o,{item:!0,xs:3,children:u.jsx(R,{variant:"contained",color:"success",onClick:X6,startIcon:u.jsx(Zu,{}),fullWidth:!0,sx:{fontSize:"12px"},children:"افزودن"})})]})}),u.jsx(o,{item:!0,xs:12,mt:au?2:0,mb:2,children:u.jsx(R,{variant:"outlined",color:"primary",onClick:()=>hu(!au),startIcon:au?u.jsx(d6,{}):u.jsx(Zu,{}),fullWidth:!0,children:au?"لغو":"افزودن کد بهداشتی حمل"})})]})]}),ju&&u.jsxs(u.Fragment,{children:[u.jsx(g0,{label:"پرداخت کننده",children:u.jsx(Gu,{fullWidth:!0,children:u.jsxs(Ju,{row:!0,"aria-labelledby":"demo-controlled-radio-buttons-group",name:"controlled-radio-buttons-group",value:J,onChange:q,justifyContent:"space-between",children:[u.jsx(Ou,{value:"poultry",control:u.jsx(zu,{}),label:"مرغدار",sx:{marginRight:"auto"}}),u.jsx(Ou,{value:"buyer",control:u.jsx(zu,{}),label:"خریدار"})]})})}),u.jsxs(o,{container:!0,xs:12,alignItems:"center",justifyContent:"center",mt:1,p:1,gap:1,style:{borderStyle:"solid",borderWidth:"2px",borderColor:"gray",borderRadius:"5px"},children:[u.jsxs(j,{variant:"body2",color:"error",children:["از این قسمت میتوانید تلفن"," ",J==="poultry"?"مرغدار":"خریدار"," را ویرایش کنید."]}),u.jsx(f,{fullWidth:!0,disabled:!0,id:"mobile",value:iu.values.mobile,error:iu.touched.mobile?!!iu.errors.mobile:null,onChange:iu.handleChange,onBlur:iu.handleBlur,helperText:iu.touched.mobile&&iu.errors.mobile?iu.errors.mobile:null,label:"موبایل",autoComplete:"current-password",variant:"outlined"})]})]}),u.jsx(o,{container:!0,xs:12,children:u.jsx(f,{id:"interface_number",label:"شماره واسطه (اختیاری)",variant:"outlined",value:t.values.interface_number,error:t.touched.interface_number?!!t.errors.interface_number:null,onChange:t.handleChange,onBlur:t.handleBlur,helperText:t.touched.interface_number&&t.errors.interface_number?t.errors.interface_number:null})}),(ou==null?void 0:ou.length)>1&&u.jsxs(u.Fragment,{children:[u.jsx(s6,{}),u.jsx(o,{children:u.jsxs(Gu,{children:[u.jsx(h6,{id:"demo-radio-buttons-group-label",children:"انتخاب اتحادیه"}),u.jsx(Ju,{"aria-labelledby":"demo-radio-buttons-group-label",defaultValue:(j6=ou[0])==null?void 0:j6.key,name:"radio-buttons-group",onChange:l=>{U6(l.currentTarget.value)},children:ou.map(l=>u.jsx(u.Fragment,{children:u.jsx(Ou,{value:l.key,control:u.jsx(zu,{}),label:l.unitName})}))})]})})]}),u.jsx(o,{children:u.jsx(b0,{title:"تعهد نامه",content:J6,actions:u.jsxs(o,{container:!0,gap:$.TINY,children:[u.jsx(R,{variant:"outlined",color:"error",onClick:()=>{t.setFieldValue("isAccepted",!1)},children:"رد"}),u.jsx(R,{variant:"contained",color:"success",onClick:()=>{t.setFieldValue("isAccepted",!0)},children:"موافقم"})]}),btnTitle:"با تعهد نامه موافق هستم!",isAccepted:t.values.isAccepted})}),u.jsx(o,{mb:$.SMALL,children:u.jsx(R,{fullWidth:!0,disabled:!m6(),onClick:()=>{W()!=="SuperAdmin"&&W()!=="AdminX"&&!_0(Mu,C==null?void 0:C.age,t.values.weight)?s({vertical:"top",horizontal:"center",msg:"میانگین وزنی با احراز سنی مطابقت ندارد. لطفا با اتحادیه تماس بگیرید.",severity:"error"}):(T(U()),M==="فروش مزایده ای"?T(E6({operator_key:(ou==null?void 0:ou.length)>1?Xu:"",poultry_hatching_key:n,quantity:t.values.noChicken,send_date:t.values.slaughterDate,chicken_breed:K,Index_weight:t.values.weight,union:t.values.isUnion,losses:t.values.losses!==""?t.values.losses:0,auction:!0,auction_list:su.map((l,A)=>({pricing_key:V,fee:l.value?l.value:S==null?void 0:S.floorPrice,hour:xu[A].value?xu[A].value:"4"}))})).then(l=>{T(D()),l.error?l.error.message.includes("403")?s({vertical:"top",horizontal:"center",msg:"قیمت پیشنهادی نباید از حداکثر قیمت روز بیشتر باشد.",severity:"error"}):s({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(T(c6()),s({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),T(yu({right:!1,bottom:!1,content:null})))}):T(E6({operator_key:(ou==null?void 0:ou.length)>1?Xu:"",poultry_hatching_key:n,poultry_key:F.key,role:W(),quantity:t.values.noChicken,send_date:t.values.slaughterDate,interface_number:t.values.interface_number?t.values.interface_number:null,chicken_breed:K,Index_weight:t.values.weight,hatching_left_over:parseInt(H),losses:t.values.losses!==""?t.values.losses:0,auction_list:[],cash:t.values.sellType.cash,credit:t.values.sellType.haveTime,kill_house_list:t.values.selectedSlaughters,killer_kill_house_unit_name:(w==null?void 0:w.type)==="killer"?t.values.killer_kill_house_unit_name:null,killer_kill_house_city:(w==null?void 0:w.type)==="killer"?t.values.killer_kill_house_city:null,killer_kill_house_province:(w==null?void 0:w.type)==="killer"?t.values.killer_kill_house_province:null,kill_house_unique_id:(w==null?void 0:w.type)==="killer"?t.values.kill_house_unique_id:null,out_province_driver_info:{driverName:L?N.values.driverName:null,driverMobile:L?N.values.driverMobile:null,driverCar:L?N.values.driverCar:null,driverPelak:L?a[0]+" "+a[1]+" "+a[2]+" "+a[3]:null,driverhealthCode:L?N.values.driverhealthCode:null},traffic_codes:ru.length>0?ru:null,out_province_poultry_request_buyer_key:eu,payer_type:J,poultry_mobile:J==="poultry"?iu.values.mobile:null,buyer_mobile:J==="buyer"?iu.values.mobile:null})).then(l=>{var A;if(T(D()),(A=l.payload)!=null&&A.error){s({vertical:"top",horizontal:"center",msg:l.payload.error,severity:"error"});return}else if(l.error){s({vertical:"top",horizontal:"center",msg:l.error.message||"خطا در ثبت درخواست",severity:"error"});return}else s({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),r(1),T(yu({right:!1,bottom:!1,content:null}))}).catch(l=>{T(D()),s({vertical:"top",horizontal:"center",msg:l.message||"خطا در ثبت درخواست",severity:"error"})}))},size:"large",variant:"contained",children:"ثبت درخواست"})})]})]})},W6=ku("PROVINCE_OUT_REQUEST_CANCEL_REQUEST",async(r,{dispatch:s})=>{try{s(U());const{data:n,status:v}=await G.put("cancel-out-poultry_request/0/",r);return s(D()),{data:n,status:v}}catch(n){return s(D()),{error:n.response.data.result}}}),R0=ku("PROVINCE_FREE_SALE_EDIT_REQUEST",async(r,{dispatch:s})=>{s(U());try{const{data:n,status:v}=await G.put("Poultry_Request/0/",r);return s(D()),{data:n,status:v}}catch(n){return s(D()),{error:n.response.data.result}}}),V6=({item:r,fetchApiData:s})=>{var Q,cu,F,Y,e,lu,eu,tu,w,P,b,nu,J;const[n]=i.useContext(bu),[v,g]=i.useState(!!((Q=r==null?void 0:r.outProvinceDriverInfo)!=null&&Q.driverName)),c=fu(),C=Du({initialValues:{noChicken:r!=null&&r.quantity?r==null?void 0:r.quantity:"",weight:r!=null&&r.IndexWeight?r==null?void 0:r.IndexWeight:"",interface_number:(r==null?void 0:r.interfaceNumber)||""},validationSchema:_u({noChicken:X().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!"),weight:Iu().test("weight","وزن را تا دو رقم اعشار وارد کنید",(k,L)=>L.originalValue&&L.originalValue.toString().length<=4).required("این فیلد اجباری است!").typeError("لطفا وزن را وارد کنید!"),interface_number:X().min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد")})}),d=Du({initialValues:{driverName:(cu=r==null?void 0:r.outProvinceDriverInfo)!=null&&cu.driverName?(F=r==null?void 0:r.outProvinceDriverInfo)==null?void 0:F.driverName:"",driverMobile:(Y=r==null?void 0:r.outProvinceDriverInfo)!=null&&Y.driverMobile?(e=r==null?void 0:r.outProvinceDriverInfo)==null?void 0:e.driverMobile:"",driverCar:(lu=r==null?void 0:r.outProvinceDriverInfo)!=null&&lu.driverCar?(eu=r==null?void 0:r.outProvinceDriverInfo)==null?void 0:eu.driverCar:"",driverhealthCode:(tu=r==null?void 0:r.outProvinceDriverInfo)!=null&&tu.driverhealthCode?(w=r==null?void 0:r.outProvinceDriverInfo)==null?void 0:w.driverhealthCode:""},validationSchema:_u({driverName:X().required("این فیلد اجباری است!"),driverMobile:X().required("این فیلد اجباری است!"),driverCar:X().required("این فیلد اجباری است!"),driverhealthCode:X().required("این فیلد اجباری است!")})}),x=Du({initialValues:{mobile:"",weight:"",quantity:""},validationSchema:_u({mobile:X().required("شماره موبایل الزامی است").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),weight:Iu(),quantity:Iu()})}),[E,I]=i.useState([]),Z=(k,L,Cu,ru)=>{I([k,L,Cu,ru])},[B,y]=i.useState([]),[h,O]=i.useState(),[H,_]=i.useState(),[m,M]=i.useState();i.useEffect(()=>{var k;O((k=r==null?void 0:r.outProvincePoultryRequestBuyer)==null?void 0:k.key),c(y6()).then(L=>{M(L.payload.data.status)}),c(T6()).then(L=>{y(L.payload.data)})},[]);const[z,V]=i.useState("poultry"),p=k=>{V(k.target.value),k.target.value==="poultry"?x.setFieldValue("mobile",r.poultry.user.mobile):H?x.setFieldValue("mobile",H.mobile):x.setFieldValue("mobile",r==null?void 0:r.outProvincePoultryRequestBuyer.mobile)},K=()=>m?x.isValid:!0,Au=()=>z==="poultry"?v?C.isValid&&K()&&h&&d&&E[0]:C.isValid&&x.isValid&&h&&K():v?C.isValid&&h&&d&&E[0]&&K():C.isValid&&h&&K();return i.useEffect(()=>{x.setFieldValue("mobile",r.poultry.user.mobile)},[]),u.jsx(o,{container:!0,gap:$.SMALL,direction:"column",display:"flex",children:u.jsxs(o,{container:!0,gap:$.SMALL,direction:"column",children:[u.jsxs(o,{xs:12,container:!0,justifyContent:"space-between",alignItems:"center",children:[u.jsxs(j,{variant:"body2",style:{color:"gray"},children:["وزن کل:"," "]}),u.jsx(j,{variant:"body2",children:(P=Math.floor(r.IndexWeight*r.quantity))==null?void 0:P.toLocaleString()})]})," ",u.jsx(C6,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"noChicken",label:"تعداد مرغ برای کشتار",variant:"outlined",value:C.values.noChicken,error:C.touched.noChicken?!!C.errors.noChicken:null,onChange:C.handleChange,onBlur:C.handleBlur,helperText:C.touched.noChicken&&C.errors.noChicken?C.errors.noChicken:null}),u.jsx(f,{id:"weight",label:"وزن تقریبی مرغ",variant:"outlined",InputProps:{endAdornment:u.jsx(I6,{position:"end",children:"کیلوگرم"})},value:C.values.weight,error:C.touched.weight?!!C.errors.weight:null,onChange:C.handleChange,onBlur:C.handleBlur,helperText:C.touched.weight&&C.errors.weight?C.errors.weight:null}),u.jsxs(o,{xs:12,container:!0,justifyContent:"space-between",alignItems:"center",children:[u.jsxs(j,{variant:"body2",style:{color:"gray"},children:["وزن کل:"," "]}),u.jsxs(j,{variant:"body2",children:[(b=Math.floor(parseInt(C.values.noChicken)*parseFloat(C.values.weight)))==null?void 0:b.toLocaleString()," ","کیلوگرم"]})]}),u.jsx(s6,{}),u.jsx(j,{variant:"body1",children:"اطلاعات خریدار"}),u.jsx(l6,{disablePortal:!0,id:"combo-box-demo",getOptionDisabled:k=>k.disabled,options:B?B==null?void 0:B.map(k=>({id:k.key,label:`${k==null?void 0:k.fullname} / ${k.mobile} / استان ${k==null?void 0:k.province}/ ${k==null?void 0:k.city}`,item:k,mobile:k.mobile})):[],onChange:(k,L)=>{O(L.id),_(L.item),z==="buyer"&&x.setFieldValue("mobile",L.mobile)},renderInput:k=>u.jsx(f,{...k,label:"انتخاب خریدار"})}),u.jsxs(o,{container:!0,xs:12,style:{borderStyle:"solid",borderWidth:"2px",borderColor:"red",borderRadius:"10px",padding:"5px"},alignItems:"center",children:[u.jsxs(j,{variant:"body2",color:"primary",children:["خریدار:"," "]}),H?u.jsxs(j,{variant:"body2",children:[" ",H==null?void 0:H.fullname," (",H==null?void 0:H.mobile,")"]}):u.jsxs(j,{variant:"body2",children:[" ",(nu=r==null?void 0:r.outProvincePoultryRequestBuyer)==null?void 0:nu.fullname," (",(J=r==null?void 0:r.outProvincePoultryRequestBuyer)==null?void 0:J.mobile,")"]})]}),u.jsxs(o,{container:!0,xs:12,alignItems:"center",justifyContent:"center",gap:$.SMALL,children:[u.jsxs(Nu,{color:v?"error":"primary",onClick:()=>{g(!v)},children:[u.jsxs(j,{variant:"body1",color:v?"error":"primary",children:[" ","افزودن اطلاعات خودرو"]}),v?u.jsx(d6,{}):u.jsx(Zu,{})]}),v&&u.jsxs(o,{container:!0,xs:12,alignItems:"center",justifyContent:"center",gap:$.SMALL,children:[u.jsx(j,{variant:"body1",children:"اطلاعات خودرو حمل"}),u.jsx(f,{label:"نام و نام خانوادگی راننده",name:"driverName",value:d.values.driverName,onChange:d.handleChange,error:d.touched.driverName&&!!d.errors.driverName,helperText:d.touched.driverName&&d.errors.driverName,required:!0,fullWidth:!0}),u.jsx(f,{label:"تلفن راننده",name:"driverMobile",value:d.values.driverMobile,onChange:d.handleChange,error:d.touched.driverMobile&&!!d.errors.driverMobile,helperText:d.touched.driverMobile&&d.errors.driverMobile,required:!0,fullWidth:!0}),u.jsx(f,{label:"مدل خودرو",name:"driverCar",value:d.values.driverCar,onChange:d.handleChange,error:d.touched.driverCar&&!!d.errors.driverCar,helperText:d.touched.driverCar&&d.errors.driverCar,type:"tel",required:!0,fullWidth:!0}),u.jsx(N6,{width:"100%",handleChange:Z}),u.jsx(f,{label:"کد بهداشتی حمل",name:"driverhealthCode",value:d.values.driverhealthCode,onChange:d.handleChange,error:d.touched.driverhealthCode&&!!d.errors.driverhealthCode,helperText:d.touched.driverhealthCode&&d.errors.driverhealthCode,required:!0,fullWidth:!0})]})]}),m&&u.jsxs(u.Fragment,{children:[u.jsxs(Gu,{children:[u.jsx(h6,{id:"demo-controlled-radio-buttons-group",children:"پرداخت کننده"}),u.jsxs(Ju,{row:!0,"aria-labelledby":"demo-controlled-radio-buttons-group",name:"controlled-radio-buttons-group",value:z,onChange:p,children:[u.jsx(Ou,{value:"poultry",control:u.jsx(zu,{}),label:"مرغدار"}),u.jsx(Ou,{value:"buyer",control:u.jsx(zu,{}),label:"خریدار"})]})]}),u.jsxs(o,{container:!0,xs:12,alignItems:"center",justifyContent:"center",mt:1,p:1,gap:1,style:{borderStyle:"solid",borderWidth:"2px",borderColor:"gray",borderRadius:"5px"},children:[u.jsxs(j,{variant:"body2",color:"error",children:["از این قسمت میتوانید تلفن"," ",z==="poultry"?"مرغدار":"خریدار"," را ویرایش کنید."]}),u.jsx(f,{fullWidth:!0,disabled:!0,id:"mobile",value:x.values.mobile,error:x.touched.mobile?!!x.errors.mobile:null,onChange:x.handleChange,onBlur:x.handleBlur,helperText:x.touched.mobile&&x.errors.mobile?x.errors.mobile:null,label:"موبایل",autoComplete:"current-password",variant:"outlined"})]}),u.jsx(o,{container:!0,xs:12,children:u.jsx(f,{id:"interface_number",label:"شماره واسطه (اختیاری)",variant:"outlined",value:C.values.interface_number,error:C.touched.interface_number?!!C.errors.interface_number:null,onChange:C.handleChange,onBlur:C.handleBlur,helperText:C.touched.interface_number&&C.errors.interface_number?C.errors.interface_number:null})})]}),u.jsx(o,{mb:$.SMALL,children:u.jsx(R,{fullWidth:!0,variant:"contained",disabled:!Au(),onClick:()=>{c(R0({edit:!0,quantity:C.values.noChicken,Index_weight:parseInt(C.values.weight),interface_number:C.values.interface_number,poultry_request_key:r==null?void 0:r.key,out_province_driver_info:{driverName:v?d.values.driverName:null,driverMobile:v?d.values.driverMobile:null,driverCar:v?d.values.driverCar:null,driverPelak:v?E[0]+" "+E[1]+" "+E[2]+" "+E[3]:null,driverhealthCode:v?d.values.driverhealthCode:null},out_province_poultry_request_buyer_key:h,poultry_mobile:z==="poultry"?x.values.mobile:null,buyer_mobile:z==="buyer"?x.values.mobile:null})).then(k=>{k.payload.error?n({vertical:"top",horizontal:"center",msg:k.payload.error,severity:"error"}):(s(1),c(yu({right:!1,bottom:!1,content:null})),n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ویرایش درخواست"})})]})})},N0=({fetchApiData:r,item:s})=>{const n=fu(),[v,g]=i.useState(null),c=h=>{g(h.currentTarget)},C=()=>{g(null)},d=!!v,x=d?"popover":void 0,[E]=i.useContext(bu),I=W(),Z=()=>{C(),n(yu({title:"ویرایش درخواست",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(V6,{item:s,fetchApiData:r})}))},B=()=>{C(),n(Vu({title:"آیا از لغو درخواست مطمئن هستید؟",content:u.jsxs(o,{children:[u.jsx(R,{variant:"contained",onClick:()=>{n(W6({role:I,poultry_request_key:s.key})).then(h=>{h.payload.error?E({vertical:"top",horizontal:"center",msg:h.payload.error,severity:"error"}):(r(1),E({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))}),n(Lu())},children:"بله"}),u.jsx(R,{onClick:()=>{n(Lu())},children:"خیر"})]})}))},y=[{key:"edit",label:"ویرایش",color:"primary.main",icon:u.jsx(F6,{}),action:Z,disabled:!!(s.quarantineCode||(s==null?void 0:s.outState)==="پرداخت شده")},{key:"cancel",label:"لغو",color:"error.main",icon:u.jsx(M6,{}),action:B,disabled:!s.provinceState==="pending"||!s.provinceState==="accepted"||(s==null?void 0:s.outState)==="پرداخت شده"||s.quarantineCode}];return u.jsxs(o,{container:!0,children:[u.jsx(Nu,{"aria-describedby":x,variant:"contained",color:"primary",onClick:c,children:u.jsx(x6,{})}),u.jsx(A6,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:x,open:d,anchorEl:v,onClose:C,children:u.jsx(v6,{sx:{width:220,p:1},children:y.map(h=>u.jsxs(p6,{onClick:()=>{h.disabled||h.action()},disabled:!!h.disabled,sx:{borderRadius:1,mb:.5,color:h.disabled?"text.disabled":h.color,"&:last-of-type":{mb:0}},children:[u.jsx(n6,{sx:{color:h.disabled?"text.disabled":h.color,minWidth:40},children:h.icon}),u.jsx(a6,{primary:u.jsx(j,{sx:{color:h.disabled?"text.disabled":h.color,fontWeight:600},children:h.label})})]},h.key))})})]})},q6=({state:r})=>{const[s,n]=i.useState([]),[v,g]=i.useState(0),[c,C]=i.useState(10),[d,x]=i.useState(""),[E,I]=i.useState(1),[Z,B]=i.useState([]),[y,h]=i.useState([]),[,,O,H,_,m]=i.useContext(bu),M=mu(F=>F.userSlice.userProfile.key),z=async F=>{p(U());const Y=await G.get(`out-province-poultry-requests/?search=filter&value=${d}&page=${F}&role=${W()}&page_size=${c}&date1=${O}&date2=${_}&state=${r}`);p(D()),n(Y.data.results),g(Y.data.count)},V=F=>{z(F),I(F)},p=fu();i.useEffect(()=>{const F=Tu(new Date).format("YYYY-MM-DD");H(F),m(F)},[]);const K=F=>{x(F.target.value)},Au=F=>{C(F),I(1)},Q=()=>{z(E!==0?E:1)};i.useEffect(()=>{const F=s==null?void 0:s.map((e,lu)=>{var eu,tu,w,P,b,nu,J,k,L,Cu,ru,du,au,hu,q,a,vu,Su,Eu,$u,su,pu,xu,Fu,ju,Pu;return[E===1?lu+1:lu+c*(E-1)+1,W()==="CityOperator"?"-":u.jsx(N0,{item:e,fetchApiData:z}),u.jsx(i6,{label:e.outState,color:e.outState==="تایید شده"?"success":e.outState==="رد شده"?"error":"info",size:"small",variant:"outlined"},lu),`${(eu=e==null?void 0:e.totalWageAmount)==null?void 0:eu.toLocaleString()} ریال`,`${(tu=e==null?void 0:e.registrar)==null?void 0:tu.fullname}`,e.orderCode,(w=e.buyer)!=null&&w.firstName?`${(P=e.buyer)==null?void 0:P.firstName} ${(b=e.buyer)==null?void 0:b.lastName} (${(nu=e.buyer)==null?void 0:nu.mobile}) / ${e.buyer.province} - ${e.buyer.city}`:(e==null?void 0:e.outProvincePoultryRequestBuyer.type)==="killhouse"?`کشتارگاه ${e.buyerFullname} (${e.buyerMobile}) / شناسه یکتا ${(J=e.outProvincePoultryRequestBuyer)==null?void 0:J.killHouseUniqueId} / ${e.buyerProvince} - ${e.buyerCity}`:`کشتارکن ${e.buyerFullname} (${e.buyerMobile}) / نام کشتارگاه ${e.killerKillHouseUnitName?e.killerKillHouseUnitName:"-"} / شناسه یکتا ${e.killerKillHouseUniqueId?e.killerKillHouseUniqueId:"-"} / استان ${e.killerKillHouseProvince?e.killerKillHouseProvince:"-"} / شهر ${e.killerKillHouseCity?e.killerKillHouseCity:"-"}`,((k=e==null?void 0:e.outProvincePoultryRequestBuyer)==null?void 0:k.type)==="killhouse"?"محل کشتارگاه":e!=null&&e.killerKillHouseUnitName?`کشتارگاه ${e==null?void 0:e.killerKillHouseUnitName} / ${e==null?void 0:e.killerKillHouseProvince} / ${e==null?void 0:e.killerKillHouseCity}`:"-",e!=null&&e.hasWage?e==null?void 0:e.payerFullname:"-",`${(L=e.poultry)==null?void 0:L.unitName} (${e.poultry.user.mobile})`,`${e==null?void 0:e.vetFarmName} (${e==null?void 0:e.vetFarmMobile})`,u.jsx(Yu,{placement:"left-start",children:u.jsx(R,{variant:"contained",color:"primary",size:"small",sx:{minWidth:0,px:1.5,py:.25,fontSize:"0.8rem"},onClick:()=>{p(Vu({title:"ثبت کد قرنطینه",size:{xs:"340px",md:"690px"},content:u.jsx(k0,{readOnly:W()==="CityOperator",item:e,updateTable:Q},lu)}))},children:W()==="VetFarm"||W()==="AdminX"?"ثبت":"مشاهده"})},lu),Qu(e==null?void 0:e.createDate),Qu(e.sendDate),e.hatching.age,(Cu=e.IndexWeight)==null?void 0:Cu.toLocaleString(),e.quantity.toLocaleString(),(ru=Math.floor(e.IndexWeight*e.quantity))==null?void 0:ru.toLocaleString(),e!=null&&e.freezing?"انجماد":"عادی",e!=null&&e.hasWage?"دارد":"ندارد",(du=e.hatching)==null?void 0:du.city,(au=e.hatching)==null?void 0:au.province,(hu=e.hatching.leftOver)==null?void 0:hu.toLocaleString(),(q=e.hatching.hatchingQuantity)==null?void 0:q.toLocaleString(),(a=e==null?void 0:e.outProvinceDriverInfo)!=null&&a.driverCar?(vu=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:vu.driverCar:"-",(Su=e==null?void 0:e.outProvinceDriverInfo)!=null&&Su.driverPelak?(Eu=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:Eu.driverPelak:"-",($u=e==null?void 0:e.outProvinceDriverInfo)!=null&&$u.driverName?(su=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:su.driverName:"-",(pu=e==null?void 0:e.outProvinceDriverInfo)!=null&&pu.driverMobile?(xu=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:xu.driverMobile:"-",(Fu=e==null?void 0:e.outProvinceDriverInfo)!=null&&Fu.driverhealthCode?(ju=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:ju.driverhealthCode:"-",(Pu=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:Pu.driverhealthCode]});B(F);const Y=s==null?void 0:s.map((e,lu)=>{var eu,tu,w,P,b,nu,J,k,L,Cu,ru,du,au,hu,q,a,vu,Su,Eu,$u,su,pu,xu,Fu,ju,Pu,Mu,T,S,ou,Ru;return[E===1?lu+1:lu+c*(E-1)+1,u.jsx(i6,{label:e.outState,color:e.outState==="تایید شده"?"success":e.outState==="رد شده"?"error":"info",size:"small",variant:"outlined"},lu),`${(eu=e==null?void 0:e.totalWageAmount)==null?void 0:eu.toLocaleString()} ریال`,(tu=e.outProvinceRequestCanceller)!=null&&tu.fullname?`${(w=e.outProvinceRequestCanceller)==null?void 0:w.fullname} (${(P=e.outProvinceRequestCanceller)==null?void 0:P.mobile})`:(b=e.agent)!=null&&b.fullname?`${(nu=e.agent)==null?void 0:nu.fullname} (${(J=e.agent)==null?void 0:J.mobile})`:"-",`${(k=e==null?void 0:e.registrar)==null?void 0:k.fullname}`,e.orderCode,(L=e.buyer)!=null&&L.firstName?`${(Cu=e.buyer)==null?void 0:Cu.firstName} ${(ru=e.buyer)==null?void 0:ru.lastName} (${(du=e.buyer)==null?void 0:du.mobile}) / ${e.buyer.province} - ${e.buyer.city}`:(e==null?void 0:e.outProvincePoultryRequestBuyer.type)==="killhouse"?`کشتارگاه ${e.buyerFullname} (${e.buyerMobile}) / شناسه یکتا ${(au=e.outProvincePoultryRequestBuyer)==null?void 0:au.killHouseUniqueId} / ${e.buyerProvince} - ${e.buyerCity}`:`کشتارکن ${e.buyerFullname} (${e.buyerMobile}) / نام کشتارگاه ${e.killerKillHouseUnitName?e.killerKillHouseUnitName:"-"} / شناسه یکتا ${e.killerKillHouseUniqueId?e.killerKillHouseUniqueId:"-"} / استان ${e.killerKillHouseProvince?e.killerKillHouseProvince:"-"} / شهر ${e.killerKillHouseCity?e.killerKillHouseCity:"-"}`,((hu=e==null?void 0:e.outProvincePoultryRequestBuyer)==null?void 0:hu.type)==="killhouse"?"محل کشتارگاه":e!=null&&e.killerKillHouseUnitName?`کشتارگاه ${e==null?void 0:e.killerKillHouseUnitName} / ${e==null?void 0:e.killerKillHouseProvince} / ${e==null?void 0:e.killerKillHouseCity}`:"-",e!=null&&e.hasWage?e==null?void 0:e.payerFullname:"-",`${(q=e.poultry)==null?void 0:q.unitName} (${e.poultry.user.mobile})`,`${e==null?void 0:e.vetFarmName} (${e==null?void 0:e.vetFarmMobile})`,e.quarantineCode?e==null?void 0:e.quarantineCode:"-",Qu(e==null?void 0:e.createDate),Qu(e.sendDate),(a=e.IndexWeight)==null?void 0:a.toLocaleString(),e.hatching.age,e.quantity.toLocaleString(),(vu=Math.floor(e.IndexWeight*e.quantity))==null?void 0:vu.toLocaleString(),e!=null&&e.freezing?"انجماد":"عادی",e!=null&&e.hasWage?"دارد":"ندارد",(Su=e.hatching)==null?void 0:Su.city,(Eu=e.hatching)==null?void 0:Eu.province,($u=e.hatching.leftOver)==null?void 0:$u.toLocaleString(),(su=e.hatching.hatchingQuantity)==null?void 0:su.toLocaleString(),(pu=e==null?void 0:e.outProvinceDriverInfo)!=null&&pu.driverCar?(xu=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:xu.driverCar:"-",(Fu=e==null?void 0:e.outProvinceDriverInfo)!=null&&Fu.driverPelak?(ju=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:ju.driverPelak:"-",(Pu=e==null?void 0:e.outProvinceDriverInfo)!=null&&Pu.driverName?(Mu=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:Mu.driverName:"-",(T=e==null?void 0:e.outProvinceDriverInfo)!=null&&T.driverMobile?(S=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:S.driverMobile:"-",(ou=e==null?void 0:e.outProvinceDriverInfo)!=null&&ou.driverhealthCode?(Ru=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:Ru.driverhealthCode:"-"]});h(Y)},[s]),i.useEffect(()=>{z(1)},[p,O,_,c]);const cu=async F=>{F.preventDefault(),p(U());try{const Y=await await G.get(`out-province-poultry-requests/?search=filter&value=${d}&date1=${O}&date2=${_}&state=${r}&role=${W()}`);n(Y.data.results),g(Y.data.count),p(D())}catch(Y){console.error("Error fetching data:",Y)}};return u.jsxs(o,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,mt:4,children:[u.jsxs(o,{container:!0,gap:2,xs:12,children:[u.jsx(o,{children:u.jsx(Uu,{label:"از تاریخ",id:"date",renderInput:F=>u.jsx(f,{style:{width:"160px"},...F}),value:O,onChange:F=>{H(Tu(F).format("YYYY-MM-DD"))}})}),u.jsx(o,{children:u.jsx(Uu,{label:"تا تاریخ",id:"date",renderInput:F=>u.jsx(f,{style:{width:"160px"},...F}),value:_,onChange:F=>{m(Tu(F).format("YYYY-MM-DD"))}})}),u.jsxs("form",{onSubmit:cu,children:[u.jsx(f,{id:"outlined-basic",size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},onChange:K}),u.jsx(R,{type:"submit",onClick:cu,endIcon:u.jsx(o6,{}),children:"جستجو"})]}),u.jsx(o,{children:u.jsx(Yu,{title:"خروجی اکسل",children:u.jsx("a",{href:`${G.defaults.baseURL}bar_free_excel/?date1=${O}&date2=${_}&state=${r}&role=${W()}&key=${M}`,rel:"noreferrer",children:u.jsx(R,{color:"success",children:u.jsx(u6,{size:32})})})})})]}),u.jsx(o,{container:!0,gap:2,xs:12,justifyContent:"center",children:u.jsx(Hu,{data:r==="accepted"?Z:y,columns:r==="accepted"?["ردیف","عملیات","وضعیت","مبلغ کل ","ثبت کننده سفارش","کد سفارش","اطلاعات خریدار","محل کشتار","پرداخت کننده","مرغدار","دامپزشک فارم","کد قرنطینه","تاریخ ثبت درخواست","تاریخ کشتار","سن مرغ","میانگین وزن (کیلوگرم)","تعداد","وزن کل (کیلوگرم)","نوع کشتار","تعرفه","شهر","استان","مانده در سالن","جوجه ریزی اولیه","نوع خودرو","پلاک","نام راننده","تلفن راننده","کد بهداشتی ماشین"]:["ردیف","وضعیت","مبلغ کل","رد/لغو کننده","ثبت کننده سفارش","کد سفارش","اطلاعات خریدار","محل کشتار","پرداخت کننده","مرغدار","دامپزشک فارم","کد قرنطینه","تاریخ ثبت درخواست","تاریخ کشتار","میانگین وزن (کیلوگرم)","سن مرغ","تعداد","وزن کل (کیلوگرم)","نوع کشتار","تعرفه","شهر","استان","مانده در سالن","جوجه ریزی اولیه","نوع خودرو","پلاک","نام راننده","تلفن راننده","کد بهداشتی ماشین"],handlePageChange:V,totalRows:v,page:E,perPage:c,handlePerRowsChange:Au,title:r==="accepted"?" تایید شده":" رد شده"})})]})},M0=ku("PROVINCE_CREATE_FREE_SALE_BUYER",async(r,{dispatch:s})=>{try{s(U());const{data:n,status:v}=await G.post("out-province-poultry-request-buyers/",r);return s(D()),{data:n,status:v}}catch(n){return s(D()),{error:n.response.data.result}}}),O6=ku("PROVINCE_FREE_SALES_EDIT_BUYER",async(r,{dispatch:s})=>{try{s(U());const{data:n,status:v}=await G.put("out-province-poultry-request-buyers/0/",r);return s(D()),{data:n,status:v}}catch(n){return s(D()),{error:n.response.data.result}}}),z6=({fetchApiData:r,isEdit:s,item:n})=>{const[v]=i.useContext(bu),g=fu(),c=Du({initialValues:{fullname:n!=null&&n.fullname?n==null?void 0:n.fullname:"",mobile:n!=null&&n.mobile?n==null?void 0:n.mobile:"",province:n!=null&&n.province?n==null?void 0:n.province:"",city:n!=null&&n.city?n==null?void 0:n.city:"",unitname:n!=null&&n.unitName?n==null?void 0:n.unitName:"",uniqueCode:n!=null&&n.killHouseUniqueId?n==null?void 0:n.killHouseUniqueId:""},validationSchema:_u({fullname:X().required("این فیلد اجباری است!").matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!"),mobile:X().required("شماره موبایل الزامی است").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),province:X().required("این فیلد اجباری است!").matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!"),city:X().required("این فیلد اجباری است!").matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!"),unitname:X().matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!"),uniqueCode:X().matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!")})});i.useEffect(()=>{c.validateForm()},[]);const[C,d]=i.useState(n!=null&&n.type?n==null?void 0:n.type:"killhouse"),x=I=>{d(I.target.value)},E=()=>C==="killhouse"?c.isValid&&c.values.unitname:c.isValid;return u.jsx(o,{container:!0,direction:"column",flex:"1",justifyContent:"space-between",gap:$.SMALL,children:u.jsxs(o,{container:!0,direction:"column",gap:$.TINY,children:[u.jsx(f,{id:"fullname",label:"نام و نام خانوادگی خریدار",variant:"outlined",sx:{width:"100%",height:"100%"},value:c.values.fullname,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.fullname?!!c.errors.fullname:null,helperText:c.touched.fullname&&c.errors.fullname?c.errors.fullname:null}),u.jsx(f,{id:"mobile",label:"موبایل",variant:"outlined",sx:{width:"100%",height:"100%"},value:c.values.mobile,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.mobile?!!c.errors.mobile:null,helperText:c.touched.mobile&&c.errors.mobile?c.errors.mobile:null}),u.jsx(f,{id:"province",label:"استان",variant:"outlined",sx:{width:"100%",height:"100%"},value:c.values.province,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.province?!!c.errors.province:null,helperText:c.touched.province&&c.errors.province?c.errors.province:null}),u.jsx(f,{id:"city",label:"شهر",variant:"outlined",sx:{width:"100%",height:"100%"},value:c.values.city,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.city?!!c.errors.city:null,helperText:c.touched.city&&c.errors.city?c.errors.city:null}),u.jsxs(Gu,{children:[u.jsx(h6,{id:"demo-controlled-radio-buttons-group",children:"نوع خریدار"}),u.jsxs(Ju,{row:!0,"aria-labelledby":"demo-controlled-radio-buttons-group",name:"controlled-radio-buttons-group",value:C,onChange:x,children:[u.jsx(Ou,{value:"killhouse",control:u.jsx(zu,{}),label:"کشتارگاه"}),u.jsx(Ou,{value:"killer",control:u.jsx(zu,{}),label:"کشتارکن"})]})]}),C==="killhouse"&&u.jsxs(o,{container:!0,direction:"column",gap:$.TINY,children:[u.jsx(f,{id:"unitname",label:"نام کشتارگاه",variant:"outlined",sx:{width:"100%",height:"100%"},value:c.values.unitname,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.unitname?!!c.errors.unitname:null,helperText:c.touched.unitname&&c.errors.unitname?c.errors.unitname:null}),u.jsx(f,{id:"uniqueCode",label:"شناسه یکتا",variant:"outlined",sx:{width:"100%",height:"100%"},value:c.values.uniqueCode,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.uniqueCode?!!c.errors.uniqueCode:null,helperText:c.touched.uniqueCode&&c.errors.uniqueCode?c.errors.uniqueCode:null})]}),u.jsx(R,{variant:"contained",disabled:!E(),onClick:()=>{s?g(O6({buyer_key:n==null?void 0:n.key,type:C,fullname:c.values.fullname,mobile:c.values.mobile,unit_name:C==="killhouse"?c.values.unitname:null,city:c.values.city,province:c.values.province,kill_house_unique_id:C==="killhouse"?c.values.uniqueCode:null})).then(I=>{I.payload.error?v({vertical:"top",horizontal:"center",msg:I.payload.error,severity:"error"}):(r(1),g(yu({right:!1,bottom:!1,content:null})),v({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))}):g(M0({type:C,fullname:c.values.fullname,mobile:c.values.mobile,unit_name:C==="killhouse"?c.values.unitname:null,city:c.values.city,province:c.values.province,kill_house_unique_id:C==="killhouse"?c.values.uniqueCode:null})).then(I=>{I.payload.error?v({vertical:"top",horizontal:"center",msg:I.payload.error,severity:"error"}):(r(1),g(yu({right:!1,bottom:!1,content:null})),v({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ثبت"})]})})},W0=({item:r,fetchApiData:s,openNotif:n})=>{const v=fu(),[g,c]=i.useState(null),C=y=>{c(y.currentTarget)},d=()=>{c(null)},x=()=>{d(),v(O6({buyer_key:r==null?void 0:r.key,active:!(r!=null&&r.active)})).then(y=>{y.payload.error?n({vertical:"top",horizontal:"center",msg:y.payload.error,severity:"error"}):(s(1),n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},E=()=>{d(),v(yu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"ویرایش خریدار",content:u.jsx(z6,{fetchApiData:s,isEdit:!0,item:r})}))},I=[{key:"toggle",label:r!=null&&r.active?"غیرفعال سازی":"فعالسازی",color:r!=null&&r.active?"error.main":"success.main",icon:r!=null&&r.active?u.jsx(E0,{}):u.jsx(S0,{}),action:x},{key:"edit",label:"ویرایش",color:"primary.main",icon:u.jsx(F6,{}),action:E,disabled:!(r!=null&&r.active)}],Z=!!g,B=Z?`buyer-operations-${r==null?void 0:r.key}`:void 0;return u.jsxs(o,{container:!0,alignItems:"center",justifyContent:"center",gap:.5,children:[u.jsx(Yu,{title:"تنظیمات",children:u.jsx(Nu,{"aria-describedby":B,color:"primary",onClick:C,children:u.jsx(x6,{})})}),u.jsx(A6,{id:B,open:Z,anchorEl:g,onClose:d,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},children:u.jsx(v6,{dense:!0,sx:{width:150,py:.5,px:1},children:I.map(y=>u.jsxs(p6,{onClick:()=>{y.disabled||y.action()},disabled:!!y.disabled,sx:{borderRadius:1,mb:.5,color:y.disabled?"text.disabled":y.color,"&:last-of-type":{mb:0}},children:[u.jsx(n6,{sx:{color:y.disabled?"text.disabled":y.color,minWidth:32},children:R6.cloneElement(y.icon,{fontSize:"small"})}),u.jsx(a6,{primary:u.jsx(j,{sx:{color:y.disabled?"text.disabled":y.color,fontWeight:600,fontSize:"0.85rem"},children:y.label})})]},y.key))})})]})},V0=()=>{const[r,s]=i.useState([]),[n,v]=i.useState(0),[g,c]=i.useState(10),[C,d]=i.useState(""),[x,E]=i.useState(1),[I,Z]=i.useState([]),B=fu(),[y]=i.useContext(bu),h=mu(V=>V.userSlice.userProfile.key),O=async V=>{B(U());const p=await G.get(`out-province-poultry-request-buyers/?search=filter&value=${C}&page=${V}&page_size=${g}&role=${W()}&state=buyer-list`);B(D()),s(p.data.results),v(p.data.count)},H=V=>{O(V),E(V)},_=V=>{c(V),E(1)},m=()=>{O(x!==0?x:1)},M=V=>{d(V.target.value)};i.useEffect(()=>{const V=r==null?void 0:r.map((p,K)=>{var Au,Q,cu,F,Y,e;return[x===1?K+1:K+g*(x-1)+1,p==null?void 0:p.fullname,p==null?void 0:p.mobile,p==null?void 0:p.province,p==null?void 0:p.city,(p==null?void 0:p.type)==="killhouse"?"کشتارگاه":"کشتارکن",p!=null&&p.unitName?p==null?void 0:p.unitName:"-",p!=null&&p.killHouseUniqueId?p==null?void 0:p.killHouseUniqueId:"-",(Q=(Au=p==null?void 0:p.requestsInfo)==null?void 0:Au.numberOfRequests)==null?void 0:Q.toLocaleString(),(F=(cu=p==null?void 0:p.requestsInfo)==null?void 0:cu.totalQuantity)==null?void 0:F.toLocaleString(),(e=(Y=p==null?void 0:p.requestsInfo)==null?void 0:Y.totalWeight)==null?void 0:e.toLocaleString(),p!=null&&p.active?"فعال":"غیر فعال",u.jsx(W0,{item:p,fetchApiData:O,openNotif:y},(p==null?void 0:p.key)||K)]});Z(V)},[r]),i.useEffect(()=>{O(1)},[B,g]);const z=async V=>{V.preventDefault(),B(U());try{const p=await G.get(`out-province-poultry-request-buyers/?search=filter&value=${C}&role=${W()}&state=buyer-list`);s(p.data.results),v(p.data.count),B(D())}catch(p){console.error("Error fetching data:",p)}};return u.jsxs(o,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsx(o,{container:!0,mt:$.SMALL,xs:12,children:u.jsx(R,{variant:"contained",onClick:()=>{B(yu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"افزودن خریدار",content:u.jsx(z6,{fetchApiData:m})}))},children:"افزودن خریدار"})}),u.jsxs(o,{container:!0,alignItems:"center",justifyContent:"center",gap:2,paddingTop:2,mb:1,width:"100%",children:[u.jsx(o,{container:!0,alignItems:"center",gap:$.SMALL,children:u.jsxs("form",{onSubmit:z,children:[u.jsx(f,{id:"outlined-basic",size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},onChange:M}),u.jsx(R,{type:"submit",onClick:z,endIcon:u.jsx(o6,{}),children:"جستجو"})]})}),u.jsx(Yu,{title:"خروجی اکسل",children:u.jsx("a",{href:`${G.defaults.baseURL}out_province_poultry_request_buyers_excel/?key=${h}&role=${W()}&search=filter&value=${C}`,rel:"noreferrer",children:u.jsx(R,{color:"success",children:u.jsx(u6,{size:32})})})})]}),u.jsx(Hu,{data:I,columns:["ردیف","نام کامل","موبایل","استان","شهر","ماهیت خریدار","نام واحد","شناسه یکتا","تعداد درخواست ها","حجم درخواست ها (قطعه)","وزن درخواست ها (کیلوگرم)","وضعیت","عملیات"],handlePageChange:H,totalRows:n,page:x,perPage:g,handlePerRowsChange:_,title:"خریداران"})]})},O0=ku("PROVINCE_APPROVE_FREE_SALE_SERVICE",async(r,{dispatch:s})=>{try{s(U());const{data:n,status:v}=await G.post("final-approval-out-province-poultry-request/",r);return s(D()),{data:n,status:v}}catch(n){return s(D()),{error:n.response.data.result}}});var b6={},z0=w6;Object.defineProperty(b6,"__esModule",{value:!0});var H6=b6.default=void 0,H0=z0(D6()),Y0=u;H6=b6.default=(0,H0.default)((0,Y0.jsx)("path",{d:"m10.89 18.28.57-2.89c.12-.59-.04-1.2-.42-1.66-.38-.46-.94-.73-1.54-.73H4v-1.08L6.57 6h8.09c.18 0 .34.16.34.34v7.84zM10 22l6.41-6.41c.38-.38.59-.89.59-1.42V6.34C17 5.05 15.95 4 14.66 4h-8.1c-.71 0-1.36.37-1.72.97l-2.67 6.15c-.11.25-.17.52-.17.8V13c0 1.1.9 2 2 2h5.5l-.92 4.65c-.05.22-.02.46.08.66.23.45.52.86.88 1.22zm10-7h2V4h-2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1"}),"ThumbDownOffAlt");const Y6=ku("PROVINCE_CHECK_FREE_SALE_SERVICE",async(r,{dispatch:s})=>{try{s(U());const{data:n,status:v}=await G.post("province_check_operator_out_request/",r);return s(D()),{data:n,status:v}}catch(n){return s(D()),{error:n.response.data.result}}}),U0=({item:r,fetchApiData:s})=>{const[n]=i.useContext(bu),v=fu(),g=Du({initialValues:{textFieldInput:""},validationSchema:_u({textFieldInput:X().required("این فیلد اجباری است!")})});return i.useEffect(()=>{g.validateForm()},[]),u.jsxs(o,{xs:12,container:!0,justifyContent:"center",children:[u.jsx(f,{fullWidth:!0,id:"textFieldInput",name:"textFieldInput",label:"توضیحات",multiline:!0,rows:4,value:g.values.textFieldInput,onChange:g.handleChange,onBlur:g.handleBlur,error:g.touched.textFieldInput&&!!g.errors.textFieldInput,helperText:g.touched.textFieldInput&&g.errors.textFieldInput,margin:"normal"}),u.jsx(R,{color:"error",fullWidth:!0,variant:"contained",type:"submit",disabled:!g.isValid,onClick:()=>{v(Y6({poultry_request_key:r==null?void 0:r.key,state:"rejected",message:g.values.textFieldInput})).then(c=>{c.payload.error?n({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(v(Lu()),s(1),n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ثبت"})]})},K0=ku("PROVINCE_SEND_SMS_AGAIN_SERVICE",async(r,{dispatch:s})=>{try{s(U());const{data:n,status:v}=await G.get("send_again_sms_for_final_approval_out_province/?key="+r);return s(D()),{data:n,status:v}}catch(n){return s(D()),{error:n.response.data.result}}}),G0=({item:r,fetchApiData:s})=>{const n=fu(),[v,g]=i.useState(null),c=_=>{g(_.currentTarget)},C=()=>{g(null)},d=!!v,x=d?"popover":void 0,[E]=i.useContext(bu),I=W(),Z=()=>{n(yu({title:"ویرایش درخواست",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(V6,{item:r,fetchApiData:s})}))},B=()=>{n(Vu({title:"آیا از تایید درخواست مطمئن هستید؟",content:u.jsxs(o,{children:[u.jsx(R,{variant:"contained",onClick:()=>{n(Y6({poultry_request_key:r==null?void 0:r.key})).then(_=>{_.payload.error?E({vertical:"top",horizontal:"center",msg:_.payload.error,severity:"error"}):(n(Lu()),s(1),E({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"بله"}),u.jsx(R,{onClick:()=>{n(Lu())},children:"خیر"})]})}))},y=()=>{var _,m,M;n(Vu({title:"پیامک مجددا ارسال شود؟",content:u.jsxs(o,{children:[(r==null?void 0:r.hasWage)&&u.jsxs(j,{fullWidth:!0,variant:"body2",children:["پیامک پرداخت مجددا برای ",r==null?void 0:r.payerFullname," ",""," به شماره موبایل"," ",(r==null?void 0:r.payerType)==="buyer"?(_=r==null?void 0:r.outProvincePoultryRequestBuyer)==null?void 0:_.mobile:(M=(m=r==null?void 0:r.poultry)==null?void 0:m.user)==null?void 0:M.mobile," ","ارسال میشود."]}),u.jsxs(o,{xs:12,container:!0,justifyContent:"center",mt:2,children:[u.jsx(R,{variant:"contained",onClick:()=>{n(K0(r==null?void 0:r.key)).then(z=>{z.payload.error?E({vertical:"top",horizontal:"center",msg:z.payload.error,severity:"error"}):(n(Lu()),s(1),E({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"بله"}),u.jsx(R,{onClick:()=>{n(Lu())},children:"خیر"})]})]})}))},h=()=>{n(Vu({title:"آیا از لغو درخواست مطمئن هستید؟",content:u.jsxs(o,{children:[u.jsx(R,{variant:"contained",onClick:()=>{n(W6({role:W(),poultry_request_key:r.key})).then(_=>{_.payload.error?E({vertical:"top",horizontal:"center",msg:_.payload.error,severity:"error"}):(s(1),E({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))}),n(Lu())},children:"بله"}),u.jsx(R,{onClick:()=>{n(Lu())},children:"خیر"})]})}))},O=()=>{n(Vu({title:"رد درخواست فروش خارج از استان",content:u.jsx(U0,{item:r,fetchApiData:s})}))},H=[{key:"edit",label:"ویرایش",color:"primary.main",icon:u.jsx(F6,{}),action:Z},I!=="CityOperator"&&{key:"approve",label:"تایید درخواست",color:"success.main",icon:u.jsx($0,{}),action:B,disabled:r.provinceState!=="pending"},(I==="CityOperator"||I==="ProvinceOperator"||I==="SuperAdmin"||I==="AdminX")&&{key:"resendSms",label:"ارسال مجدد پیامک",color:"info.main",icon:u.jsx(P0,{}),action:y,disabled:r.outState!=="در انتظار پرداخت"},{key:"cancel",label:"لغو",color:"error.main",icon:u.jsx(M6,{}),action:h,disabled:!r.provinceState==="pending"||!r.provinceState==="accepted"},I!=="CityOperator"&&{key:"reject",label:"رد درخواست",color:"error.main",icon:u.jsx(H6,{}),action:O,disabled:!r.provinceState==="pending"||!r.provinceState==="accepted"||r.outState==="در انتظار پرداخت"}].filter(Boolean);return u.jsxs(o,{container:!0,children:[u.jsx(Nu,{"aria-describedby":x,variant:"contained",color:"primary",onClick:c,children:u.jsx(x6,{})}),u.jsx(A6,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:x,open:d,anchorEl:v,onClose:C,children:u.jsx(v6,{dense:!0,sx:{width:176,py:.5,px:1},children:H.map(_=>u.jsxs(p6,{onClick:()=>{C(),_.action()},disabled:!!_.disabled,sx:{borderRadius:1,mb:.5,color:_.disabled?"text.disabled":_.color,"&:last-of-type":{mb:0}},children:[u.jsx(n6,{sx:{color:_.disabled?"text.disabled":_.color,minWidth:32},children:R6.cloneElement(_.icon,{fontSize:"small"})}),u.jsx(a6,{primary:u.jsx(j,{sx:{color:_.disabled?"text.disabled":_.color,fontWeight:600,fontSize:"0.85rem"},children:_.label})})]},_.key))})})]})},B6=ku("PROVINCE_FREE_SALES_TRANSACTIONS_DASH",async(r,{dispatch:s})=>{s(U());const{data:n,status:v}=await G.get("total-dashboard-poultry-requests-transactions",{params:{date1:r.selectedDate1,date2:r.selectedDate2,role:W(),filter:"search",value:r.textValue}});return s(D()),{data:n,status:v}}),Q0=()=>{var F,Y,e,lu,eu,tu,w;const[,,r,s,n,v]=i.useContext(bu),g=fu();i.useEffect(()=>{const P=Tu(new Date).format("YYYY-MM-DD");s(P),v(P)},[]);const c=P=>{H(P.target.value)},C=(P,b)=>{p(b)},[d,x]=i.useState([]),[E,I]=i.useState([]),[Z,B]=i.useState(0),[y,h]=i.useState(10),[O,H]=i.useState(""),[_,m]=i.useState(1),[M,z]=i.useState([]),[V,p]=i.useState(0),K=async P=>{let b;g(U()),b=await G.get(`poultry-requests-transactions/?search=filter&value=${O}&role=${W()}&date1=${r}&date2=${n}&page=${P}&page_size=${y}&type=${V===0?"poultry":"buyer"}`),g(D()),I(b.data.results),B(b.data.count)},Au=P=>{K(P),m(P)},Q=P=>{h(P),m(1)};i.useEffect(()=>{const P=E==null?void 0:E.map((b,nu)=>{var J,k,L,Cu,ru,du,au,hu;return[_===1?nu+1:nu+y*(_-1)+1,b==null?void 0:b.orderId,(J=b==null?void 0:b.poultryRequest)==null?void 0:J.map((q,a)=>u.jsx(j,{variant:"caption",children:q.orderCode},a)),(k=b==null?void 0:b.amount)==null?void 0:k.toLocaleString(),`${(L=b==null?void 0:b.payerInfo)==null?void 0:L.fullname} (${(Cu=b==null?void 0:b.payerInfo)==null?void 0:Cu.mobile})`,b==null?void 0:b.refId,(ru=b==null?void 0:b.unionShare)==null?void 0:ru.toLocaleString(),(du=b==null?void 0:b.companyShare)==null?void 0:du.toLocaleString(),(au=b==null?void 0:b.guildsShare)==null?void 0:au.toLocaleString(),(hu=b==null?void 0:b.otherShare)==null?void 0:hu.toLocaleString()]});z(P)},[E]),i.useEffect(()=>{K(1),g(B6({selectedDate1:r,selectedDate2:n,textValue:O})).then(P=>{x(P.payload.data)})},[g,r,n,y,V]);const cu=async P=>{P.preventDefault(),g(U());try{const b=await G.get(`poultry-requests-transactions/?role=${W()}&search=filter&value=${O}&date1=${r}&date2=${n}&page=1&page_size=${y}&type=${V===0?"poultry":"buyer"}`);I(b.data.results),B(b.data.count),g(D()),g(B6({selectedDate1:r,selectedDate2:n,textValue:O,type:V===0?"poultry":"buyer"})).then(nu=>{x(nu.payload.data)})}catch(b){console.error("Error fetching data:",b)}};return u.jsxs(o,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,mt:2,children:[u.jsxs(o,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[u.jsx(o,{children:u.jsx(Uu,{label:"از تاریخ",id:"date",renderInput:P=>u.jsx(f,{style:{width:"160px"},...P,size:"small"}),value:r,onChange:P=>{s(Tu(P).format("YYYY-MM-DD"))}})}),u.jsx(o,{children:u.jsx(Uu,{label:"تا تاریخ",id:"date",renderInput:P=>u.jsx(f,{style:{width:"160px"},...P,size:"small"}),value:n,onChange:P=>{v(Tu(P).format("YYYY-MM-DD"))}})}),u.jsx(o,{children:u.jsxs("form",{onSubmit:cu,children:[u.jsx(f,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:c}),u.jsx(R,{type:"submit",onClick:cu,endIcon:u.jsx(o6,{}),children:"جستجو"})]})}),u.jsx(o,{children:u.jsx(Yu,{title:"خروجی اکسل کلی",children:u.jsx("a",{href:`${G.defaults.baseURL}transacion_out_request_excel/?date1=${r}&date2=${n}&role=${W()}&search=filter&value=${O}&type=${V===0?"poultry":"buyer"}`,rel:"noreferrer",children:u.jsx(R,{color:"primary",children:u.jsx(u6,{size:32})})})})})]}),u.jsx(o,{container:!0,mt:2,mb:4,isDashboard:!0,children:u.jsx(Hu,{noPagination:!0,isDashboard:!0,columns:["تعداد پرداختی ها","تعداد پرداخت کننده ها","مبلغ کل پرداختی","تعداد مرغداران"," پرداختی مرغداران","تعداد خریداران"," پرداختی خریداران"],data:[[(F=d==null?void 0:d.totalNumberOfTransactions)==null?void 0:F.toLocaleString(),(Y=d==null?void 0:d.totalNumberOfPayers)==null?void 0:Y.toLocaleString(),(e=d==null?void 0:d.totalAmountOfTransactions)==null?void 0:e.toLocaleString(),(lu=d==null?void 0:d.totalNumberOfPoultries)==null?void 0:lu.toLocaleString(),(eu=d==null?void 0:d.totalAmountOfPoultries)==null?void 0:eu.toLocaleString(),(tu=d==null?void 0:d.totalNumberOfBuyers)==null?void 0:tu.toLocaleString(),(w=d==null?void 0:d.totalAmountOfBuyers)==null?void 0:w.toLocaleString()]],title:"خلاصه اطلاعات"})}),u.jsxs(L6,{value:V,onChange:C,"aria-label":"simple tabs example",children:[u.jsx(Wu,{label:"مرغدار"}),u.jsx(Wu,{label:"خریدار"})]}),V===0?u.jsx(Hu,{data:M,columns:["ردیف","شماره سفارش","کد سفارش","مبلغ تراکنش (ریال)","پرداخت کننده","کد پیگیری","سهم اتحادیه (ریال)","سهم شرکت (ریال)","سهم صنف (ریال)","سهم دیگر (ریال)"],handlePageChange:Au,totalRows:Z,page:_,perPage:y,handlePerRowsChange:Q,title:"تراکنش های مرغداران"}):u.jsx(Hu,{data:M,columns:["ردیف","شماره سفارش","کد سفارش","مبلغ تراکنش (ریال)","پرداخت کننده","کد پیگیری","سهم اتحادیه (ریال)","سهم شرکت (ریال)","سهم صنف (ریال)","سهم دیگر (ریال)"],handlePageChange:Au,totalRows:Z,page:_,perPage:y,handlePerRowsChange:Q,title:"تراکنش های خریداران"})]})},X0=ku("GET_PROVINCE_FEE_SALES_DASHBOARD",async(r,{dispatch:s})=>{s(U());const{data:n,status:v}=await G.get("out-province-poultry-requests-dashboard",{params:{date1:r.selectedDate1,date2:r.selectedDate2,search:"filter",value:r.textValue,role:W()}});return s(D()),{data:n,status:v}}),_e=()=>{var tu,w,P,b,nu,J,k,L,Cu,ru,du,au,hu;const[r,s]=i.useState([]),[n,v]=i.useState(0),[g,c]=i.useState(10),[C,d]=i.useState(""),[x,E]=i.useState(1),[I,Z]=i.useState([]),[B,y]=i.useState(0),[h,O]=i.useState([]),[H,_]=i.useState(),[m]=i.useContext(bu),M=fu(),z=mu(q=>q.userSlice.userProfile.key),V=q=>{d(q.target.value)},p=(q,a)=>{y(a),Y()},[,,K,Au,Q,cu]=i.useContext(bu),F=async q=>{M(U());const a=await G.get(`out-province-poultry-requests/?search=filter&value=${C}&page=${q}&role=${W()}&page_size=${g}&date1=${K}&date2=${Q}&state=pending`);M(D()),s(a.data.results),v(a.data.count)},Y=()=>{M(X0({selectedDate1:K,selectedDate2:Q,textValue:C})).then(q=>{O(q.payload.data)})},e=q=>{F(q),E(q)},lu=q=>{c(q),E(1)};i.useEffect(()=>{F(1),Y(),M(y6()).then(q=>{_(q.payload.data.status)})},[M,g]),i.useEffect(()=>{B===0&&F(1),Y()},[K,Q,B]),i.useEffect(()=>{const q=r==null?void 0:r.map((a,vu)=>{var Su,Eu,$u,su,pu,xu,Fu,ju,Pu,Mu,T,S,ou,Ru,Xu;return[x===1?vu+1:vu+g*(x-1)+1,u.jsx(G0,{item:a,wageType:H,fetchApiData:F},vu),u.jsx(i6,{label:a.outState,color:a.outState==="در انتظار پرداخت"?"info":a.outState==="در انتظار تایید"?"warning":a.outState==="رد شده"?"error":"success",size:"small",variant:"outlined"},vu),`${(Su=a==null?void 0:a.registrar)==null?void 0:Su.fullname}`,a.orderCode,(Eu=a.buyer)!=null&&Eu.firstName?`${($u=a.buyer)==null?void 0:$u.firstName} ${(su=a.buyer)==null?void 0:su.lastName} (${(pu=a.buyer)==null?void 0:pu.mobile}) / ${a.buyer.province} - ${a.buyer.city}`:(a==null?void 0:a.outProvincePoultryRequestBuyer.type)==="killhouse"?`کشتارگاه ${a.buyerFullname} (${a.buyerMobile}) / شناسه یکتا ${(xu=a.outProvincePoultryRequestBuyer)==null?void 0:xu.killHouseUniqueId} / ${a.buyerProvince} - ${a.buyerCity}`:`کشتارکن ${a.buyerFullname} (${a.buyerMobile}) / نام کشتارگاه ${a.killerKillHouseUnitName?a.killerKillHouseUnitName:"-"} / شناسه یکتا ${a.killerKillHouseUniqueId?a.killerKillHouseUniqueId:"-"} / استان ${a.killerKillHouseProvince?a.killerKillHouseProvince:"-"} / شهر ${a.killerKillHouseCity?a.killerKillHouseCity:"-"}`,((Fu=a==null?void 0:a.outProvincePoultryRequestBuyer)==null?void 0:Fu.type)==="killhouse"?"محل کشتارگاه":a!=null&&a.killerKillHouseUnitName?`کشتارگاه ${a==null?void 0:a.killerKillHouseUnitName} / ${a==null?void 0:a.killerKillHouseProvince} / ${a==null?void 0:a.killerKillHouseCity}`:"-",a!=null&&a.hasWage?a==null?void 0:a.payerFullname:"-",(a==null?void 0:a.interfaceNumber)||"-",a!=null&&a.paymentLink?u.jsx("a",{href:a==null?void 0:a.paymentLink,target:"_blank",rel:"noreferrer",dir:"ltr",children:(a==null?void 0:a.paymentLink.length)>25?`${a==null?void 0:a.paymentLink.slice(0,25)}...`:a==null?void 0:a.paymentLink}):"-",`${(ju=a.poultry)==null?void 0:ju.unitName} (${a.poultry.user.mobile})`,Qu(a.createDate),Qu(a.sendDate),a.hatching.age,(Pu=a.IndexWeight)==null?void 0:Pu.toLocaleString(),a.quantity.toLocaleString(),(Mu=Math.floor(a.IndexWeight*a.quantity))==null?void 0:Mu.toLocaleString(),a!=null&&a.freezing?"انجماد":"عادی",a!=null&&a.hasWage?"دارد":"ندارد",(T=a.hatching)==null?void 0:T.city,(S=a.hatching)==null?void 0:S.province,a.hatching.hatchingLeftOver?a.hatching.hatchingLeftOver.toLocaleString():a.hatching.leftOver.toLocaleString(),(ou=a.hatching.hatchingQuantity)==null?void 0:ou.toLocaleString(),((Ru=a.totalWageAmount)==null?void 0:Ru.toLocaleString())+" ریال",((Xu=a==null?void 0:a.outProvinceDriverInfo)==null?void 0:Xu.driverhealthCode)||"-"]});Z(q)},[r]);const eu=async q=>{q.preventDefault(),M(U());try{const a=await G.get(`out-province-poultry-requests/?search=filter&value=${C}&page=${x}&page_size=${g}&date1=${K}&date2=${Q}&state=pending&role=${W()}`);s(a.data.results),v(a.data.count),Y(),M(D())}catch(a){console.error("Error fetching data:",a),M(D())}};return u.jsx(o,{container:!0,justifyContent:"center",children:u.jsxs(o,{container:!0,justifyContent:"center",alignItems:"center",children:[u.jsxs(L6,{value:B,onChange:p,"aria-label":"simple tabs example",scrollButtons:"auto",variant:"scrollable",centered:!0,allowScrollButtonsMobile:!0,children:[u.jsx(Wu,{label:"درخواست های جدید"}),u.jsx(Wu,{label:"تایید شده"}),u.jsx(Wu,{label:"رد شده"}),u.jsx(Wu,{label:"خریداران"}),u.jsx(Wu,{label:"پرداختی ها"})]}),u.jsxs(o,{pt:2,px:2,children:[u.jsx(o,{container:!0,justifyContent:"center",alignItems:"center",children:u.jsx(Hu,{isDashboard:!0,noPagination:!0,columns:["تعداد فارم","تعداد فروش","حجم فروش","وزن فروش","تعداد فروش های تایید شده بدون تعرفه","حجم فروش های تایید شده بدون تعرفه","وزن فروش های تایید شده بدون تعرفه","تعداد فروش های تایید شده با تعرفه","حجم فروش های تایید شده با تعرفه","وزن فروش های تایید شده با تعرفه","تعداد کل فروش های تایید شده","حجم کل فروش های تایید شده","وزن کل فروش های تایید شده"],data:[[(tu=h==null?void 0:h.poultries)==null?void 0:tu.toLocaleString(),(w=h==null?void 0:h.totalNumberOfPoultryRequest)==null?void 0:w.toLocaleString(),(P=h==null?void 0:h.totalPoultryRequestQuantity)==null?void 0:P.toLocaleString(),(b=Math.round(h==null?void 0:h.totalPoultryRequestWeight))==null?void 0:b.toLocaleString(),(nu=h==null?void 0:h.totalNumberOfAcceptedPoultryRequestWithOutWage)==null?void 0:nu.toLocaleString(),(J=h==null?void 0:h.totalAcceptedPoultryRequestQuantityWithOutWage)==null?void 0:J.toLocaleString(),(k=Math.round(h==null?void 0:h.totalAcceptedPoultryRequestWeightWithOutWage))==null?void 0:k.toLocaleString(),(L=h==null?void 0:h.totalNumberOfAcceptedPoultryRequestWithWage)==null?void 0:L.toLocaleString(),(Cu=h==null?void 0:h.totalAcceptedPoultryRequestQuantityWithWage)==null?void 0:Cu.toLocaleString(),(ru=Math.round(h==null?void 0:h.totalAcceptedPoultryRequestWeightWithWage))==null?void 0:ru.toLocaleString(),(du=h==null?void 0:h.totalNumberOfAcceptedPoultryRequest)==null?void 0:du.toLocaleString(),(au=h==null?void 0:h.totalAcceptedPoultryRequestQuantity)==null?void 0:au.toLocaleString(),(hu=h==null?void 0:h.totalAcceptedPoultryRequestWeight)==null?void 0:hu.toLocaleString()]],title:"خلاصه اطلاعات"})}),B===0&&u.jsxs(o,{container:!0,alignItems:"start",direction:"column",gap:2,xs:12,children:[u.jsx(o,{container:!0,alignItems:"center",gap:$.SMALL,mt:$.SMALL,children:u.jsx(o,{style:{width:190},children:u.jsx(R,{className:"avicultureNewRequestBtn",variant:"contained",fullWidth:!0,onClick:()=>{M(yu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"ثبت درخواست فروش به خارج استان",size:{xs:"100%",md:"400px"},content:u.jsx(T0,{fetchApiData:F})}))},children:"فروش به خارج استان"})})}),u.jsxs(o,{container:!0,gap:2,xs:12,justifyContent:"space-between",mt:2,children:[u.jsxs(o,{container:!0,gap:2,children:[u.jsx(o,{children:u.jsx(Uu,{label:"از تاریخ",id:"date",renderInput:q=>u.jsx(f,{style:{width:"160px"},...q}),value:K,onChange:q=>{Au(Tu(q).format("YYYY-MM-DD"))}})}),u.jsx(o,{children:u.jsx(Uu,{label:"تا تاریخ",id:"date",renderInput:q=>u.jsx(f,{style:{width:"160px"},...q}),value:Q,onChange:q=>{cu(Tu(q).format("YYYY-MM-DD"))}})}),u.jsxs("form",{onSubmit:eu,children:[u.jsx(f,{id:"outlined-basic",size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},onChange:V}),u.jsx(R,{type:"submit",onClick:eu,endIcon:u.jsx(o6,{}),children:"جستجو"})]}),u.jsx(o,{children:u.jsx(Yu,{title:"خروجی اکسل کلی",children:u.jsx("a",{href:`${G.defaults.baseURL}general_free_bar_excel/?date1=${K}&date2=${Q}&role=${W()}&key=${z}&search=filter&value=${C}`,rel:"noreferrer",children:u.jsx(R,{color:"primary",children:u.jsx(u6,{size:32})})})})}),u.jsx(o,{children:u.jsx(Yu,{title:"خروجی اکسل درخواست های جدید",children:u.jsx("a",{href:`${G.defaults.baseURL}bar_free_excel/?date1=${K}&date2=${Q}&state=pending&role=${W()}&key=${z}`,rel:"noreferrer",children:u.jsx(R,{color:"success",children:u.jsx(u6,{size:32})})})})})]}),W()!=="CityOperator"&&u.jsx(o,{children:u.jsx(R,{color:"error",variant:"contained",onClick:()=>{M(O0()).then(q=>{q.payload.error?m({vertical:"top",horizontal:"center",msg:q.payload.error,severity:"error"}):(F(1),Y(),m({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"تایید یکجا"})})]}),u.jsx(o,{container:!0,gap:2,xs:12,justifyContent:"center",children:u.jsx(Hu,{data:I,columns:["ردیف","عملیات","وضعیت","ثبت کننده سفارش","کد سفارش","اطلاعات خریدار","محل کشتار","پرداخت کننده","شماره واسط","لینک پرداخت","مرغدار","تاریخ ثبت درخواست","تاریخ کشتار","سن مرغ","میانگین وزن (کیلوگرم)","تعداد","وزن کل (کیلوگرم)","نوع کشتار","تعرفه","شهر","استان","مانده در سالن","جوجه ریزی اولیه","مبلغ تراکنش (ریال)","کد بهداشتی ماشین"],handlePageChange:e,totalRows:n,page:x,perPage:g,handlePerRowsChange:lu,title:"فروش خارج از استان"})})]}),B===1&&u.jsx(q6,{state:"accepted"}),B===2&&u.jsx(q6,{state:"rejected"}),B===3&&u.jsx(V0,{}),B===4&&u.jsx(Q0,{})]})]})})};export{L0 as C,_e as P,B0 as d,D0 as p};
|