import{u as p,K as x,r as g,j as e,S as h}from"./app-DZfefqwY.js";import{A as y}from"./AppLayout-DeG2WwBX.js";import{p as j}from"./index-wh97_X4O.js";import{D as f,A as N,S as w,a as b}from"./Detail-C7BJrx1e.js";import{F as k}from"./file-text-Dy8LJNLd.js";import{B as C,C as v,W as z}from"./wallet-Cq6BJJvQ.js";import{C as n,a as D}from"./clock-2VfAipfR.js";import{C as S}from"./circle-check-big-Cr59orY0.js";/* empty css            */import"./iconBase-Bk-4DJ7c.js";import"./x-DUKJD8Z_.js";import"./createLucideIcon-DVe2WYpF.js";import"./copy-BzZqXC0O.js";import"./circle-alert-C-OnHBie.js";const P=()=>{console.count("Component Render");const{log:c}=p(),{transactions:t,nouid:l}=x().props;c("Data Transaksi : ",t);const[r,i]=g.useState(null),o=s=>{switch(s){case"success":return e.jsx(S,{className:"text-green-500",size:16});case"pending":return e.jsx(D,{className:"text-yellow-500",size:16});case"failed":return e.jsx(n,{className:"text-red-500",size:16});case"canceled":return e.jsx(n,{className:"text-red-500",size:16});default:return null}},m=s=>{switch(s){case"topup":case"deposit":return e.jsx(b,{className:"text-blue-500",size:20});case"payment":case"purchase":return e.jsx(w,{className:"text-purple-500",size:20});case"transfer":return e.jsx(N,{className:"text-orange-500",size:20});case"withdraw":return e.jsx(z,{className:"text-amber-500",size:20});case"bank_transfer":case"credit_card":return e.jsx(v,{className:"text-indigo-500",size:20});default:return e.jsx(C,{className:"text-gray-500",size:20})}},d=s=>parseFloat(s).toLocaleString("id-ID",{style:"currency",currency:"IDR",minimumFractionDigits:0}),u=s=>new Date(s).toLocaleDateString("id-ID",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"});return e.jsx(y,{title:"Riwayat Transaksi",children:e.jsxs("div",{className:"overflow-hidden min-h-screen rounded-lg bg-white shadow-md",children:[e.jsxs("div",{className:"flex items-center justify-between bg-primary px-4 py-4 text-primary-foreground",children:[e.jsxs("button",{onClick:()=>window.history.back(),className:"flex items-center space-x-2",children:[e.jsx(j,{className:"text-primary-foreground"}),e.jsx("span",{children:"Kembali"})]}),e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Riwayat Transaksi"})]}),e.jsx("div",{className:"divide-y",children:t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 bg-gray-50 rounded-lg",children:[e.jsx(k,{className:"w-10 h-10 text-gray-400 mb-3"}),e.jsx("h3",{className:"text-lg font-medium text-gray-500 mb-1",children:"Belum ada transaksi"}),e.jsx("p",{className:"text-gray-400 text-center max-w-md px-4",children:"Anda belum memiliki riwayat transaksi. Semua transaksi akan ditampilkan disini."})]}):t.map(s=>e.jsxs("div",{className:"flex cursor-pointer items-center p-4 transition-colors hover:bg-gray-50",onClick:()=>i(s),children:[e.jsx("div",{className:"mr-3 flex h-10 w-10 items-center justify-center rounded-full bg-gray-100",children:m(s.type||s.payment_type)}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-medium capitalize",children:s.type||s.payment_type.replace("_"," ")}),e.jsx("p",{className:"text-sm text-gray-500",children:s.note||`Order: ${s.order_id}`}),e.jsxs("div",{className:"mt-1 flex items-center text-sm",children:[o(s.status),e.jsx("span",{className:"ml-1 text-gray-500 capitalize",children:s.status})]})]}),e.jsxs("div",{className:`text-right ${s.status==="failed"||s.status==="canceled"?"text-red-600":parseFloat(s.amount)>0?"text-green-600":"text-red-600"}`,children:[e.jsxs("div",{className:"font-medium",children:[parseFloat(s.amount)>0?"+":"",d(s.amount)]}),e.jsx("div",{className:"mt-1 text-xs text-gray-400",children:u(s.created_at)}),s.status==="pending"&&e.jsx("button",{className:"mt-2 inline-block rounded-lg bg-blue-500 px-3 py-1 text-xs font-medium text-white transition hover:bg-blue-600",onClick:a=>{a.stopPropagation(),h.get(`/${l}/payment/${s.order_id}`)},children:"Bayar Sekarang"})]})]},s.order_id))}),r&&e.jsx(f,{transaction:r,onClose:()=>i(null)})]})})};export{P as default};
