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

2 lines
7.9 KiB
JavaScript

import{j as u,T as l,bs as P,p as x,b as F,co as O,aa as T,ak as B,I as G,B as I,aO as V,aP as q,aQ as W,aR as z,aS as $,aT as Y,ah as Z,ai as R,aj as k}from"./mui-vendor-CkIVaoQP.js";import{r as h}from"./react-vendor-CmFgShSM.js";import{G as a,S as d,j as _,A as v,L as Q,X as N,h$ as X,i0 as J,N as H,h as K,u as uu,c as eu,b as au}from"./index-BHF9XhlR.js";import{a as w,u as tu}from"./redux-vendor-B7uoacJt.js";import{d as ru}from"./Add-B14uoYzg.js";import{d as nu}from"./Delete-BMbGwban.js";import{N as D}from"./NumberFormatCustom-DwWPj40N.js";const M=({cardNumber:e,expirationDate:r,bankName:i,bankUser:p})=>u.jsxs("div",{style:{border:"1px solid #d9d9d9",borderRadius:"10px",padding:"20px",backgroundColor:"#f0f0f0",width:"350px"},children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",flexDirection:"row"},children:[u.jsxs("div",{children:[u.jsx(l,{variant:"body2",children:"اطلاعات بانکی جهت واریز مبلغ"}),u.jsx(l,{variant:"h6",fontWeight:"bold",children:i})]}),u.jsx("div",{children:u.jsx("img",{src:"https://fs.noorgram.ir/xen/2020/12/953_f6253f3c48b7e2a782b3526bf4b80fbd.png",alt:"Visa",width:"50px"})})]}),u.jsx("div",{style:{fontSize:"18px",marginTop:"40px"},children:u.jsxs(l,{children:["شماره کارت ",e]})}),u.jsx("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"20px"},children:u.jsxs(l,{children:[u.jsx("div",{style:{fontSize:"14px"},children:p}),u.jsx("div",{style:{fontSize:"18px"},children:r})]})})]});M.propTypes={cardNumber:P.string.isRequired,expirationDate:P.string.isRequired};const U=({card:e,shaba:r,info:i,price:p,priceText:j,bankName:n,bankUser:s})=>u.jsx(a,{container:!0,alignItems:"start",pl:d.SMALL,gap:d.SMALL,mt:d.SMALL,children:u.jsx(a,{children:u.jsx(M,{bankName:"بانک "+n,bankUser:s,cardNumber:e,expirationDate:"IR"+r})})});U.propTypes={card:x.PropTypes.string,shaba:x.PropTypes.string,info:x.PropTypes.string,price:x.PropTypes.any,priceText:x.PropTypes.any};const su=()=>{const[e,r]=h.useState(null),[i,p]=h.useState(null),j=n=>{const s=n.target.files[0];if(s){const c=new FileReader;c.onload=()=>{r(s),p(c.result)},c.readAsDataURL(s)}};return u.jsxs(F,{children:[u.jsx(l,{children:"سند:"}),u.jsx(O,{type:"file",accept:"image/*",onChange:j}),e&&u.jsx(F,{mt:2,children:u.jsx("img",{src:i,alt:"img",width:"200px",style:{borderRadius:"10px"}})})]})},iu=w("SLAUGHTER_UPDATE_PAY_PROVINCE_FACTOR",async e=>{const{data:r,status:i}=await _.put("kill_house_factor_province/0/",e);return{data:r,status:i}}),du=w("SLAUGHTER_PAY_PROVINCE_FACTOR",async e=>{const{data:r,status:i}=await _.post("kill_house_factor_province/",e);return{data:r,status:i}}),ou=({provinceFactorToKillHouse:e,price:r,isRejected:i,barCode:p,killHouseFactorToProvince:j})=>{var b;const n=tu(),[,,s,,c]=h.useContext(v),[m]=h.useContext(v),[y,A]=h.useState([{id:11,paymentId:"",doc:"",amount:""},{id:22,paymentId:"",doc:"",amount:""}]),f=y.reduce((t,o)=>t+Number(o.amount),0);return u.jsx(a,{container:!0,children:u.jsxs(a,{container:!0,alignItems:"start",children:[u.jsx(a,{children:u.jsx(U,{card:e==null?void 0:e.card,shaba:e==null?void 0:e.shaba,info:e==null?void 0:e.nameOfBankUser,price:r,priceText:e==null?void 0:e.totalAmountChar,bankName:e==null?void 0:e.bankName,bankUser:e==null?void 0:e.nameOfBankUser})}),u.jsxs(a,{container:!0,direction:"column",gap:d.SMALL,mt:d.SMALL,pl:d.SMALL,children:[u.jsxs(a,{children:[u.jsxs(a,{container:!0,gap:d.MEDIUM,children:[u.jsxs(a,{children:[u.jsx(l,{variant:"body2",color:"primary",children:"مبلغ قابل پرداخت"}),u.jsxs(l,{variant:"body2",color:"error",fontWeight:"bold",children:[f?(Number(r)-f).toLocaleString():(b=Number(r))==null?void 0:b.toLocaleString()," ","ریال"]})]}),u.jsxs(a,{children:[u.jsx(l,{variant:"body2",color:"primary",children:"شناسه پرداخت"}),u.jsx(l,{variant:"body2",color:"error",fontWeight:"bold",children:p})]})]}),u.jsx(a,{children:u.jsx(l,{variant:"body1",fontWeight:"bold"})})]}),u.jsxs(a,{container:!0,direction:"column",alignItems:"center",gap:d.SMALL,children:[y.sort((t,o)=>t.id-o.id).map((t,o)=>u.jsxs(a,{container:!0,alignItems:"center",gap:d.SMALL,children:[u.jsxs(l,{children:[o+1,"."]}),u.jsx(a,{children:u.jsx(D,{allowLeadingZeros:!0,thousandSeparator:",",InputProps:{endAdornment:u.jsx(T,{position:"end",children:"ریال"})},label:"مبلغ پرداخت شده",value:t.amount,onChange:C=>{A(g=>{const S=t.id;return[...g.filter(L=>L.id!==S),{...t,id:t.id,amount:C.target.value}]})}})}),u.jsx(a,{children:u.jsx(B,{label:"شناسه واریز",value:t.paymentId,onChange:C=>{A(g=>{const S=t.id;return[...g.filter(L=>L.id!==S),{...t,id:t.id,paymentId:C.target.value}]})}})}),u.jsx(a,{children:u.jsx(su,{})}),u.jsx(a,{children:u.jsx(G,{"aria-label":"delete",color:"error",onClick:()=>{A(C=>{const g=t.id;return C.filter(E=>E.id!==g)})},children:u.jsx(nu,{})})})]},o)),u.jsxs(I,{color:"primary","aria-label":"Add",onClick:()=>{A(t=>[...t,{id:Date.now()}])},children:[u.jsx(ru,{}),"افزودن سند"]}),u.jsx(a,{children:u.jsx(I,{variant:"contained",onClick:()=>{n(Q());const t=o=>{o.error?m({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(n(X({selectedDate1:s,selectedDate2:c})),n(J({selectedDate1:s,selectedDate2:c})),n(H({right:!1,bottom:!1,top:!1,content:null,size:null})),m({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})),n(K())};if(i){const o={role:N()};n(iu(o)).then(t)}else{const o={role:N()};n(du(o)).then(t)}},children:"ثبت"})})]})]})]})})},lu=({provinceFactorToKillHouse:e,price:r,isRejected:i,barCode:p,killHouseFactorToProvince:j})=>{const[n,s]=h.useState("");return u.jsxs(a,{container:!0,gap:d.SMALL,mt:d.SMALL,alignItems:"center",children:[u.jsx(a,{children:u.jsx(D,{allowLeadingZeros:!0,thousandSeparator:",",id:"outlined-basic",label:"مبلغ برای پرداخت را وارد کنید",variant:"outlined",InputProps:{endAdornment:u.jsx(T,{position:"end",children:"ریال"})},value:n,onChange:c=>s(c.target.value)})}),u.jsx(a,{children:u.jsx(I,{variant:"contained",children:"ارسال به درگاه پرداخت"})})]})},cu=({factorKey:e,price:r,provinceFactorToKillHouse:i,killHouseFactorToProvince:p,isRejected:j,barCode:n,item:s})=>{const c=uu({initialValues:{paymentId:""},validationSchema:eu({paymentId:au().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!")})});h.useEffect(()=>{c.validateForm()},[]),h.useEffect(()=>{j&&c.setFieldValue("paymentId",p.paymentCode)},[]);let m="";(s==null?void 0:s.factorPersonType)==="union"?m="اتحادیه":m="مرغدار";const[y,A]=h.useState("option1"),f=b=>{A(b.target.value)};return u.jsxs(V,{sx:{alignSelf:"flex-start",width:"100%"},children:[u.jsxs(q,{children:[u.jsx(W,{color:"secondary"}),u.jsx(z,{})]}),u.jsxs(a,{container:!0,direction:"column",flexWrap:"nowrap",flex:"1",children:[u.jsxs(a,{container:!0,children:[u.jsx(a,{children:u.jsxs($,{variant:"body1",fontWeight:"bold",color:"secondary",children:["انجام عملیات - پرداخت به ",m]})}),u.jsx(a,{children:u.jsx(Y,{color:"textSecondary",children:u.jsx(a,{container:!0,gap:d.SMALL,children:u.jsx(l,{variant:"body2",display:"flex",gap:d.SMALL,children:"در این مرحله مبلغ را پرداخت کنید و شناسه پرداخت را وارد و سند آن را بارگذاری کنید."})})})})]}),u.jsx(a,{children:u.jsxs(Z,{"aria-labelledby":"radio-group-label",name:"radio-buttons-group",value:y,onChange:f,children:[u.jsx(R,{value:"bank-gateway",control:u.jsx(k,{}),label:"پرداخت از طریق درگاه پرداخت"}),u.jsx(R,{value:"manual-payment",control:u.jsx(k,{}),label:"ثبت سند پرداخت"})]})}),u.jsxs(a,{children:[y==="bank-gateway"&&u.jsx(lu,{}),y==="manual-payment"&&u.jsx(ou,{price:r,provinceFactorToKillHouse:i,barCode:n,isRejected:j,killHouseFactorToProvince:p})]})]})]})};cu.propTypes={factorKey:x.PropTypes.string,price:x.PropTypes.any,provinceFactorToKillHouse:x.PropTypes.any,killHouseFactorToProvince:x.PropTypes.any,isRejected:x.PropTypes.any};export{cu as S,du as s};