Files
Rasadyar_FrontEnd/build/assets/vet-farm-get-out-province-dashboard-BLT-TxVO.js

2 lines
23 KiB
JavaScript

import{j as e,ak as eu,al as P,am as O,ao as f,an as i,aj as Au,bk as Fu,T as _,B as w,ac as T,i as ju,I as Bu,b3 as Su,aq as wu,ar as G,b7 as $,as as Y,a5 as Tu}from"./mui-vendor-D_SVL-Dx.js";import{r as h}from"./react-vendor-CmFgShSM.js";import{a as L,u as M,f as K}from"./redux-vendor-CfkcHgWN.js";import{gr as Eu,L as D,j as m,h as j,A as U,u as R,v as ru,W as nu,c as V,G as v,S,V as C,g2 as Iu,gs as Wu,b as x,C as H,g4 as su,O as ou,r as qu}from"./index-D80MdVQn.js";import{I as Nu,f as fu}from"./toBase64-UDzdrM-n.js";import{a as au,s as Du}from"./slaughter-get-provinces-D6etA0Tf.js";import{C as Vu}from"./CarPelak-BUqZflo3.js";import{c as lu}from"./checkPathStartsWith-DedybDvj.js";import{d as Pu}from"./Tune-BBzxV8DK.js";import{d as Ou}from"./EditOutlined-CdYoJAhn.js";import{d as Ru}from"./DeleteOutlineOutlined-BmausW-i.js";function Lu(u){return new Mu(u)}class Mu{constructor(a){this.type="lazy",this.__isYupSchema__=!0,this.__inputType=void 0,this.__outputType=void 0,this._resolve=(r,n={})=>{let t=this.builder(r,n);if(!Eu(t))throw new TypeError("lazy() functions must return a valid schema");return t.resolve(n)},this.builder=a}resolve(a){return this._resolve(a.value,a)}cast(a,r){return this._resolve(a,r).cast(a,r)}validate(a,r,n){return this._resolve(a,r).validate(a,r,n)}validateSync(a,r){return this._resolve(a,r).validateSync(a,r)}validateAt(a,r,n){return this._resolve(r,n).validateAt(a,r,n)}validateSyncAt(a,r,n){return this._resolve(r,n).validateSyncAt(a,r,n)}describe(){return null}isValid(a,r){return this._resolve(a,r).isValid(a,r)}isValidSync(a,r){return this._resolve(a,r).isValidSync(a,r)}}const mu=L("SLAUGHTER_DELETE_INVENTORY_FREE_BAR_SERVICE",async(u,{dispatch:a})=>{a(D());try{const{data:r,status:n}=await m.delete("kill_house_free_bar/0/?key="+u);return a(j()),{data:r,status:n}}catch(r){return a(j()),{error:r.response.data.result}}}),J=L("SLAUGHTER_EDIT_FREE_SALE_SERVICE",async(u,{dispatch:a})=>{a(D());try{const{data:r,status:n}=await m.put("kill_house_free_bar/0/",u);return a(j()),{data:r,status:n}}catch(r){return a(j()),{error:r.response.data.result}}}),zu=L("SLAUGHTER_SUBMIT_FREE_SALE_SERVICE",async(u,{dispatch:a})=>{a(D());try{const{data:r,status:n}=await m.post("kill_house_free_bar/",u);return a(j()),{data:r,status:n}}catch(r){return a(j()),{error:r.response.data.result}}}),Gu=V().shape({poultry_name:C().required("نام مرغدار الزامی است"),poultry_mobile:C().required("شماره موبایل مرغدار الزامی است").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),province:C().required("استان الزامی است"),city:C().required("شهر الزامی است"),clearance_code:C().required("کد قرنطینه الزامی است"),quantity:x().required("تعداد الزامی است").min(1,"تعداد باید بیشتر از 0 باشد"),live_weight:x().required("وزن الزامی است").min(.01,"وزن باید بیشتر از 0 باشد"),bar_image:C().required("عکس بار الزامی است")}),$u=V().shape({poultry_name:C().required("نام مرغدار الزامی است"),poultry_mobile:C().required("شماره موبایل مرغدار الزامی است").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),province:C().required("استان الزامی است"),city:C().required("شهر الزامی است"),clearance_code:C().required("کد قرنطینه الزامی است"),bar_image:C().required("عکس بار الزامی است"),number_of_carcasses:x().required("حجم لاشه الزامی است").min(1,"حجم لاشه باید بیشتر از 0 باشد"),weight_of_carcasses:x().required("وزن لاشه الزامی است").min(.01,"وزن باید بیشتر از 0 باشد")}),Yu=V().shape({driverName:C(),driverMobile:C().min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد")}),cu=({formik:u,cities:a,provinces:r,isEdit:n})=>e.jsxs(e.Fragment,{children:[e.jsx(f,{fullWidth:!0,disablePortal:!0,id:"province",options:r.map(t=>({id:t.name,label:t.name})),value:u.values.province?{id:u.values.province,label:u.values.province}:null,onChange:(t,o)=>{u.setFieldValue("province",o?o.id:""),u.setFieldValue("city","")},renderInput:t=>e.jsx(i,{...t,label:"استان را انتخاب کنید",error:u.touched.province&&!!u.errors.province,helperText:u.touched.province&&u.errors.province})}),n&&e.jsxs(_,{variant:"caption",color:"error",children:["استان: ",u.values.province]}),e.jsx(f,{fullWidth:!0,disablePortal:!0,id:"city",disabled:!u.values.province,options:a.map(t=>({id:t.name,label:t.name})),value:u.values.city?{id:u.values.city,label:u.values.city}:null,onChange:(t,o)=>{u.setFieldValue("city",o?o.id:"")},renderInput:t=>e.jsx(i,{...t,label:"شهر را انتخاب کنید",error:u.touched.city&&!!u.errors.city,helperText:u.touched.city&&u.errors.city})}),n&&e.jsxs(_,{variant:"caption",color:"error",children:["شهر: ",u.values.city]})]}),Hu=({formik:u,cities:a,provinces:r,isEdit:n,item:t})=>e.jsxs(e.Fragment,{children:[e.jsx(i,{id:"poultry_name",name:"poultry_name",label:"نام مرغدار",value:u.values.poultry_name,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.poultry_name&&!!u.errors.poultry_name,helperText:u.touched.poultry_name&&u.errors.poultry_name}),e.jsx(i,{id:"poultry_mobile",name:"poultry_mobile",label:"تلفن مرغداری",value:u.values.poultry_mobile,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.poultry_mobile&&!!u.errors.poultry_mobile,helperText:u.touched.poultry_mobile&&u.errors.poultry_mobile}),e.jsx(cu,{formik:u,cities:a,provinces:r,isEdit:n,item:t}),e.jsx(i,{id:"clearance_code",name:"clearance_code",label:"کد قرنطینه",disabled:n&&(t==null?void 0:t.registerType)==="automatic",value:u.values.clearance_code,onChange:o=>u.setFieldValue("clearance_code",o.target.value.toUpperCase()),onBlur:u.handleBlur,error:u.touched.clearance_code&&!!u.errors.clearance_code,helperText:u.touched.clearance_code&&u.errors.clearance_code}),e.jsx(i,{id:"quantity",name:"quantity",label:"حجم زنده",InputProps:{endAdornment:e.jsx(T,{position:"end",children:"قطعه"})},value:u.values.quantity,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.quantity&&!!u.errors.quantity,helperText:u.touched.quantity&&u.errors.quantity}),e.jsx(i,{id:"live_weight",name:"live_weight",label:"وزن بار زنده",InputProps:{endAdornment:e.jsx(T,{position:"end",children:"کیلوگرم"})},value:u.values.live_weight,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.live_weight&&!!u.errors.live_weight,helperText:u.touched.live_weight&&u.errors.live_weight})]}),Ku=({formik:u,cities:a,provinces:r,isEdit:n,item:t})=>e.jsxs(e.Fragment,{children:[e.jsx(i,{id:"poultry_name",name:"poultry_name",label:"نام فروشنده",value:u.values.poultry_name,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.poultry_name&&!!u.errors.poultry_name,helperText:u.touched.poultry_name&&u.errors.poultry_name}),e.jsx(i,{id:"poultry_mobile",name:"poultry_mobile",label:"تلفن فروشنده",value:u.values.poultry_mobile,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.poultry_mobile&&!!u.errors.poultry_mobile,helperText:u.touched.poultry_mobile&&u.errors.poultry_mobile}),e.jsx(cu,{formik:u,cities:a,provinces:r,isEdit:n,item:t}),e.jsx(i,{id:"clearance_code",name:"clearance_code",label:"کد قرنطینه",value:u.values.clearance_code,onChange:o=>u.setFieldValue("clearance_code",o.target.value.toUpperCase()),onBlur:u.handleBlur,error:u.touched.clearance_code&&!!u.errors.clearance_code,helperText:u.touched.clearance_code&&u.errors.clearance_code}),e.jsx(i,{id:"weight_of_carcasses",name:"weight_of_carcasses",label:"وزن لاشه",InputProps:{endAdornment:e.jsx(T,{position:"end",children:"کیلوگرم"})},value:u.values.weight_of_carcasses,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.weight_of_carcasses&&!!u.errors.weight_of_carcasses,helperText:u.touched.weight_of_carcasses&&u.errors.weight_of_carcasses}),e.jsx(i,{id:"number_of_carcasses",name:"number_of_carcasses",label:"حجم تقریبی لاشه",InputProps:{endAdornment:e.jsx(T,{position:"end",children:"قطعه"})},value:u.values.number_of_carcasses,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.number_of_carcasses&&!!u.errors.number_of_carcasses,helperText:u.touched.number_of_carcasses&&u.errors.number_of_carcasses})]}),Uu=({formikDriver:u,setDriverPelak:a})=>e.jsxs(e.Fragment,{children:[e.jsx(Vu,{width:"100%",handleChange:(r,n,t,o)=>{a([r,n,t,o])}}),e.jsx(i,{label:"نام و نام خانوادگی راننده",name:"driverName",value:u.values.driverName,onChange:u.handleChange,error:u.touched.driverName&&!!u.errors.driverName,helperText:u.touched.driverName&&u.errors.driverName,fullWidth:!0}),e.jsx(i,{label:"تلفن راننده",name:"driverMobile",value:u.values.driverMobile,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.driverMobile&&!!u.errors.driverMobile,helperText:u.touched.driverMobile&&u.errors.driverMobile,fullWidth:!0})]}),Ju=({item:u,updateTable:a})=>{const r=M(),[n]=h.useContext(U),[t,o]=h.useState(u?(u==null?void 0:u.buyType)==="live"?"alive":"carcasses":"alive"),[y,s]=h.useState("today"),[A,g]=h.useState(null),[p,E]=h.useState(null),[I,W]=h.useState([]),[q,N]=h.useState([]),[X,du]=h.useState([]),[Z,k]=h.useState([]),[hu,Cu]=h.useState([]),[uu,pu]=h.useState([]),b=K(l=>l.userSlice.selectedSubUser),c=R({initialValues:{buyType:u?(u==null?void 0:u.buyType)==="live"?"alive":"carcasses":"alive",poultry_name:u?u.poultryName:"",poultry_mobile:u?u.poultryMobile:"",province:u?u.province:"",city:u?u.city:"",clearance_code:u?u.barClearanceCode:"",quantity:u?u.quantity:"",live_weight:u?u.liveWeight:"",bar_image:u?" ":"",number_of_carcasses:u?u.numberOfCarcasses:"",weight_of_carcasses:u?u.weightOfCarcasses:""},validationSchema:Lu(l=>l.buyType==="alive"?Gu:$u),onSubmit:async l=>{try{const d={driver_name:z.values.driverName,driver_mobile:z.values.driverMobile,poultry_name:l.poultry_name,poultry_mobile:l.poultry_mobile,province:l.province,city:l.city,...l.clearance_code!==(u==null?void 0:u.barClearanceCode)&&{bar_clearance_code:l.clearance_code},bar_image:l.bar_image,killer_key:p||null,date:y==="today"?ru(new Date).format("YYYY-MM-DD"):ru(new Date).add(1,"days").format("YYYY-MM-DD"),buy_type:l.buyType==="alive"?"live":"carcass",product_key:A==null?void 0:A.key,role_key:lu("slaughter")&&(b==null?void 0:b.key)||"",car:uu.join(" "),...l.buyType==="alive"?{quantity:Number(l.quantity),live_weight:Number(l.live_weight)}:{number_of_carcasses:l.number_of_carcasses,weight_of_carcasses:l.weight_of_carcasses}},B=u?await r(J({...d,key:u.key})):await r(zu(d));B.payload.error?n({vertical:"top",horizontal:"center",msg:B.payload.error,severity:"error"}):(a&&a(),r(nu({right:!1,bottom:!1,content:null})),n({vertical:"top",horizontal:"center",msg:u?"اطلاعات با موفقیت ویرایش شد":"اطلاعات خرید شما با موفقیت ثبت شد",severity:"success"}))}catch{n({vertical:"top",horizontal:"center",msg:"خطا در ارسال اطلاعات",severity:"error"})}},validateOnMount:!0}),z=R({initialValues:{driverName:(u==null?void 0:u.driverName)||"",driverMobile:(u==null?void 0:u.driverMobile)||""},validationSchema:Yu}),yu=l=>{o(l.target.value),c.setFieldValue("buyType",l.target.value)},vu=l=>{s(l.target.value)},_u=l=>{var d;l[0]&&c.setFieldValue("bar_image",fu((d=l[0])==null?void 0:d.data_url)),Cu(l)};return h.useEffect(()=>{(async()=>{var d;try{const[B,gu,bu]=await Promise.all([r(Iu({role_key:lu("slaughter")&&(b==null?void 0:b.key)||""})),r(Wu()),r(Du())]),F=(d=B.payload)==null?void 0:d.data;if(Array.isArray(F)?W(F):F!=null&&F.data&&Array.isArray(F.data)?W(F.data):W([]),N(gu.payload.data||[]),du(bu.payload.data||[]),u!=null&&u.province){const xu=await r(au(u.province));k(xu.payload.data||[])}}catch(B){console.error(B)}})()},[r,b==null?void 0:b.key]),h.useEffect(()=>{c.values.province&&r(au(c.values.province)).then(l=>{k(l.payload.data||[])})},[c.values.province,r]),e.jsx(v,{container:!0,direction:"column",justifyContent:"center",gap:2,children:(u==null?void 0:u.registerType)!=="automatic"?e.jsxs(v,{container:!0,direction:"column",justifyContent:"center",gap:2,children:[e.jsxs(eu,{value:t,onChange:yu,row:!0,"aria-labelledby":"buy-type-radio-group",name:"buy-type-radio-group",children:[e.jsx(P,{disabled:!!u,value:"alive",control:e.jsx(O,{}),label:"مرغ زنده"}),e.jsx(P,{disabled:!!u,value:"carcasses",control:e.jsx(O,{}),label:"لاشه"})]}),!u&&e.jsx(v,{xs:12,container:!0,gap:2,children:e.jsx(f,{fullWidth:!0,style:{minWidth:210},disablePortal:!0,id:"product-select",options:Array.isArray(I)&&I.length>0?I.map(l=>({data:l,label:l.name||""})):[],onChange:(l,d)=>g((d==null?void 0:d.data)||null),renderInput:l=>e.jsx(i,{fullWidth:!0,...l,label:"انتخاب محصول"})})}),!!q.length&&e.jsx(f,{fullWidth:!0,style:{minWidth:210},disablePortal:!0,id:"killer-select",options:q.map(l=>({data:l.key,label:`${l.name} (${l==null?void 0:l.phone})`})),onChange:(l,d)=>E(d==null?void 0:d.data),renderInput:l=>e.jsx(i,{fullWidth:!0,...l,label:"انتخاب کشتارکن (اختیاری)"})}),e.jsxs("form",{onSubmit:c.handleSubmit,style:{display:"flex",flexDirection:"column",gap:S.LARGE},children:[t==="alive"?e.jsx(Hu,{formik:c,cities:Z,provinces:X,isEdit:!!u,item:u}):e.jsx(Ku,{formik:c,cities:Z,provinces:X,isEdit:!!u,item:u}),e.jsx(Uu,{formikDriver:z,driverPelak:uu,setDriverPelak:pu}),t==="alive"&&e.jsxs(Au,{children:[e.jsx(Fu,{id:"inventory-date-radio-group",children:"تاریخ ورود به انبار"}),e.jsxs(eu,{value:y,onChange:vu,row:!0,"aria-labelledby":"inventory-date-radio-group",name:"inventory-date-radio-group",children:[e.jsx(P,{value:"today",control:e.jsx(O,{}),label:"امروز"}),e.jsx(P,{value:"tomorrow",control:e.jsx(O,{}),label:"فردا"})]})]}),e.jsx(Nu,{onChange:_u,images:hu,maxNumber:1,title:"تصویر بار"}),c.touched.bar_image&&!!c.errors.bar_image&&e.jsx(_,{color:"error",children:"ثبت تصویر بار الزامی است"}),e.jsx(w,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",disabled:!c.isValid,children:"ثبت"})]})]}):e.jsxs(v,{container:!0,direction:"column",justifyContent:"center",gap:2,children:[e.jsx(f,{fullWidth:!0,style:{minWidth:210},disablePortal:!0,id:"killer-select-automatic",options:q.map(l=>({data:l.key,label:`${l.name} (${l==null?void 0:l.phone})`})),onChange:(l,d)=>E(d==null?void 0:d.data),renderInput:l=>e.jsx(i,{fullWidth:!0,...l,label:"انتخاب کشتارکن (اختیاری)"})}),e.jsx(i,{id:"quantity",name:"quantity",disabled:(u==null?void 0:u.registerType)==="automatic",label:"حجم زنده",InputProps:{endAdornment:e.jsx(T,{position:"end",children:"قطعه"})},value:c.values.quantity,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.quantity&&!!c.errors.quantity,helperText:c.touched.quantity&&c.errors.quantity}),e.jsx(i,{id:"live_weight",name:"live_weight",disabled:(u==null?void 0:u.registerType)==="automatic",label:"وزن بار زنده",InputProps:{endAdornment:e.jsx(T,{position:"end",children:"کیلوگرم"})},value:c.values.live_weight,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.live_weight&&!!c.errors.live_weight,helperText:c.touched.live_weight&&c.errors.live_weight}),e.jsx(w,{onClick:c.handleSubmit,type:"button",fullWidth:!0,variant:"contained",color:"primary",disabled:!c.isValid,children:"ثبت"})]})})},Qu=({item:u,updateTable:a})=>{var g;const[r,n]=h.useState("0"),[t]=h.useContext(U),o=M(),y=K(p=>p.userSlice.selectedSubUser),s=R({initialValues:{realNumber:u.numberOfCarcasses?u.numberOfCarcasses:"",realWeight:u.weightOfCarcasses?u.weightOfCarcasses:""},validationSchema:V({realNumber:x().typeError("لطفا فیلد را به درستی وارد کنید.!").required("این فیلد اجباری است!"),realWeight:x().typeError("لطفا فیلد را به درستی وارد کنید.!").required("این فیلد اجباری است!")})});h.useEffect(()=>{const p=(u==null?void 0:u.liveWeight)-s.values.realWeight;p<(u==null?void 0:u.liveWeight)?n((p/(u==null?void 0:u.liveWeight)*100).toPrecision(4)):n(0),s.setFieldValue("realNumber",Math.round(s.values.realWeight/1.5))},[s.values.realWeight]);const A=()=>{o(ou({title:"عملیات با موفقیت انجام شد",content:e.jsx(e.Fragment,{children:e.jsxs(v,{container:!0,gap:S.SMALL,justifyContent:"center",children:[e.jsx(_,{variant:"body2",color:"secondary",children:"جهت ویرایش میتوانید حداکثر تا پایان امروز یا قبل از اولین تخصیص اقدام کنید."}),e.jsx(w,{variant:"outlined",onClick:()=>{o(H())},children:"متوجه شدم"})]})})}))};return h.useEffect(()=>{s.validateForm()},[]),e.jsx(e.Fragment,{children:e.jsxs(v,{xs:12,container:!0,spacing:S.SMALL,alignItems:"center",justifyContent:"center",children:[e.jsxs(v,{container:!0,xs:12,gap:S.TINY,children:[e.jsx(v,{container:!0,xs:12,gap:S.SMALL,justifyContent:"center",children:e.jsxs(_,{color:"primary",variant:"body2",children:["وزن بار زنده: ",(g=u==null?void 0:u.liveWeight)==null?void 0:g.toLocaleString()," کیلوگرم"]})}),e.jsx(i,{fullWidth:!0,id:"realWeight",size:"small",label:"وزن لاشه",variant:"outlined",value:s.values.realWeight,error:s.touched.realWeight?!!s.errors.realWeight:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.realWeight&&s.errors.realWeight?s.errors.realWeight:null}),e.jsx(i,{fullWidth:!0,id:"realNumber",size:"small",label:"حجم لاشه",variant:"outlined",value:s.values.realNumber,error:s.touched.realNumber?!!s.errors.realNumber:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.realNumber&&s.errors.realNumber?s.errors.realNumber:null})]}),e.jsxs(v,{container:!0,xs:12,gap:4,alignItems:"center",mt:2,justifyContent:"space-between",children:[e.jsxs(v,{children:[e.jsxs(_,{variant:"body1",color:"primary",children:["افت: ",r>0?r:0,"%"]}),(r>30||r<20)&&e.jsx(_,{variant:"body2",color:"error",children:"درصد افت باید بین 20 تا 30 درصد باشد!"})]}),e.jsx(v,{children:e.jsx(w,{disabled:!s.isValid||r>30||r<20,size:"small",variant:"outlined",onClick:()=>{o(D()),o(J({key:u==null?void 0:u.key,number_of_carcasses:Number(s.values.realNumber),weight_of_carcasses:Number(s.values.realWeight),ware_house:!0,weight_loss:parseFloat(r)})).then(p=>{p.payload.error?t({vertical:"top",horizontal:"center",msg:p.payload.error,severity:"error"}):(o(H()),a(1),A(),o(su({role_key:(y==null?void 0:y.key)||""})))})},children:"ثبت"})})]})]})})};var Q={},Xu=ju;Object.defineProperty(Q,"__esModule",{value:!0});var iu=Q.default=void 0,Zu=Xu(qu()),tu=e;iu=Q.default=(0,Zu.default)([(0,tu.jsx)("path",{d:"M20 2H4c-1 0-2 .9-2 2v3.01c0 .72.43 1.34 1 1.69V20c0 1.1 1.1 2 2 2h14c.9 0 2-.9 2-2V8.7c.57-.35 1-.97 1-1.69V4c0-1.1-1-2-2-2m-1 18H5V9h14zm1-13H4V4h16z"},"0"),(0,tu.jsx)("path",{d:"M9 12h6v2H9z"},"1")],"Inventory2Outlined");const de=({item:u,updateTable:a,barState:r,type:n})=>{const t=M(),o=K(N=>N.userSlice.selectedSubUser),[y,s]=h.useState(null),A=N=>{s(N.currentTarget)},g=()=>{s(null)},p=!!y,E=p?"popover":void 0,I=()=>(u==null?void 0:u.buyType)==="live"?!u.weightOfCarcasses&&!r:!1,W=()=>n==="carcass"||(u==null?void 0:u.buyType)!=="live"?!0:!r&&!u.weightOfCarcasses,q=(u==null?void 0:u.registerType)==="automatic"?!1:u.weightOfCarcasses&&!r&&(u==null?void 0:u.buyType)==="live";return e.jsxs("div",{children:[e.jsx(Bu,{disabled:q,"aria-describedby":E,variant:"contained",color:"primary",onClick:A,children:e.jsx(Pu,{})}),e.jsx(Su,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:E,open:p,anchorEl:y,onClose:g,children:e.jsxs(wu,{sx:{p:1},children:[(I()||(u==null?void 0:u.registerType)==="automatic")&&e.jsx(G,{disablePadding:!0,children:e.jsxs($,{sx:{color:"primary.main"},onClick:()=>{g(),t(nu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"ویرایش بار آزاد",content:e.jsx(Ju,{item:u,updateTable:a})}))},children:[e.jsx(Y,{sx:{minWidth:36,color:"inherit"},children:e.jsx(Ou,{fontSize:"small"})}),e.jsx(_,{variant:"body2",children:"ویرایش"})]})}),r&&(u==null?void 0:u.registerType)==="manual"&&e.jsx(G,{disablePadding:!0,children:e.jsxs($,{sx:{color:"success.main"},onClick:()=>{g(),t(ou({title:"ثبت اطلاعات لاشه ورودی به انبار",content:e.jsx(Qu,{item:u,updateTable:a,IsEdit:r==="entered"})}))},children:[e.jsx(Y,{sx:{minWidth:36,color:"inherit"},children:e.jsx(iu,{fontSize:"small"})}),e.jsx(_,{variant:"body2",children:r==="entered"?"ویرایش":"ورود به انبار"})]})}),W()&&(u==null?void 0:u.registerType)!=="automatic"&&e.jsx(G,{disablePadding:!0,children:e.jsxs($,{sx:{color:"error.main"},onClick:()=>{g(),t(mu(u.key)).then(()=>{a(),t(su({role_key:(o==null?void 0:o.key)||""}))})},children:[e.jsx(Y,{sx:{minWidth:36,color:"inherit"},children:e.jsx(Ru,{fontSize:"small"})}),e.jsx(_,{variant:"body2",color:"inherit",children:"حذف"})]})})]})})]})},ku=V({weight:x().positive("عدد مثبت وارد کنید"),amount:x().positive("عدد مثبت وارد کنید")}),he=({item:u,updateTable:a})=>{const r=M(),[n]=h.useContext(U),t=R({initialValues:{weight:"",amount:""},validationSchema:ku}),o=y=>{r(J({key:u==null?void 0:u.key,kill_house_vet_state:y,kill_house_vet_quantity:parseInt(t.values.amount),kill_house_vet_weight:parseInt(t.values.weight)})).then(s=>{r(H()),a(1),s.payload.error?n({vertical:"top",horizontal:"center",msg:s.payload.error,severity:"error"}):n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})};return e.jsxs(Tu,{container:!0,gap:S.SMALL,justifyContent:"center",children:[e.jsx(i,{fullWidth:!0,id:"amount",name:"amount",label:"حجم",value:t.values.amount,onChange:t.handleChange,error:t.touched.amount&&!!t.errors.amount,helperText:t.touched.amount&&t.errors.amount}),e.jsx(i,{fullWidth:!0,id:"weight",name:"weight",label:"وزن",value:t.values.weight,onChange:t.handleChange,error:t.touched.weight&&!!t.errors.weight,helperText:t.touched.weight&&t.errors.weight}),e.jsx(w,{variant:"contained",disabled:!t.isValid,onClick:()=>{o("accepted")},children:"تایید"}),e.jsx(w,{color:"error",variant:"outlined",onClick:()=>{o("rejected")},disabled:!t.isValid,children:"رد"})]})},Ce=L("VET_FARM_GET_OUT_PROVINCE_DASHBOARD",async(u,{dispatch:a})=>{a(D());const{data:r,status:n}=await m.get("dashboard_kill_house_free_bar",{params:{...u}});return a(j()),{data:r,status:n}});export{de as S,he as a,Ju as b,Qu as c,mu as s,Ce as v};