2 lines
9.4 KiB
JavaScript
2 lines
9.4 KiB
JavaScript
|
|
import{j as u,an as z,B as R,al as E,b8 as L,T as V,i as P,aj as U,ak as Y,am as w,I as Q,b3 as K,aq as X,b7 as J,as as Z,at as uu}from"./mui-vendor-D_SVL-Dx.js";import{r as d}from"./react-vendor-CmFgShSM.js";import{L as _,j as F,h,A as S,u as D,c as H,a0 as W,W as eu,fW as ru,V as T,cE as tu,G as A,C as G,r as ou,fE as au,O as N}from"./index-D80MdVQn.js";import{a as k,u as I,f as su}from"./redux-vendor-CfkcHgWN.js";import{d as nu}from"./Tune-BBzxV8DK.js";import{a as lu}from"./index.esm-C1-dCPnj.js";import{F as iu}from"./FileUploader-DvFCJiD0.js";import{d as cu}from"./Add-CiyqkOpq.js";import{d as du}from"./Sms-C-zLQmIm.js";const $=k("ARCHIVE_HATCHING_SERVICE",async(e,{dispatch:t})=>{t(_());try{const{data:o,status:s}=await F.put("poultry_hatching/0/",e);return t(h()),{data:o,status:s}}catch(o){return t(h()),{error:o.response.data.result}}}),Cu=H({name:T()}),Iu=({item:e,selectedAge1:t,selectedAge2:o,updateTable:s})=>{const[r]=d.useContext(S),c=I(),n=D({initialValues:{name:""},validationSchema:Cu,onSubmit:p=>{c($({key:e.key,archive_state:"",message:p.name,role:W()})).then(m=>{m.payload.error?r({vertical:"top",horizontal:"center",msg:m.payload.error,severity:"error"}):(c(eu({right:!1,bottom:!1,content:null})),t&&c(ru({selectedAge1:t,selectedAge2:o})),s(),r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}});return u.jsxs("form",{onSubmit:n.handleSubmit,children:[u.jsx(z,{id:"name",name:"name",label:"توضیحات",variant:"outlined",multiline:!0,rows:4,fullWidth:!0,margin:"normal",value:n.values.name,onChange:n.handleChange,onBlur:n.handleBlur,helperText:n.touched.name&&n.errors.name,error:n.touched.name&&!!n.errors.name}),u.jsx(R,{type:"submit",variant:"contained",color:"primary",fullWidth:!0,children:"ثبت"})]})},hu=k("HATCHING_UNDO_ARCHIVE_SERVICE",async(e,{dispatch:t})=>{try{t(_());const{data:o,status:s}=await F.put("poultry_hatching/0/",e);return t(h()),{data:o,status:s}}catch(o){return t(h()),{error:o.response.data.result}}}),mu=({item:e,updateTable:t,isArchive:o})=>{const[s,r]=d.useState(e==null?void 0:e.violation),[c,n]=d.useState(!1),p=I(),m=i=>{r(i.target.checked)},x=i=>{n(i.target.checked)},[y]=d.useContext(S),[b,C]=d.useState([]),B=i=>{C(i)},l=D({initialValues:{reportText:e==null?void 0:e.violationReport,bar_image:""},validationSchema:H({reportText:T().required("این فیلد اجباری است!").typeError("لطفا گزارش خود را بیان کنید."),bar_image:tu()})});return d.useEffect(()=>{l.validateForm()},[]),u.jsxs(A,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsx(E,{control:u.jsx(L,{checked:s,onChange:m,color:"primary"}),label:s?"متخلف":"بدون تخلف",style:{justifyContent:"center",alignItems:"center",display:"flex"}}),!o&&u.jsx(E,{control:u.jsx(L,{checked:c,onChange:x,color:"primary"}),label:"انتقال به بایگانی",style:{justifyContent:"center",alignItems:"center",display:"flex"}}),u.jsx(z,{multiline:!0,rows:4,fullWidth:!0,id:"reportText",label:"متن گزارش",variant:"outlined",value:l.values.reportText,error:l.touched.reportText?!!l.errors.reportText:null,onChange:l.handleChange,onBlur:l.handleBlur,helperText:l.touched.reportText&&l.errors.reportText?l.errors.reportText:null}),u.jsx(V,{color:"error",children:"در صورت آپلود فایل جدید، سندهای پیشین حذف میشوند!"}),u.jsx(iu,{onChange:B}),u.jsx(R,{mt:2,disabled:!l.isValid||l.isSubmitting,fullWidth:!0,variant:"contained",onClick:async()=>{try{const i={key:e==null?void 0:e.key,violation_check:!0,violation:s,violation_report:l.values.reportText,archive:c},v=new FormData;Object.entries(i).forEach(([f,g])=>{v.append(f,g)}),b.forEach((f,g)=>{v.append(`violation_image_${g}`,f)});const j=await p($(b.length?v:i));if(j.error)throw new Error(j.error);t(1),p(G()),y({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})}catch(i){y({vertical:"top",horizontal:"center",msg:i.message||"خطا در ارسال اطلاعات",severity:"err
|