import{K as f,u as N,r,j as e,S as b}from"./app-BMysVXg2.js";import{h as k}from"./index-BBHaahpi.js";import{M as h}from"./menu-layout-DRG0RIty.js";import{P as w}from"./payment-method-Bebfb-nD.js";import{L as v}from"./loading-screen-DL6SqjyA.js";/* empty css            */import"./iconBase-BRa7Gs07.js";import"./AppLayout-CZK2OZmQ.js";import"./payment-utils-BOgEUXTT.js";import"./wallet-CE-i1bzG.js";import"./createLucideIcon-D5220jan.js";const V=()=>{var x,g;const{auth:S,data:s}=f().props,{log:n}=N(),[p,P]=r.useState(!1),[o,c]=r.useState(!1),[M,u]=r.useState("wallet"),[l,m]=r.useState({});r.useEffect(()=>{var a,t;n("Payment methods page loaded:",{siswaName:(a=s.siswa)==null?void 0:a.namlen,balance:s.balance,totalTagihan:((t=s.tagihan)==null?void 0:t.length)||0})},[(x=s.siswa)==null?void 0:x.namlen,s.balance,(g=s.tagihan)==null?void 0:g.length,n]);const y=a=>{u(a),n("Payment method selected:",a)},j=async a=>{c(!0),m({});try{n("Processing payment with method:",a),await new Promise(t=>setTimeout(t,3e3)),a==="wallet"?(n("Wallet payment processed successfully"),b.visit("/payment/success")):a==="va"&&(n("VA payment initiated successfully"),b.visit("/payment/va-payment"))}catch(t){n("Payment processing error:",t),m({payment:"Gagal memproses pembayaran. Silakan coba lagi."})}finally{c(!1)}},d=()=>{n("Navigating back from payment methods"),window.history.back()};if(p)return e.jsx(h,{title:"Metode Pembayaran",onBack:d,children:e.jsx(v,{variant:"overlay"})});const i=(s.tagihan||[]).reduce((a,t)=>a+t.jumlah,0);return e.jsx(h,{title:"Metode Pembayaran",onBack:d,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Ringkasan Pembayaran"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600",children:"Total Tagihan:"}),e.jsx("span",{className:"text-lg font-semibold text-gray-900",children:new Intl.NumberFormat("id-ID",{style:"currency",currency:"IDR",minimumFractionDigits:0,maximumFractionDigits:0}).format(i)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600",children:"Saldo Tersedia:"}),e.jsx("span",{className:`font-medium ${(s.balance||0)>=i?"text-green-600":"text-red-600"}`,children:new Intl.NumberFormat("id-ID",{style:"currency",currency:"IDR",minimumFractionDigits:0,maximumFractionDigits:0}).format(s.balance||0)})]}),s.balance&&s.balance<i&&e.jsx("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-3",children:e.jsx("p",{className:"text-sm text-yellow-800",children:"⚠️ Saldo tidak mencukupi. Silakan top up saldo atau pilih metode pembayaran lain."})})]})]}),e.jsx("div",{className:"bg-white rounded-lg border border-gray-200",children:e.jsx(w,{selectedMethod:y,siswa:{balance:s.balance},totalAmount:i,existingTransaction:{exist:!1,uri:""},onSubmit:j,processing:o,errors:l})}),e.jsxs("div",{className:"bg-blue-50 rounded-lg border border-blue-200 p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-blue-900 mb-2",children:"Informasi Pembayaran"}),e.jsxs("div",{className:"space-y-2 text-sm text-blue-800",children:[e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Saldo Tabungan:"})," Pembayaran langsung dari saldo yang tersedia"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Virtual Account:"})," Transfer melalui bank partner yang tersedia"]}),e.jsx("p",{children:"• Pembayaran akan diproses secara otomatis setelah konfirmasi"}),e.jsx("p",{children:"• Bukti pembayaran akan dikirim ke email Anda"})]})]}),e.jsxs("div",{className:"bg-green-50 rounded-lg border border-green-200 p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-green-900 mb-2",children:"Keamanan"}),e.jsxs("div",{className:"space-y-2 text-sm text-green-800",children:[e.jsx("p",{children:"🔒 Semua transaksi dilindungi dengan enkripsi SSL"}),e.jsx("p",{children:"🔒 Data pembayaran Anda aman dan tidak akan dibagikan"}),e.jsx("p",{children:"🔒 Transaksi dipantau 24/7 untuk keamanan"})]})]}),Object.keys(l).length>0&&e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-red-900 mb-2",children:"Error"}),e.jsx("div",{className:"space-y-1",children:Object.entries(l).map(([a,t])=>e.jsx("p",{className:"text-sm text-red-700",children:t},a))})]}),e.jsx("div",{className:"flex justify-center",children:e.jsxs("button",{onClick:d,disabled:o,className:"flex items-center gap-2 px-6 py-3 bg-gray-600 text-white rounded-lg hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(k,{}),"Kembali"]})})]})})};export{V as default};
