%PDF- %PDF-
Direktori : /home/opti/www/startup-life/assets/ |
Current File : /home/opti/www/startup-life/assets/index-c06f3d54.js |
import{e as f,d as y,r as d,u as q,j as e,Q as o}from"./index-5492fbe1.js";import{u as B}from"./index.esm-1be9f6a3.js";import{I as b}from"./index-fbb310b5.js";import{C as p}from"./index-2c4b8b3c.js";import{u as S}from"./useQuery-0abbcf43.js";import{f as F}from"./index.esm-b6fe913b.js";import"./Menu-c26e62ae.js";import"./useFormControl-45c447f9.js";import"./useForkRef-ff55d5c8.js";import"./TransitionGroupContext-29effe25.js";import"./setPrototypeOf-0bb37fbe.js";import"./Modal-01a2ce69.js";import"./useTheme-0dfa0cbc.js";import"./useSlotProps-b42d44e4.js";import"./index-e5978b8b.js";import"./Paper-26f2abc8.js";import"./useControlled-967f9278.js";import"./createSvgIcon-6a373a0a.js";import"./joinClasses-adfcc520.js";import"./iconBase-4b2ba95c.js";const R=()=>S({queryFn:async()=>{var t;try{return(await f.get("/paystack/get-bank-list")).data}catch(r){return(t=r.response)==null?void 0:t.data}},queryKey:["bank_list"]}),T=()=>y({mutationFn:async t=>{var r;try{return(await f.post("/paystack/resolve-account",t)).data}catch(a){return(r=a.response)==null?void 0:r.data}}}),_=()=>y({mutationFn:async t=>{var r;try{return(await f.post("/paystack/create-transfer-recipient",t)).data}catch(a){return(r=a.response)==null?void 0:r.data}}}),ee=()=>{const{control:s,setValue:c,getValues:t}=B({mode:"onBlur"}),{data:r}=R(),[a,i]=d.useState(!1),[m,g]=d.useState(""),N=q(),[j,v]=d.useState(""),{mutateAsync:w,isPending:u}=T(),{mutateAsync:k,isPending:h}=_();console.log(r);const A=n=>{console.log(n.code),c("beneficiaryBankCode",n.code),i(!1),v(n.name),w({account_number:t().beneficiaryAccountNumber,bank_code:n.code}).then(l=>{if(console.log(l),l.message==="Account number resolved")c("beneficiaryAccountName",l.data.account_name);else{o.error("bank details is incorrect");return}})},C=()=>{if(!t().amount||!t().beneficiaryAccountNumber||!t().beneficiaryAccountName||!t().beneficiaryBankCode){o.error("fill all bank fields");return}k({account_number:t().beneficiaryAccountNumber,bank_code:t().beneficiaryBankCode,name:t().beneficiaryAccountName,amount:t().amount}).then(n=>{if(console.log(n),n.statusCode===400||n.statusCode===500||n.statusCode===404){if(n.message==="Internal server error"){o.error("Something went wrong. Check inputs and try again");return}o.error(n.message);return}o.success(`You have successfully withdraw the sum of ${t().amount} from your wallet into your personal account with the the account number ${t().beneficiaryAccountNumber} with the account name ${t().beneficiaryAccountName}`),console.log(n),N("/dashboard")})},x=d.useMemo(()=>m?r.data.filter(n=>n.name.toLowerCase().includes(m)):(r==null?void 0:r.data)||[],[m,r]);return e.jsxs("div",{className:"withdrawal py-[40px]",children:[e.jsx("div",{className:"title text-center font-[600] text-[28px]",children:e.jsx("div",{children:"Withdrawal"})}),e.jsxs("div",{className:"w-[400px] flex flex-col gap-[20px] mt-[40px] mx-auto border-[#A8CF45]",children:[e.jsx(p,{appear:u,children:"Resolving bank info..."}),e.jsx(b,{name:"beneficiaryAccountNumber",label:"Account Number",labelSize:"1.125rem",control:s,disabled:u,rules:{required:"Please enter beneficiary account number"}}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mt-[20px] text-gray-500 text-[1.2rem] font-[400]",htmlFor:"fullname",children:"Select Bank"}),e.jsxs("div",{className:"relative w-full text-gray-500 bg-white h-[60px] rounded-[10px] flex justify-between items-center mb-[10px] border-[2px] border-gray-400 p-[10px]",children:[e.jsx("div",{className:"font-[600] capitalize",children:j}),e.jsx("span",{onClick:()=>{if(console.log(t().beneficiaryAccountNumber),!u){if(!t().beneficiaryAccountNumber||t().beneficiaryAccountNumber.length<10){o.error("account must be submitted, and the length must be 10");return}i(!a)}},className:"text-[1.2rem] right-[20px] top-[15px] cursor-pointer",children:e.jsx(F,{})})]})]}),e.jsx(p,{appear:!!a,children:e.jsxs("div",{className:"bg-white w-full shadow-lg absolute z-10",children:[e.jsx("div",{className:"",children:e.jsx("input",{onChange:n=>g(n.target.value),value:m,onFocus:()=>i(!0),type:"text",className:"p-[10px] w-full border mb-[10px] rounded-[5px] border-[#A8CF45] outline-none"})}),e.jsxs("div",{className:"banks h-[300px] overflow-auto flex flex-col gap-[10px] pt-[10px] rounded-[10px]",children:[e.jsx(p,{appear:x.length>0,children:x.map((n,l)=>e.jsx("div",{onClick:()=>{A(n)},className:"bank flex items-center px-[20px] w-full cursor-pointer",children:e.jsx("div",{children:n.name})},l))}),e.jsx(p,{appear:x.length===0,children:e.jsx("div",{className:"p-[20px]",children:"No bank match search..."})})]})]})})]}),e.jsx(b,{name:"beneficiaryAccountName",label:"Account Name",labelSize:"1.125rem",control:s,disabled:!0,className:"cursor-not-allowed",rules:{required:""}}),e.jsx(b,{name:"amount",type:"number",label:"Enter Amount",labelSize:"1.125rem",control:s,disabled:u,rules:{required:"Please enter amount"}}),e.jsx("div",{className:"act",children:e.jsx("button",{type:"button",disabled:u||h,onClick:C,className:"bg-[#A8CF45] outline-none uppercase w-full block py-[10px] text-[#fff]",children:h?"Transfering...":"Submit"})})]})]})};export{ee as Withdrawal,ee as default};