import{j as u,B as C,I as h,b as A}from"./mui-vendor-CkIVaoQP.js";import{L as f,j as x,h as F,A as S,u as j,k1 as c,N as p,G as s,S as l}from"./index-Vwb3Bce5.js";import{r as a}from"./react-vendor-CmFgShSM.js";import{a as k,u as d,f as v}from"./redux-vendor-B7uoacJt.js";import{A as b}from"./AdvancedTable-B0ObjV8k.js";import{N as g}from"./NumberFormatCustom-DwWPj40N.js";import{d as y}from"./Edit-CwJaslma.js";import"./index-CgNdnt2v.js";import"./Close-8pFLGZ5w.js";import"./Search-CLlOaERQ.js";import"./Delete-DHYHiC8G.js";const L=k("PROVINCE_FINANCIAL_SETTLMENT_SERVICE",async(t,{dispatch:r})=>{r(f());const{data:n,status:e}=await x.put("kill_house_creditors/0/",t);return r(F()),{data:n,status:e}}),E=(t,r)=>{const n={};return t.price?/^[0-9]*$/i.test(t.price)?parseInt(t.price)>parseInt(r)&&(n.price=`عدد نمی تواند بزرگتر از ${r} ﷼ باشد.`):n.price="لطفا عدد وارد کنید.":n.price="این فیلد اجباری است.",n},I=({item:t})=>{const[r]=a.useContext(S),n=d(),e=j({initialValues:{price:t.amount},validate:i=>E(i,t.amount),onSubmit:i=>{n(L({amount:i.price,key:t.key})).then(o=>{n(c()),r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),n(p({right:!1,bottom:!1,content:null,size:null}))})}});return a.useEffect(()=>{e.setFieldValue("price",t.amount)},[]),u.jsxs("form",{onSubmit:e.handleSubmit,width:"100%",children:[u.jsx(s,{children:u.jsx(g,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"price",label:"مبلغ (﷼)",variant:"outlined",value:e.values.price,error:e.touched.price?!!e.errors.price:null,onChange:e.handleChange,onBlur:e.handleBlur,helperText:e.touched.price&&e.errors.price?e.errors.price:null})}),u.jsx(s,{mt:l.SMALL,children:u.jsx(C,{fullWidth:!0,color:"primary",variant:"contained",type:"submit",children:"ثبت"})})]})},N=()=>{const t=d(),{provinceFinancialGetSlaughterSattlement:r}=v(i=>i.provinceFinancialSlice),[n,e]=a.useState([]);return a.useEffect(()=>{t(c())},[]),a.useEffect(()=>{const i=r==null?void 0:r.map((o,m)=>[o.killHouse.name,o.killHouse.killHouseOperator.user.fullname,o.killHouse.killHouseOperator.user.mobile,o.killHouse.killHouseOperator.user.city,o.killHouse.killHouseOperator.user.province,o.amount.toLocaleString()+" ﷼",u.jsx(h,{color:"primary",onClick:()=>{t(p({title:"انجام عملیات تسویه حساب",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(I,{item:o})}))},children:u.jsx(y,{})},m)]);e(i)},[r]),u.jsx(s,{container:!0,mt:l.SMALL,children:u.jsx(b,{name:"تسویه با کشتارگاه",columns:["نام","مالک","تلفن","شهر","استان","مبلغ","تسویه"],data:n})})},M=()=>u.jsx(u.Fragment,{children:u.jsx(A,{display:"flex",justifyContent:"center",children:u.jsx(s,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,children:u.jsx(s,{container:!0,justifyContent:"space-between",gap:l.SMALL,children:u.jsx(s,{xs:12,children:u.jsx(N,{})})})})})});export{M as default};
