import{j as e,bt as R,T as P}from"./mui-vendor-CkIVaoQP.js";import{r as n}from"./react-vendor-CmFgShSM.js";import{a as p,u as S}from"./redux-vendor-B7uoacJt.js";import{j as d,X as f,G as A,S as g}from"./index-Cr86_nOs.js";const j=p("SLAUGHTER_PAYMENT_REF_ID",async(t,{dispatch:o})=>{const{data:a,status:s}=await d.post("wage_payment/",t);return{data:a,status:s}}),w=p("PROVINCE_PAYMENT_REF_ID",async(t,{dispatch:o})=>{const{data:a,status:s}=await d.post("wage-payment-total/",t);return{data:a,status:s}}),k=p("PROVINCE_PAYMENT_REF_ID_WAGES",async(t,{dispatch:o})=>{const{data:a,status:s}=await d.post(`https://${t.backend}backend.rasadyar.com/wage-payment-with-link/`,t.data);return{data:a,status:s}}),b=({amount:t,user_key:o,amountWithTax:a,isZarinPal:s,isPayment:E,isPaymentData:_,backend:x})=>{const i=S(),l=n.useRef(),[h,I]=n.useState(),[c,m]=n.useState(),y=()=>{l.current.submit()};return n.useEffect(()=>{s?i(w({role:f(),total_amount:parseInt(t)})).then(r=>{var u;m((u=r.payload.data)==null?void 0:u.token)}):E?i(k({data:_,backend:x})).then(r=>{var u;m((u=r.payload.data)==null?void 0:u.token)}):i(j({role:f(),kill_house_key:o,payment_type:"auto",amount:parseInt(t),amount_with_tax:parseInt(a)})).then(r=>{I(r.payload.data.refId)})},[]),n.useEffect(()=>{h&&y()},[h]),n.useEffect(()=>{c&&y()},[c]),e.jsxs(A,{container:!0,direction:"column",width:"100%",gap:g.TINY,children:[e.jsx(R,{style:{width:"100%"}}),e.jsx(P,{textAlign:"center",children:"در حال انتقال به درگاه پرداخت..."}),e.jsx("div",{style:{display:"none"},children:e.jsxs("form",{ref:l,action:"https://sep.shaparak.ir/OnlinePG/OnlinePG",method:"post",children:[e.jsx("input",{type:"hidden",name:"Token",value:c}),e.jsx("input",{name:"GetMethod",type:"text",value:""}),e.jsx("input",{type:"submit",value:"Submit"})]})})]})};export{b as S};
