Files
Rasadyar_FrontEnd/build/assets/SlaughterPayProvinceFactorForm-BwQZlEga.js

2 lines
7.9 KiB
JavaScript

import{j as u,T as o,P,ah as x,b as F,cs as B,ac as _,an as G,I as O,B as I,aR as V,aS as W,aT as q,aU as z,aV as Y,aW as Z,ak as $,al as R,am as k}from"./mui-vendor-D_SVL-Dx.js";import{r as h}from"./react-vendor-CmFgShSM.js";import{G as a,S as d,j as w,A as v,L as J,a0 as T,iu as Q,iv as X,W as H,h as K,u as uu,c as eu,b as au}from"./index-D80MdVQn.js";import{a as D,u as tu}from"./redux-vendor-CfkcHgWN.js";import{d as ru}from"./Add-CiyqkOpq.js";import{d as nu}from"./Delete-CIwpNviU.js";import{N}from"./NumberFormatCustom-BXcOcGV4.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(o,{variant:"body2",children:"اطلاعات بانکی جهت واریز مبلغ"}),u.jsx(o,{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(o,{children:["شماره کارت ",e]})}),u.jsx("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"20px"},children:u.jsxs(o,{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:m,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),m=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(o,{children:"سند:"}),u.jsx(B,{type:"file",accept:"image/*",onChange:m}),e&&u.jsx(F,{mt:2,children:u.jsx("img",{src:i,alt:"img",width:"200px",style:{borderRadius:"10px"}})})]})},iu=D("SLAUGHTER_UPDATE_PAY_PROVINCE_FACTOR",async e=>{const{data:r,status:i}=await w.put("kill_house_factor_province/0/",e);return{data:r,status:i}}),du=D("SLAUGHTER_PAY_PROVINCE_FACTOR",async e=>{const{data:r,status:i}=await w.post("kill_house_factor_province/",e);return{data:r,status:i}}),lu=({provinceFactorToKillHouse:e,price:r,isRejected:i,barCode:p,killHouseFactorToProvince:m})=>{var b;const n=tu(),[,,s,,c]=h.useContext(v),[j]=h.useContext(v),[y,A]=h.useState([{id:11,paymentId:"",doc:"",amount:""},{id:22,paymentId:"",doc:"",amount:""}]),f=y.reduce((t,l)=>t+Number(l.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(o,{variant:"body2",color:"primary",children:"مبلغ قابل پرداخت"}),u.jsxs(o,{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(o,{variant:"body2",color:"primary",children:"شناسه پرداخت"}),u.jsx(o,{variant:"body2",color:"error",fontWeight:"bold",children:p})]})]}),u.jsx(a,{children:u.jsx(o,{variant:"body1",fontWeight:"bold"})})]}),u.jsxs(a,{container:!0,direction:"column",alignItems:"center",gap:d.SMALL,children:[y.sort((t,l)=>t.id-l.id).map((t,l)=>u.jsxs(a,{container:!0,alignItems:"center",gap:d.SMALL,children:[u.jsxs(o,{children:[l+1,"."]}),u.jsx(a,{children:u.jsx(N,{allowLeadingZeros:!0,thousandSeparator:",",InputProps:{endAdornment:u.jsx(_,{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(G,{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(O,{"aria-label":"delete",color:"error",onClick:()=>{A(C=>{const g=t.id;return C.filter(E=>E.id!==g)})},children:u.jsx(nu,{})})})]},l)),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(J());const t=l=>{l.error?j({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(n(Q({selectedDate1:s,selectedDate2:c})),n(X({selectedDate1:s,selectedDate2:c})),n(H({right:!1,bottom:!1,top:!1,content:null,size:null})),j({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})),n(K())};if(i){const l={role:T()};n(iu(l)).then(t)}else{const l={role:T()};n(du(l)).then(t)}},children:"ثبت"})})]})]})]})})},ou=({provinceFactorToKillHouse:e,price:r,isRejected:i,barCode:p,killHouseFactorToProvince:m})=>{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(N,{allowLeadingZeros:!0,thousandSeparator:",",id:"outlined-basic",label:"مبلغ برای پرداخت را وارد کنید",variant:"outlined",InputProps:{endAdornment:u.jsx(_,{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:m,barCode:n,item:s})=>{const c=uu({initialValues:{paymentId:""},validationSchema:eu({paymentId:au().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!")})});h.useEffect(()=>{c.validateForm()},[]),h.useEffect(()=>{m&&c.setFieldValue("paymentId",p.paymentCode)},[]);let j="";(s==null?void 0:s.factorPersonType)==="union"?j="اتحادیه":j="مرغدار";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(W,{children:[u.jsx(q,{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(Y,{variant:"body1",fontWeight:"bold",color:"secondary",children:["انجام عملیات - پرداخت به ",j]})}),u.jsx(a,{children:u.jsx(Z,{color:"textSecondary",children:u.jsx(a,{container:!0,gap:d.SMALL,children:u.jsx(o,{variant:"body2",display:"flex",gap:d.SMALL,children:"در این مرحله مبلغ را پرداخت کنید و شناسه پرداخت را وارد و سند آن را بارگذاری کنید."})})})})]}),u.jsx(a,{children:u.jsxs($,{"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(ou,{}),y==="manual-payment"&&u.jsx(lu,{price:r,provinceFactorToKillHouse:i,barCode:n,isRejected:m,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};