Files
Rasadyar_FrontEnd/build/assets/ProvinceFreeSales-CAKgsPJn.js
2026-01-19 16:15:09 +03:30

3 lines
85 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{i as I6,j as u,aO as u0,aP as e0,aQ as r0,aR as l0,aS as n0,aT as t0,T as j,ak as f,B as R,p as o0,ao as a0,ap as n6,aq as t6,al as l6,aa as B6,ag as Gu,ah as Ju,am as s6,av as s0,aw as i0,ax as Iu,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 ku,M as J,X as W,G as o,S as $,m as h0,L as U,fc as k6,K as _6,a1 as c6,h as D,fd as A0,N as gu,O as Vu,C as Lu,j as G,a0 as S6,fe as v0,ff as T6,du as p0,b as Bu,c2 as x0,v as Tu,W as Uu,fg as E6,p as Qu}from"./index-BHF9XhlR.js";import{r as i,b as R6}from"./react-vendor-CmFgShSM.js";import{u as ju,a as _u,f as mu}from"./redux-vendor-B7uoacJt.js";import{g as $6}from"./useRequestFile-DJLl5omk.js";import{A as F0}from"./index-rXDbFGCK.js";import{R as o6,a as u6}from"./index.esm-Bu7XMDZU.js";import{L as y0}from"./LabelField-CY9emCr4.js";import{a as g0}from"./aviculture-get-hatching-data-BR9pqiDJ.js";import{d as P6}from"./Delete-BMbGwban.js";import{d as Zu}from"./Add-B14uoYzg.js";import{N as C6}from"./NumberFormatCustom-DwWPj40N.js";import{D as b0}from"./DialogAlert-DKhMdDI2.js";import{d as j0}from"./Done-CXPGvgsL.js";import{a as f0}from"./aviculture-get-unions-DFRgtngr.js";import{C as N6}from"./CarPelak-qce8cQdA.js";import{b as d6}from"./index-CV2Xug6a.js";import{i as k0}from"./isValidIndexWeight-C_ik-uYa.js";import{R as Hu}from"./ResponsiveTable-cmj--TTX.js";import{d as x6}from"./Tune-rHyTJYQA.js";import{d as F6}from"./Edit-DE-0ja3Q.js";import{d as M6}from"./Close-Daz6UZes.js";import{V as _0}from"./VetFarmSubmitClearanceCode-BMbmSr2O.js";import{d as S0}from"./ToggleOn-9h7KsYVp.js";import{d as E0}from"./ToggleOff-BEqTZ7eR.js";import{d as $0}from"./Check-CnsFWTEq.js";import{d as P0}from"./Sms-B-2HP--h.js";var y6={},q0=I6;Object.defineProperty(y6,"__esModule",{value:!0});var w0=y6.default=void 0,I0=q0(D6()),B0=u;w0=y6.default=(0,I0.default)((0,B0.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,k,m,M;const[v,,y,,c,,]=i.useContext(bu),[C]=i.useState(!1),[d]=d0(),x=Du({initialValues:{rejectText:"",canHaching:"False"},validationSchema:ku({rejectText:J().required("این فیلد اجباری است!").typeError("لطفا دلیل خود را بیان کنید.")})}),[E,B]=i.useState(!1),X=((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,w=!x.values.canHaching&&X,g=ju(),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(t0,{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:()=>{B(!1)},children:"لغو"})}),u.jsx(o,{container:!0,xs:12,children:u.jsx(R,{fullWidth:!0,disabled:!x.values.rejectText,variant:"outlined",onClick:()=>{g(U()),g(k6({message:x.values.rejectText,key:s==null?void 0:s.key,allow_hatching:x.values.canHaching,state:"reject",role:W()})).then(z=>{n&&n(),g(_6({selectedDate1:y,selectedDate2:c})),g(c6({selectedDate1:y,selectedDate2:c})),$6(d,r,g),g(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:[(k=s==null?void 0:s.quantity)==null?void 0:k.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()," قطعه"]})]}),!!X&&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:w,variant:"outlined",color:"error",onClick:()=>{B(!0)},children:"رد اطلاعات و پیام به مرغدار"}),u.jsx(o,{xs:12,children:u.jsx(R,{fullWidth:!0,disabled:w,variant:"outlined",onClick:()=>{g(U()),g(k6({key:s==null?void 0:s.key,allow_hatching:x.values.canHaching,state:"accept",role:W()})).then(z=>{$6(d,r,g),g(D()),z.error?v({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(n&&n(),g(_6({selectedDate1:y,selectedDate2:c})),g(c6({selectedDate1:y,selectedDate2:c})),g(A0({selectedDate1:y,selectedDate2:c})),g(gu({right:!1,bottom:!1,content:null})),v({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),W()==="ProvinceOperator"&&g(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:()=>{g(Lu())},children:"تایید"})})]})})))})},children:h})})]})]})})})})})]})]})})};L0.propTypes={file:o0.PropTypes.object};const D0=_u("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}}),g6=_u("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 j6,f6;const[s]=i.useContext(bu),[n,v]=i.useState(""),[y,c]=i.useState(""),[C,d]=i.useState(""),[x,E]=i.useState(""),[B,X]=i.useState(""),[w,g]=i.useState(""),[h,O]=i.useState(""),[H,k]=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,au]=i.useState(),[I,P]=i.useState(),[b,nu]=i.useState(),[Z,_]=i.useState("poultry"),[L,Cu]=i.useState(!1),[ru,du]=i.useState([]),[tu,hu]=i.useState(!1),q=l=>{var A;_(l.target.value),l.target.value==="poultry"?iu.setFieldValue("mobile",(A=F==null?void 0:F.user)==null?void 0:A.mobile):I?iu.setFieldValue("mobile",I.mobile):iu.setFieldValue("mobile","")},[t,vu]=i.useState([]),Su=(l,A,uu,yu)=>{vu([l,A,uu,yu])},Eu=[{type:"text",id:1,value:""}],$u=[{type:"text",id:1,value:""}],[su,pu]=i.useState(Eu),[xu,Fu]=i.useState($u),[fu,Pu]=i.useState(),{weightRange:Mu}=mu(l=>l.provinceSlice),T=ju(),{avicultureChickenPrice:S}=mu(l=>l.avicultureSlice);i.useEffect(()=>{T(U()),T(S6()),T(v0()),T(g6()).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(f0()).then(l=>{var A,uu,yu,Ku;((uu=(A=l==null?void 0:l.payload)==null?void 0:A.data)==null?void 0:uu.length)>0?Ru((Ku=(yu=l==null?void 0:l.payload)==null?void 0:yu.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((yu,Ku)=>Ku!==l),uu=xu.filter((yu,Ku)=>Ku!==l);pu(A),Fu(uu)}},Q6=l=>{l.preventDefault();const A=l.target.id;pu(uu=>{const yu=uu.slice();return yu[A].value=l.target.value,yu})},qu=l=>{l.preventDefault();const A=l.target.id;Fu(uu=>{const yu=uu.slice();return yu[A].value=l.target.dataset.value,yu})};i.useEffect(()=>{S&&p(S==null?void 0:S.key)},[S]);const a=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:"",intermediaryNumber:""},validationSchema:ku({noChicken:J().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!").min(0,"تعداد وارد شده از حداقل ممکن کمتر است").max(Q,"تعداد وارد شده از کل موجودی بیشتر است"),isAccepted:x0().test("req","باید تعهد نامه را بپذیرید!",(l,A)=>A.originalValue&&A.originalValue===!0).required("این فیلد اجباری است!"),price1:Bu().typeError("لطفا عدد وارد کنید!").min(S==null?void 0:S.floorPrice,"قیمت وارد شده از کف قیمت امروز کمتر است").max(S==null?void 0:S.ceilingPrice,"قیمت وارد شده از سقف قیمت امروز بیشتر است"),price2:Bu().typeError("لطفا عدد وارد کنید!").min(S==null?void 0:S.floorPrice,"قیمت وارد شده از کف قیمت امروز کمتر است").max(S==null?void 0:S.ceilingPrice,"قیمت وارد شده از سقف قیمت امروز بیشتر است"),price3:Bu().typeError("لطفا عدد وارد کنید!").min(S==null?void 0:S.floorPrice,"قیمت وارد شده از کف قیمت امروز کمتر است").max(S==null?void 0:S.ceilingPrice,"قیمت وارد شده از سقف قیمت امروز بیشتر است"),weight:Bu().test("weight","وزن را تا دو رقم اعشار وارد کنید",(l,A)=>A.originalValue&&A.originalValue.toString().length<=4).required("این فیلد اجباری است!").typeError("لطفا وزن را وارد کنید!"),losses:Bu().required("این فیلد اجباری است!").max(w,"تلفات وارد شده از باقیمانده بیشتر است!").typeError("لطفا تعداد تلفات را وارد کنید!"),sellType:ku().test("sellType","نحوه فروش را انتخاب کنید!",(l,A)=>A.originalValue&&Object.values(A.originalValue).some(uu=>uu===!0)).required("این فیلد اجباری است!"),intermediaryNumber:J().min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد")})}),N=Du({initialValues:{driverName:"",driverMobile:"",driverCar:"",driverhealthCode:""},validationSchema:ku({driverName:J().required("این فیلد اجباری است!"),driverMobile:J().required("این فیلد اجباری است!").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),driverCar:J().required("این فیلد اجباری است!"),driverhealthCode:J().required("این فیلد اجباری است!").matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!")})}),iu=Du({initialValues:{mobile:"",weight:"",quantity:""},validationSchema:ku({mobile:J().required("شماره موبایل الزامی است").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),weight:Bu(),quantity:Bu()})}),wu=Du({initialValues:{healthCode:""},validationSchema:ku({healthCode:J().required("این فیلد اجباری است!").matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!")})}),X6=()=>{wu.values.healthCode.trim()&&(du([...ru,wu.values.healthCode]),wu.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 a6=a.values.noChicken*1e3,J6=u.jsxs(u.Fragment,{children:[u.jsxs(j,{variant:"body1",children:["اینجانب ",(j6=F==null?void 0:F.user)==null?void 0:j6.fullname," موافقت خود را نسبت به موارد ذکر شده اعلام می نمایم."]}),u.jsxs(a0,{children:[u.jsx(n6,{children:u.jsx(j0,{})}),u.jsx(t6,{primary:` بر اساس این توافق نامه در صورت لغو فروش ${a.values.noChicken} قطعه
مرغ ${a6==null?void 0:a6.toLocaleString()} ریال جریمه خواهم شد.`})]}),u.jsx(j,{})]});i.useEffect(()=>{T(U()),T(D0()).then(l=>{E(l.payload.data),T(D())})},[]),i.useEffect(()=>{let l=a.values.weight;const A=a.values.weight.toString().split(".").join("");a.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))?a.setFieldValue("weight",""):a.setFieldValue("weight",Number.parseFloat(l))},[a.values.weight]),i.useEffect(()=>{M&&T(S6()).then(l=>{Array.isArray(l.payload.data)?(s({vertical:"top",horizontal:"center",msg:"قیمت روز مرغ در سامانه ثبت نشده است.",severity:"error"}),T(gu({right:!1,bottom:!1,content:null}))):T(D())})},[M]),i.useEffect(()=>{a.validateForm(),N.validateForm()},[]),i.useEffect(()=>{B&&(T(U()),T(g0(B)).then(l=>{l.payload.data?(c(l.payload.data),T(D())):s({vertical:"top",horizontal:"center",msg:"اطلاعات جوجه ریزی یافت نشد!",severity:"error"}),T(D())}))},[B,F]),i.useEffect(()=>{cu(C==null?void 0:C.leftOver)},[a.values.losses,H,a.values.noChicken,C]),i.useEffect(()=>{g(C==null?void 0:C.quantity),O(C==null?void 0:C.losses),k(C==null?void 0:C.leftOver)},[C]);const e6=()=>(I==null?void 0:I.type)==="killer"?a.values.killer_kill_house_city&&a.values.killer_kill_house_province&&a.values.killer_kill_house_unit_name:!0,r6=()=>fu?iu.isValid:!0,m6=()=>Z==="poultry"?L?a.isValid&&r6()&&eu&&N&&t[0]&&e6():a.isValid&&r6()&&eu&&e6():L?a.isValid&&eu&&N&&t[0]&&e6()&&r6():a.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),X(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:y?y.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:w||"نامشخص",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:a.values.slaughterDate,error:a.touched.slaughterDate?!!a.errors.slaughterDate:null,onChange:l=>{a.setFieldValue("slaughterDate",Tu(l).format("YYYY-MM-DD"))},onBlur:a.handleBlur,helperText:a.touched.slaughterDate&&a.errors.slaughterDate?a.errors.slaughterDate:null})}),u.jsx(o,{container:!0,xs:12,children:u.jsx(C6,{allowLeadingZeros:!0,thousandSeparator:",",id:"noChicken",label:"تعداد مرغ برای کشتار",variant:"outlined",value:a.values.noChicken,error:a.touched.noChicken?!!a.errors.noChicken:null,onChange:a.handleChange,onBlur:a.handleBlur,helperText:a.touched.noChicken&&a.errors.noChicken?a.errors.noChicken:null})}),u.jsx(o,{container:!0,xs:12,children:u.jsx(f,{id:"weight",label:"وزن تقریبی مرغ",variant:"outlined",InputProps:{endAdornment:u.jsx(B6,{position:"end",children:"کیلوگرم"})},value:a.values.weight,error:a.touched.weight?!!a.errors.weight:null,onChange:a.handleChange,onBlur:a.handleBlur,helperText:a.touched.weight&&a.errors.weight?a.errors.weight:null})})]}),a.values.weight&&u.jsxs(j,{variant:"body2",style:{color:"green"},children:["وزن کل:"," ",parseInt(parseInt(a.values.noChicken)*parseFloat(a.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(Iu,{onClick:qu,id:A,value:"1",children:"1"}),u.jsx(Iu,{onClick:qu,id:A,value:"2",children:"2"}),u.jsx(Iu,{onClick:qu,id:A,value:"3",children:"3"}),u.jsx(Iu,{onClick:qu,id:A,value:"4",children:"4"}),u.jsx(Iu,{onClick:qu,id:A,value:"5",children:"5"}),u.jsx(Iu,{onClick:qu,id:A,value:"6",children:"6"}),u.jsx(Iu,{onClick:qu,id:A,value:"7",children:"7"}),u.jsx(Iu,{onClick:qu,id:A,value:"8",children:"8"}),u.jsx(Iu,{onClick:qu,id:A,value:"9",children:"9"}),u.jsx(Iu,{onClick:qu,id:A,value:"10",children:"10"})]}),u.jsx(c0,{children:a.touched.period1&&a.errors.period1?a.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:a.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)=>{au(A.id),P(A.item),Z==="buyer"&&iu.setFieldValue("mobile",A.mobile)},renderInput:l=>u.jsx(f,{...l,label:"انتخاب خریدار"})}),(I==null?void 0:I.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:a.values.killer_kill_house_unit_name,onChange:a.handleChange,onBlur:a.handleBlur,error:a.touched.killer_kill_house_unit_name?!!a.errors.killer_kill_house_unit_name:null,helperText:a.touched.killer_kill_house_unit_name&&a.errors.killer_kill_house_unit_name?a.errors.killer_kill_house_unit_name:null}),u.jsx(f,{id:"kill_house_unique_id",label:"شناسه یکتا کشتارگاه",variant:"outlined",sx:{width:"100%",height:"100%"},value:a.values.kill_house_unique_id,onChange:a.handleChange,onBlur:a.handleBlur,error:a.touched.kill_house_unique_id?!!a.errors.kill_house_unique_id:null,helperText:a.touched.kill_house_unique_id&&a.errors.kill_house_unique_id?a.errors.kill_house_unique_id:null}),u.jsx(f,{id:"killer_kill_house_province",label:"استان کشتارگاه",variant:"outlined",sx:{width:"100%",height:"100%"},value:a.values.killer_kill_house_province,onChange:a.handleChange,onBlur:a.handleBlur,error:a.touched.killer_kill_house_province?!!a.errors.killer_kill_house_province:null,helperText:a.touched.killer_kill_house_province&&a.errors.killer_kill_house_province?a.errors.killer_kill_house_province:null}),u.jsx(f,{id:"killer_kill_house_city",label:"شهر کشتارگاه",variant:"outlined",sx:{width:"100%",height:"100%"},value:a.values.killer_kill_house_city,onChange:a.handleChange,onBlur:a.handleBlur,error:a.touched.killer_kill_house_city?!!a.errors.killer_kill_house_city:null,helperText:a.touched.killer_kill_house_city&&a.errors.killer_kill_house_city?a.errors.killer_kill_house_city:null})]})]}),(I==null?void 0:I.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:a.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))}),tu&&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:wu.values.healthCode,onChange:wu.handleChange,onBlur:wu.handleBlur,error:wu.touched.healthCode&&!!wu.errors.healthCode,helperText:wu.touched.healthCode&&wu.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:tu?2:0,mb:2,children:u.jsx(R,{variant:"outlined",color:"primary",onClick:()=>hu(!tu),startIcon:tu?u.jsx(d6,{}):u.jsx(Zu,{}),fullWidth:!0,children:tu?"لغو":"افزودن کد بهداشتی حمل"})})]})]}),fu&&u.jsxs(u.Fragment,{children:[u.jsx(y0,{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:Z,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:["از این قسمت میتوانید تلفن"," ",Z==="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:"intermediaryNumber",label:"شماره واسطه (اختیاری)",variant:"outlined",value:a.values.intermediaryNumber,error:a.touched.intermediaryNumber?!!a.errors.intermediaryNumber:null,onChange:a.handleChange,onBlur:a.handleBlur,helperText:a.touched.intermediaryNumber&&a.errors.intermediaryNumber?a.errors.intermediaryNumber: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:(f6=ou[0])==null?void 0:f6.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:()=>{a.setFieldValue("isAccepted",!1)},children:"رد"}),u.jsx(R,{variant:"contained",color:"success",onClick:()=>{a.setFieldValue("isAccepted",!0)},children:"موافقم"})]}),btnTitle:"با تعهد نامه موافق هستم!",isAccepted:a.values.isAccepted})}),u.jsx(o,{mb:$.SMALL,children:u.jsx(R,{fullWidth:!0,disabled:!m6(),onClick:()=>{W()!=="SuperAdmin"&&W()!=="AdminX"&&!k0(Mu,C==null?void 0:C.age,a.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:a.values.noChicken,send_date:a.values.slaughterDate,chicken_breed:K,Index_weight:a.values.weight,union:a.values.isUnion,losses:a.values.losses!==""?a.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(gu({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:a.values.noChicken,send_date:a.values.slaughterDate,interface_number:a.values.intermediaryNumber?a.values.intermediaryNumber:null,chicken_breed:K,Index_weight:a.values.weight,hatching_left_over:parseInt(H),losses:a.values.losses!==""?a.values.losses:0,auction_list:[],cash:a.values.sellType.cash,credit:a.values.sellType.haveTime,kill_house_list:a.values.selectedSlaughters,killer_kill_house_unit_name:(I==null?void 0:I.type)==="killer"?a.values.killer_kill_house_unit_name:null,killer_kill_house_city:(I==null?void 0:I.type)==="killer"?a.values.killer_kill_house_city:null,killer_kill_house_province:(I==null?void 0:I.type)==="killer"?a.values.killer_kill_house_province:null,kill_house_unique_id:(I==null?void 0:I.type)==="killer"?a.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?t[0]+" "+t[1]+" "+t[2]+" "+t[3]:null,driverhealthCode:L?N.values.driverhealthCode:null},traffic_codes:ru.length>0?ru:null,out_province_poultry_request_buyer_key:eu,payer_type:Z,poultry_mobile:Z==="poultry"?iu.values.mobile:null,buyer_mobile:Z==="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(gu({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=_u("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=_u("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,au,I,P,b,nu,Z;const[n]=i.useContext(bu),[v,y]=i.useState(!!((Q=r==null?void 0:r.outProvinceDriverInfo)!=null&&Q.driverName)),c=ju(),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:""},validationSchema:ku({noChicken:J().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!"),weight:Bu().test("weight","وزن را تا دو رقم اعشار وارد کنید",(_,L)=>L.originalValue&&L.originalValue.toString().length<=4).required("این فیلد اجباری است!").typeError("لطفا وزن را وارد کنید!")})}),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:(au=r==null?void 0:r.outProvinceDriverInfo)!=null&&au.driverhealthCode?(I=r==null?void 0:r.outProvinceDriverInfo)==null?void 0:I.driverhealthCode:""},validationSchema:ku({driverName:J().required("این فیلد اجباری است!"),driverMobile:J().required("این فیلد اجباری است!"),driverCar:J().required("این فیلد اجباری است!"),driverhealthCode:J().required("این فیلد اجباری است!")})}),x=Du({initialValues:{mobile:"",weight:"",quantity:""},validationSchema:ku({mobile:J().required("شماره موبایل الزامی است").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),weight:Bu(),quantity:Bu()})}),[E,B]=i.useState([]),X=(_,L,Cu,ru)=>{B([_,L,Cu,ru])},[w,g]=i.useState([]),[h,O]=i.useState(),[H,k]=i.useState(),[m,M]=i.useState();i.useEffect(()=>{var _;O((_=r==null?void 0:r.outProvincePoultryRequestBuyer)==null?void 0:_.key),c(g6()).then(L=>{M(L.payload.data.status)}),c(T6()).then(L=>{g(L.payload.data)})},[]);const[z,V]=i.useState("poultry"),p=_=>{V(_.target.value),_.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(B6,{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:_=>_.disabled,options:w?w==null?void 0:w.map(_=>({id:_.key,label:`${_==null?void 0:_.fullname} / ${_.mobile} / استان ${_==null?void 0:_.province}/ ${_==null?void 0:_.city}`,item:_,mobile:_.mobile})):[],onChange:(_,L)=>{O(L.id),k(L.item),z==="buyer"&&x.setFieldValue("mobile",L.mobile)},renderInput:_=>u.jsx(f,{..._,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," (",(Z=r==null?void 0:r.outProvincePoultryRequestBuyer)==null?void 0:Z.mobile,")"]})]}),u.jsxs(o,{container:!0,xs:12,alignItems:"center",justifyContent:"center",gap:$.SMALL,children:[u.jsxs(Nu,{color:v?"error":"primary",onClick:()=>{y(!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:X}),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,{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),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(_=>{_.payload.error?n({vertical:"top",horizontal:"center",msg:_.payload.error,severity:"error"}):(s(1),c(gu({right:!1,bottom:!1,content:null})),n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ویرایش درخواست"})})]})})},N0=({fetchApiData:r,item:s})=>{const n=ju(),[v,y]=i.useState(null),c=h=>{y(h.currentTarget)},C=()=>{y(null)},d=!!v,x=d?"popover":void 0,[E]=i.useContext(bu),B=W(),X=()=>{C(),n(gu({title:"ویرایش درخواست",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(V6,{item:s,fetchApiData:r})}))},w=()=>{C(),n(Vu({title:"آیا از لغو درخواست مطمئن هستید؟",content:u.jsxs(o,{children:[u.jsx(R,{variant:"contained",onClick:()=>{n(W6({role:B,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:"خیر"})]})}))},g=[{key:"edit",label:"ویرایش",color:"primary.main",icon:u.jsx(F6,{}),action:X,disabled:!!(s.quarantineCode||(s==null?void 0:s.outState)==="پرداخت شده")},{key:"cancel",label:"لغو",color:"error.main",icon:u.jsx(M6,{}),action:w,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:g.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(t6,{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,y]=i.useState(0),[c,C]=i.useState(10),[d,x]=i.useState(""),[E,B]=i.useState(1),[X,w]=i.useState([]),[g,h]=i.useState([]),[,,O,H,k,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=${k}&state=${r}`);p(D()),n(Y.data.results),y(Y.data.count)},V=F=>{z(F),B(F)},p=ju();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),B(1)},Q=()=>{z(E!==0?E:1)};i.useEffect(()=>{const F=s==null?void 0:s.map((e,lu)=>{var eu,au,I,P,b,nu,Z,_,L,Cu,ru,du,tu,hu,q,t,vu,Su,Eu,$u,su,pu,xu,Fu,fu,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()} ریال`,`${(au=e==null?void 0:e.registrar)==null?void 0:au.fullname}`,e.orderCode,(I=e.buyer)!=null&&I.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}) / شناسه یکتا ${(Z=e.outProvincePoultryRequestBuyer)==null?void 0:Z.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:"-"}`,((_=e==null?void 0:e.outProvincePoultryRequestBuyer)==null?void 0:_.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})`,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(_0,{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,(tu=e.hatching)==null?void 0:tu.province,(hu=e.hatching.leftOver)==null?void 0:hu.toLocaleString(),(q=e.hatching.hatchingQuantity)==null?void 0:q.toLocaleString(),(t=e==null?void 0:e.outProvinceDriverInfo)!=null&&t.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?(fu=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:fu.driverhealthCode:"-",(Pu=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:Pu.driverhealthCode]});w(F);const Y=s==null?void 0:s.map((e,lu)=>{var eu,au,I,P,b,nu,Z,_,L,Cu,ru,du,tu,hu,q,t,vu,Su,Eu,$u,su,pu,xu,Fu,fu,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()} ریال`,(au=e.outProvinceRequestCanceller)!=null&&au.fullname?`${(I=e.outProvinceRequestCanceller)==null?void 0:I.fullname} (${(P=e.outProvinceRequestCanceller)==null?void 0:P.mobile})`:(b=e.agent)!=null&&b.fullname?`${(nu=e.agent)==null?void 0:nu.fullname} (${(Z=e.agent)==null?void 0:Z.mobile})`:"-",`${(_=e==null?void 0:e.registrar)==null?void 0:_.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}) / شناسه یکتا ${(tu=e.outProvincePoultryRequestBuyer)==null?void 0:tu.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.quarantineCode?e==null?void 0:e.quarantineCode:"-",Qu(e==null?void 0:e.createDate),Qu(e.sendDate),(t=e.IndexWeight)==null?void 0:t.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?(fu=e==null?void 0:e.outProvinceDriverInfo)==null?void 0:fu.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,k,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=${k}&state=${r}&role=${W()}`);n(Y.data.results),y(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:k,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=${k}&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"?X:g,columns:r==="accepted"?["ردیف","عملیات","وضعیت","مبلغ کل ","ثبت کننده سفارش","کد سفارش","اطلاعات خریدار","محل کشتار","پرداخت کننده","مرغدار","کد قرنطینه","تاریخ ثبت درخواست","تاریخ کشتار","سن مرغ","میانگین وزن (کیلوگرم)","تعداد","وزن کل (کیلوگرم)","نوع کشتار","تعرفه","شهر","استان","مانده در سالن","جوجه ریزی اولیه","نوع خودرو","پلاک","نام راننده","تلفن راننده","کد بهداشتی ماشین"]:["ردیف","وضعیت","مبلغ کل","رد/لغو کننده","ثبت کننده سفارش","کد سفارش","اطلاعات خریدار","محل کشتار","پرداخت کننده","مرغدار","کد قرنطینه","تاریخ ثبت درخواست","تاریخ کشتار","میانگین وزن (کیلوگرم)","سن مرغ","تعداد","وزن کل (کیلوگرم)","نوع کشتار","تعرفه","شهر","استان","مانده در سالن","جوجه ریزی اولیه","نوع خودرو","پلاک","نام راننده","تلفن راننده","کد بهداشتی ماشین"],handlePageChange:V,totalRows:v,page:E,perPage:c,handlePerRowsChange:Au,title:r==="accepted"?" تایید شده":" رد شده"})})]})},M0=_u("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=_u("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),y=ju(),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:ku({fullname:J().required("این فیلد اجباری است!").matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!"),mobile:J().required("شماره موبایل الزامی است").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),province:J().required("این فیلد اجباری است!").matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!"),city:J().required("این فیلد اجباری است!").matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!"),unitname:J().matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!"),uniqueCode:J().matches(/^[^*&^%$#@!()|.]*$/,"این فیلد نباید شامل کاراکترهای ویژه باشد!")})});i.useEffect(()=>{c.validateForm()},[]);const[C,d]=i.useState(n!=null&&n.type?n==null?void 0:n.type:"killhouse"),x=B=>{d(B.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?y(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(B=>{B.payload.error?v({vertical:"top",horizontal:"center",msg:B.payload.error,severity:"error"}):(r(1),y(gu({right:!1,bottom:!1,content:null})),v({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))}):y(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(B=>{B.payload.error?v({vertical:"top",horizontal:"center",msg:B.payload.error,severity:"error"}):(r(1),y(gu({right:!1,bottom:!1,content:null})),v({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ثبت"})]})})},W0=({item:r,fetchApiData:s,openNotif:n})=>{const v=ju(),[y,c]=i.useState(null),C=g=>{c(g.currentTarget)},d=()=>{c(null)},x=()=>{d(),v(O6({buyer_key:r==null?void 0:r.key,active:!(r!=null&&r.active)})).then(g=>{g.payload.error?n({vertical:"top",horizontal:"center",msg:g.payload.error,severity:"error"}):(s(1),n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},E=()=>{d(),v(gu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"ویرایش خریدار",content:u.jsx(z6,{fetchApiData:s,isEdit:!0,item:r})}))},B=[{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)}],X=!!y,w=X?`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":w,color:"primary",onClick:C,children:u.jsx(x6,{})})}),u.jsx(A6,{id:w,open:X,anchorEl:y,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:B.map(g=>u.jsxs(p6,{onClick:()=>{g.disabled||g.action()},disabled:!!g.disabled,sx:{borderRadius:1,mb:.5,color:g.disabled?"text.disabled":g.color,"&:last-of-type":{mb:0}},children:[u.jsx(n6,{sx:{color:g.disabled?"text.disabled":g.color,minWidth:32},children:R6.cloneElement(g.icon,{fontSize:"small"})}),u.jsx(t6,{primary:u.jsx(j,{sx:{color:g.disabled?"text.disabled":g.color,fontWeight:600,fontSize:"0.85rem"},children:g.label})})]},g.key))})})]})},V0=()=>{const[r,s]=i.useState([]),[n,v]=i.useState(0),[y,c]=i.useState(10),[C,d]=i.useState(""),[x,E]=i.useState(1),[B,X]=i.useState([]),w=ju(),[g]=i.useContext(bu),h=mu(V=>V.userSlice.userProfile.key),O=async V=>{w(U());const p=await G.get(`out-province-poultry-request-buyers/?search=filter&value=${C}&page=${V}&page_size=${y}&role=${W()}&state=buyer-list`);w(D()),s(p.data.results),v(p.data.count)},H=V=>{O(V),E(V)},k=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+y*(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:g},(p==null?void 0:p.key)||K)]});X(V)},[r]),i.useEffect(()=>{O(1)},[w,y]);const z=async V=>{V.preventDefault(),w(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),w(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:()=>{w(gu({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:B,columns:["ردیف","نام کامل","موبایل","استان","شهر","ماهیت خریدار","نام واحد","شناسه یکتا","تعداد درخواست ها","حجم درخواست ها (قطعه)","وزن درخواست ها (کیلوگرم)","وضعیت","عملیات"],handlePageChange:H,totalRows:n,page:x,perPage:y,handlePerRowsChange:k,title:"خریداران"})]})},O0=_u("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=I6;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=_u("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=ju(),y=Du({initialValues:{textFieldInput:""},validationSchema:ku({textFieldInput:J().required("این فیلد اجباری است!")})});return i.useEffect(()=>{y.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:y.values.textFieldInput,onChange:y.handleChange,onBlur:y.handleBlur,error:y.touched.textFieldInput&&!!y.errors.textFieldInput,helperText:y.touched.textFieldInput&&y.errors.textFieldInput,margin:"normal"}),u.jsx(R,{color:"error",fullWidth:!0,variant:"contained",type:"submit",disabled:!y.isValid,onClick:()=>{v(Y6({poultry_request_key:r==null?void 0:r.key,state:"rejected",message:y.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=_u("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=ju(),[v,y]=i.useState(null),c=k=>{y(k.currentTarget)},C=()=>{y(null)},d=!!v,x=d?"popover":void 0,[E]=i.useContext(bu),B=W(),X=()=>{n(gu({title:"ویرایش درخواست",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(V6,{item:r,fetchApiData:s})}))},w=()=>{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(k=>{k.payload.error?E({vertical:"top",horizontal:"center",msg:k.payload.error,severity:"error"}):(n(Lu()),s(1),E({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"بله"}),u.jsx(R,{onClick:()=>{n(Lu())},children:"خیر"})]})}))},g=()=>{var k,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"?(k=r==null?void 0:r.outProvincePoultryRequestBuyer)==null?void 0:k.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(k=>{k.payload.error?E({vertical:"top",horizontal:"center",msg:k.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:X},B!=="CityOperator"&&{key:"approve",label:"تایید درخواست",color:"success.main",icon:u.jsx($0,{}),action:w,disabled:r.provinceState!=="pending"},(B==="CityOperator"||B==="ProvinceOperator"||B==="SuperAdmin"||B==="AdminX")&&{key:"resendSms",label:"ارسال مجدد پیامک",color:"info.main",icon:u.jsx(P0,{}),action:g,disabled:r.outState!=="در انتظار پرداخت"},{key:"cancel",label:"لغو",color:"error.main",icon:u.jsx(M6,{}),action:h,disabled:!r.provinceState==="pending"||!r.provinceState==="accepted"},B!=="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(k=>u.jsxs(p6,{onClick:()=>{C(),k.action()},disabled:!!k.disabled,sx:{borderRadius:1,mb:.5,color:k.disabled?"text.disabled":k.color,"&:last-of-type":{mb:0}},children:[u.jsx(n6,{sx:{color:k.disabled?"text.disabled":k.color,minWidth:32},children:R6.cloneElement(k.icon,{fontSize:"small"})}),u.jsx(t6,{primary:u.jsx(j,{sx:{color:k.disabled?"text.disabled":k.color,fontWeight:600,fontSize:"0.85rem"},children:k.label})})]},k.key))})})]})},w6=_u("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,au,I;const[,,r,s,n,v]=i.useContext(bu),y=ju();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,B]=i.useState([]),[X,w]=i.useState(0),[g,h]=i.useState(10),[O,H]=i.useState(""),[k,m]=i.useState(1),[M,z]=i.useState([]),[V,p]=i.useState(0),K=async P=>{let b;y(U()),b=await G.get(`poultry-requests-transactions/?search=filter&value=${O}&role=${W()}&date1=${r}&date2=${n}&page=${P}&page_size=${g}&type=${V===0?"poultry":"buyer"}`),y(D()),B(b.data.results),w(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 Z,_,L,Cu,ru,du,tu,hu;return[k===1?nu+1:nu+g*(k-1)+1,b==null?void 0:b.orderId,(Z=b==null?void 0:b.poultryRequest)==null?void 0:Z.map((q,t)=>u.jsx(j,{variant:"caption",children:q.orderCode},t)),(_=b==null?void 0:b.amount)==null?void 0:_.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(),(tu=b==null?void 0:b.guildsShare)==null?void 0:tu.toLocaleString(),(hu=b==null?void 0:b.otherShare)==null?void 0:hu.toLocaleString()]});z(P)},[E]),i.useEffect(()=>{K(1),y(w6({selectedDate1:r,selectedDate2:n,textValue:O})).then(P=>{x(P.payload.data)})},[y,r,n,g,V]);const cu=async P=>{P.preventDefault(),y(U());try{const b=await G.get(`poultry-requests-transactions/?role=${W()}&search=filter&value=${O}&date1=${r}&date2=${n}&page=1&page_size=${g}&type=${V===0?"poultry":"buyer"}`);B(b.data.results),w(b.data.count),y(D()),y(w6({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(),(au=d==null?void 0:d.totalNumberOfBuyers)==null?void 0:au.toLocaleString(),(I=d==null?void 0:d.totalAmountOfBuyers)==null?void 0:I.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:X,page:k,perPage:g,handlePerRowsChange:Q,title:"تراکنش های مرغداران"}):u.jsx(Hu,{data:M,columns:["ردیف","شماره سفارش","کد سفارش","مبلغ تراکنش (ریال)","پرداخت کننده","کد پیگیری","سهم اتحادیه (ریال)","سهم شرکت (ریال)","سهم صنف (ریال)","سهم دیگر (ریال)"],handlePageChange:Au,totalRows:X,page:k,perPage:g,handlePerRowsChange:Q,title:"تراکنش های خریداران"})]})},X0=_u("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}}),ke=()=>{var au,I,P,b,nu,Z,_,L,Cu,ru,du,tu,hu;const[r,s]=i.useState([]),[n,v]=i.useState(0),[y,c]=i.useState(10),[C,d]=i.useState(""),[x,E]=i.useState(1),[B,X]=i.useState([]),[w,g]=i.useState(0),[h,O]=i.useState([]),[H,k]=i.useState(),[m]=i.useContext(bu),M=ju(),z=mu(q=>q.userSlice.userProfile.key),V=q=>{d(q.target.value)},p=(q,t)=>{g(t),Y()},[,,K,Au,Q,cu]=i.useContext(bu),F=async q=>{M(U());const t=await G.get(`out-province-poultry-requests/?search=filter&value=${C}&page=${q}&role=${W()}&page_size=${y}&date1=${K}&date2=${Q}&state=pending`);M(D()),s(t.data.results),v(t.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(g6()).then(q=>{k(q.payload.data.status)})},[M,y]),i.useEffect(()=>{w===0&&F(1),Y()},[K,Q,w]),i.useEffect(()=>{const q=r==null?void 0:r.map((t,vu)=>{var Su,Eu,$u,su,pu,xu,Fu,fu,Pu,Mu,T,S,ou,Ru,Xu;return[x===1?vu+1:vu+y*(x-1)+1,u.jsx(G0,{item:t,wageType:H,fetchApiData:F},vu),u.jsx(i6,{label:t.outState,color:t.outState==="در انتظار پرداخت"?"info":t.outState==="در انتظار تایید"?"warning":t.outState==="رد شده"?"error":"success",size:"small",variant:"outlined"},vu),`${(Su=t==null?void 0:t.registrar)==null?void 0:Su.fullname}`,t.orderCode,(Eu=t.buyer)!=null&&Eu.firstName?`${($u=t.buyer)==null?void 0:$u.firstName} ${(su=t.buyer)==null?void 0:su.lastName} (${(pu=t.buyer)==null?void 0:pu.mobile}) / ${t.buyer.province} - ${t.buyer.city}`:(t==null?void 0:t.outProvincePoultryRequestBuyer.type)==="killhouse"?`کشتارگاه ${t.buyerFullname} (${t.buyerMobile}) / شناسه یکتا ${(xu=t.outProvincePoultryRequestBuyer)==null?void 0:xu.killHouseUniqueId} / ${t.buyerProvince} - ${t.buyerCity}`:`کشتارکن ${t.buyerFullname} (${t.buyerMobile}) / نام کشتارگاه ${t.killerKillHouseUnitName?t.killerKillHouseUnitName:"-"} / شناسه یکتا ${t.killerKillHouseUniqueId?t.killerKillHouseUniqueId:"-"} / استان ${t.killerKillHouseProvince?t.killerKillHouseProvince:"-"} / شهر ${t.killerKillHouseCity?t.killerKillHouseCity:"-"}`,((Fu=t==null?void 0:t.outProvincePoultryRequestBuyer)==null?void 0:Fu.type)==="killhouse"?"محل کشتارگاه":t!=null&&t.killerKillHouseUnitName?`کشتارگاه ${t==null?void 0:t.killerKillHouseUnitName} / ${t==null?void 0:t.killerKillHouseProvince} / ${t==null?void 0:t.killerKillHouseCity}`:"-",t!=null&&t.hasWage?t==null?void 0:t.payerFullname:"-",t!=null&&t.paymentLink?u.jsx("a",{href:t==null?void 0:t.paymentLink,target:"_blank",rel:"noreferrer",dir:"ltr",children:(t==null?void 0:t.paymentLink.length)>25?`${t==null?void 0:t.paymentLink.slice(0,25)}...`:t==null?void 0:t.paymentLink}):"-",`${(fu=t.poultry)==null?void 0:fu.unitName} (${t.poultry.user.mobile})`,Qu(t.createDate),Qu(t.sendDate),t.hatching.age,(Pu=t.IndexWeight)==null?void 0:Pu.toLocaleString(),t.quantity.toLocaleString(),(Mu=Math.floor(t.IndexWeight*t.quantity))==null?void 0:Mu.toLocaleString(),t!=null&&t.freezing?"انجماد":"عادی",t!=null&&t.hasWage?"دارد":"ندارد",(T=t.hatching)==null?void 0:T.city,(S=t.hatching)==null?void 0:S.province,t.hatching.hatchingLeftOver?t.hatching.hatchingLeftOver.toLocaleString():t.hatching.leftOver.toLocaleString(),(ou=t.hatching.hatchingQuantity)==null?void 0:ou.toLocaleString(),((Ru=t.totalWageAmount)==null?void 0:Ru.toLocaleString())+" ریال",((Xu=t==null?void 0:t.outProvinceDriverInfo)==null?void 0:Xu.driverhealthCode)||"-"]});X(q)},[r]);const eu=async q=>{q.preventDefault(),M(U());try{const t=await G.get(`out-province-poultry-requests/?search=filter&value=${C}&page=${x}&page_size=${y}&date1=${K}&date2=${Q}&state=pending&role=${W()}`);s(t.data.results),v(t.data.count),Y(),M(D())}catch(t){console.error("Error fetching data:",t),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:w,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:[[(au=h==null?void 0:h.poultries)==null?void 0:au.toLocaleString(),(I=h==null?void 0:h.totalNumberOfPoultryRequest)==null?void 0:I.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(),(Z=h==null?void 0:h.totalAcceptedPoultryRequestQuantityWithOutWage)==null?void 0:Z.toLocaleString(),(_=Math.round(h==null?void 0:h.totalAcceptedPoultryRequestWeightWithOutWage))==null?void 0:_.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(),(tu=h==null?void 0:h.totalAcceptedPoultryRequestQuantity)==null?void 0:tu.toLocaleString(),(hu=h==null?void 0:h.totalAcceptedPoultryRequestWeight)==null?void 0:hu.toLocaleString()]],title:"خلاصه اطلاعات"})}),w===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(gu({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:B,columns:["ردیف","عملیات","وضعیت","ثبت کننده سفارش","کد سفارش","اطلاعات خریدار","محل کشتار","پرداخت کننده","لینک پرداخت","مرغدار","تاریخ ثبت درخواست","تاریخ کشتار","سن مرغ","میانگین وزن (کیلوگرم)","تعداد","وزن کل (کیلوگرم)","نوع کشتار","تعرفه","شهر","استان","مانده در سالن","جوجه ریزی اولیه","مبلغ تراکنش (ریال)","کد بهداشتی ماشین"],handlePageChange:e,totalRows:n,page:x,perPage:y,handlePerRowsChange:lu,title:"فروش خارج از استان"})})]}),w===1&&u.jsx(q6,{state:"accepted"}),w===2&&u.jsx(q6,{state:"rejected"}),w===3&&u.jsx(V0,{}),w===4&&u.jsx(Q0,{})]})]})})};export{L0 as C,ke as P,w0 as d,D0 as p};