PageSourceSearch

https://p1.prosperna.com/assets/index-DqRL7DGM.js

js prosperna.com collected 2026-09-26 09:23:49 UTC 5,650 bytes, 1 lines download raw bytes

1import{a9 as O,ak as M,bd as G,d as L,gh as I,c as U,Q as v,r as l,j as e,S as A,R as p,I as c,F as n,a as g}from"./index-CSsSX63M.js";import{D as B}from"./DeleteOutline-ClE1B58E.js";import{S as H}from"./SectionTitle-CqftPwho.js";import{S as y}from"./utilities-CoYgNjuY.js";import{M as K}from"./index-CNfVor-1.js";import"./Grid-DNX_ExZZ.js";import"./index-CCVDs4O5.js";import"./HelpOutlined-CNQRJ5wk.js";import"./ArrowBack-C2ef7Myz.js";import"./OverlayTrigger-DxqfTLm5.js";import"./useTimeout-DMefeYIR.js";import"./mergeOptionsWithPopperConfig-Kl50-gi5.js";import"./useIsomorphicEffect-DOgrT-SO.js";const D=new L,z=async()=>(await D.get(I)).data,$=async r=>(await D.update(I,r)).data,k={useGetSettings:()=>G({queryKey:["directTransferSettings"],queryFn:z}),useSaveSettings:()=>{const r=O();return M({mutationFn:$,onSuccess:()=>{r.invalidateQueries({queryKey:["directTransferSettings"]}),r.invalidateQueries({queryKey:["stripeGateways"]})}})}},Y=["GCASH","MAYA","BPI","BDO","UNIONBANK","OTHER"],C=()=>({provider:"GCASH",account_name:"",account_number:"",qr_code_image:""}),le=()=>{const r=U(),{data:d,isLoading:w}=k.useGetSettings(),{mutate:q,isPending:b}=k.useSaveSettings(),Q=K.useUploadImageMediaItem({onError:a=>{v(!1,"Upload Failed",a||"Failed to upload QR code image.")}}),[j,S]=l.useState(!1),[x,m]=l.useState([C()]),[N,_]=l.useState(""),[f,R]=l.useState(null),T=l.useRef(!1);l.useEffect(()=>{var t;const a=d==null?void 0:d.data;a&&!T.current&&(T.current=!0,S(a.enabled===!0),m(((t=a.channels)==null?void 0:t.length)>0?a.channels:[C()]),_(a.notes||""))},[d]);const u=(a,t,s)=>{m(i=>i.map((o,h)=>h===a?{...o,[t]:s}:o))},E=()=>{m(a=>[...a,C()])},P=a=>{m(t=>t.filter((s,i)=>i!==a))},X=async(a,t)=>{var s,i;if(!(!t||t.length===0)){R(a);try{const o=await Q.mutateAsync([t[0]]),h=(i=(s=o==null?void 0:o.data)==null?void 0:s[0])==null?void 0:i.location;h&&u(a,"qr_code_image",h)}catch{}finally{R(null)}}},F=()=>{q({enabled:j,channels:x.filter(a=>a.provider||a.account_name||a.account_number),notes:N},{onSuccess:()=>{v(!0,"Direct Transfer Saved",j?"Direct Transfer is active. Customers can now pay your accounts at checkout.":"Your Direct Transfer settings have been saved."),r("/home/settings/payments")},onError:a=>{var t;v(!1,"Save Failed",((t=a==null?void 0:a.data)==null?void 0:t.message)||(a==null?void 0:a.message)||"Unable to save your Direct Transfer settings.")}})};return w?e.jsx("div",{className:"d-flex justify-content-center align-items-center vh-100",children:e.jsx(A,{animation:"border"})}):e.jsxs(e.Fragment,{children:[e.jsx(p,{className:"mt-1",children:e.jsx(c,{lg:12,children:e.jsx(H,{title:"Direct Transfer",popContent:"Accept GCash, Maya, or bank transfers. Customers pay your accounts at checkout and upload proof of payment, and you verify each order before it is processed."})})}),e.jsx(p,{className:"mt-1",children:e.jsxs(c,{lg:12,children:[e.jsx(y,{className:"mb-3",children:e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("div",{children:[e.jsx("h4",{children:"Enable Direct Transfer"}),e.jsx("p",{className:"text-muted mb-0",children:"Once enabled, this payment option appears at checkout."})]}),e.jsx(n.Check,{type:"switch",id:"direct-transfer-enabled",checked:j,onChange:a=>S(a.target.checked)})]})})}),e.jsx(y,{className:"mb-3",children:e.jsxs("div",{className:"p-3",children:[e.jsx("h4",{children:"Payment Channels"}),e.jsx("p",{className:"text-muted",children:"Add the accounts where customers can send their payment. These details are shown at checkout."}),x.map((a,t)=>e.jsxs("div",{className:"border rounded p-3 mb-3","data-testid":`payment-channel-${t}`,children:[e.jsxs(p,{children:[e.jsxs(c,{md:3,children:[e.jsx(n.Label,{children:"Provider"}),e.jsx(n.Select,{value:a.provider,onChange:s=>u(t,"provider",s.target.value),children:Y.map(s=>e.jsx("option",{value:s,children:s},s))})]}),e.jsxs(c,{md:4,children:[e.jsx(n.Label,{children:"Account Name"}),e.jsx(n.Control,{type:"text",placeholder:"Juan Dela Cruz",value:a.account_name,onChange:s=>u(t,"account_name",s.target.value)})]}),e.jsxs(c,{md:4,children:[e.jsx(n.Label,{children:"Account Number"}),e.jsx(n.Control,{type:"text",placeholder:"09XXXXXXXXX / account no.",value:a.account_number,onChange:s=>u(t,"account_number",s.target.value)})]}),e.jsx(c,{md:1,className:"d-flex align-items-end justify-content-end",children:x.length>1&&e.jsx(g,{variant:"link",size:"sm",onClick:()=>P(t),"aria-label":`Remove channel ${t+1}`,children:e.jsx(B,{})})})]}),e.jsxs(p,{className:"mt-2",children:[e.jsxs(c,{md:8,children:[e.jsx(n.Label,{children:"QR Code Image (optional)"}),e.jsx(n.Control,{type:"file",accept:"image/png,image/jpeg,image/jpg",disabled:f===t,onChange:s=>X(t,s.target.files)})]}),e.jsxs(c,{md:4,className:"d-flex align-items-end",children:[f===t&&e.jsx(A,{animation:"border",size:"sm"}),a.qr_code_image&&f!==t&&e.jsx("img",{src:a.qr_code_image,alt:`${a.provider} QR code`,style:{maxHeight:80}})]})]})]},t)),e.jsx(g,{variant:"outline-primary",onClick:E,children:"+ Add another channel"})]})}),e.jsx(y,{className:"mb-3",children:e.jsxs("div",{className:"p-3",children:[e.jsx("h4",{children:"Notes to Customers (optional)"}),e.jsx(n.Control,{as:"textarea",rows:3,maxLength:500,placeholder:"e.g. Send the exact amount and keep your transaction reference number.",value:N,onChange:a=>_(a.target.value)})]})}),e.jsxs("div",{className:"d-flex justify-content-end gap-2 mb-4",children:[e.jsx(g,{variant:"outline-secondary",onClick:()=>r("/home/settings/payments"),children:"Cancel"}),e.jsx(g,{onClick:F,disabled:b,children:b?"Saving…":"Save"})]})]})})]})};export{le as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.