import{j as e,ag as E,av as L,aw as N,ax as A,ak as g,T as w,B as k,p as x}from"./mui-vendor-CkIVaoQP.js";import{j as D,A as G,u as F,c as v,M as R,b as _,G as p,S as C,L as M,h as V,jI as P,jJ as W,N as H,v as m}from"./index-Cr86_nOs.js";import{r as f,b as h}from"./react-vendor-CmFgShSM.js";import{I as O,f as U}from"./toBase64-CmPKyXM7.js";import{a as q,u as z}from"./redux-vendor-B7uoacJt.js";const $=q("SLAUGHTER_NEW_COMPLAINT",async r=>{const{data:l,status:o}=await D.post("kill_house_complaint/",r);return{data:l,status:o}}),J=({barKey:r,role:l})=>{const[o]=f.useContext(G),t=z(),[n,j]=h.useState(10),[S,B]=h.useState([]),[i,y]=h.useState([]),b=(a,c)=>{B(a),y(a.map(d=>U(d.data_url)))},I=a=>{switch(a){case 10:return s.isValid&&u.isValid&&i.length;default:return u.isValid&&i.length}},T=a=>{j(a.target.value)},u=F({initialValues:{description:""},validationSchema:v({description:R().required("این فیلد اجباری است!").typeError("لطفا فیلد را پر کنید!")})}),s=F({initialValues:{looses:""},validationSchema:v({looses:_().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!")})});return f.useEffect(()=>{u.validateForm(),s.validateForm()},[]),e.jsxs(p,{container:!0,gap:C.SMALL,direction:"column",flex:"1",height:"100%",justifyContent:"space-between",children:[e.jsxs(p,{container:!0,direction:"column",gap:C.SMALL,children:[e.jsxs(E,{fullWidth:!0,children:[e.jsx(L,{id:"demo-simple-select-label",children:"موضوع"}),e.jsxs(N,{labelId:"demo-simple-select-label",id:"demo-simple-select",value:n,label:"موضوع",onChange:T,children:[e.jsx(A,{value:10,children:"مغایرت درصد تلفات با واقعیت"}),e.jsx(A,{value:20,children:"دیگر"})]})]}),n===10&&e.jsx(g,{id:"looses",label:"درصد تلفات",variant:"outlined",sx:{width:"100%",height:"100%"},value:s.values.looses,error:s.touched.looses?!!s.errors.looses:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.looses&&s.errors.looses?s.errors.looses:null}),e.jsx(g,{id:"description",label:"توضیحات",multiline:!0,rows:5,variant:"outlined",sx:{width:"100%",height:"100%"},value:u.values.description,error:u.touched.description?!!u.errors.description:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.description&&u.errors.description?u.errors.description:null}),e.jsx(w,{children:"پیوست تصویر"}),e.jsx(p,{mb:C.SMALL,children:e.jsx(O,{id:"image",onChange:b,images:S,maxNumber:4,title:"بارگذاری سند",value:u.values.image,error:u.touched.image?!!u.errors.image:null,onBlur:u.handleBlur,helperText:u.touched.image&&u.errors.image?u.errors.image:null})})]}),e.jsx(k,{fullWidth:!0,variant:"contained",disabled:!I(n),onClick:()=>{var a,c;t(M()),t($({bar_key:r,image:i,title:n===10?" مغایرت درصد تلفات با واقعیت":"دیگر",description:u.values.description,percent:(a=s.values)!=null&&a.looses?(c=s.values)==null?void 0:c.looses:null,role:l})).then(d=>{t(V()),d.error?o({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است",severity:"error"}):(t(P()),t(W()),t(H({right:!1,bottom:!1,content:null})),o({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد!",severity:"success"}))})},children:"ثبت اطلاعات"})]})};J.propTypes={barKey:x.PropTypes.any,role:x.PropTypes.any};const uu=r=>{const l=m(new Date(r)),o=m(),t=l.diff(o);return m.duration(t).asSeconds()};export{J as S,uu as g};
