PageSourceSearch

https://flfproleague.com/assets/FinancialDashboard-CZQivA_A.js

js flfproleague.com collected 2026-10-05 23:12:24 UTC 15,138 bytes, 7 lines download raw bytes

1import{J as H,r as g,o as T,j as t,R as Q,au as J,T as X,Q as Y,l as W,b as j,k as N}from"./index-CtR2Cm7C.js";import{g as R,b as Z,f as E,P as v,C as ee}from"./paymentData-BSdRgjit.js";import{D as te}from"./download-BN7BUjrI.js";import{C as se}from"./clock-Crn-bV_Q.js";import{T as ae}from"./triangle-alert-BSj5rZQS.js";import{C as re}from"./circle-arrow-up-C2j0vZQC.js";import{C as ne}from"./circle-check-big-CtQTi4fB.js";import{C as le}from"./circle-x-DEaQAqwj.js";import{f as D}from"./format-CAy5MAkn.js";/**
2 * @license lucide-react v0.475.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const oe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]],ie=H("CircleArrowDown",oe),i=({label:x,value:y,sub:c,icon:_,color:f})=>t.jsxs("div",{className:"p-4 rounded-2xl bg-white/[0.04] border border-white/[0.06]",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center ${f}`,children:t.jsx(_,{className:"w-3.5 h-3.5 text-white"})}),t.jsx("span",{className:"text-[10px] text-white/40 uppercase tracking-wide font-semibold",children:x})]}),t.jsx("p",{className:"text-xl font-black text-white",children:y}),c&&t.jsx("p",{className:"text-[11px] text-white/30 mt-0.5",children:c})]});function fe(){const[x,y]=g.useState(""),[c,_]=g.useState("all"),[f,ce]=g.useState("all"),[k,q]=g.useState("all"),[m,U]=g.useState("overview"),{data:o=[],isLoading:A,refetch:C}=T({queryKey:["payment-transactions"],queryFn:()=>j.entities.PaymentTransaction.list("-created_date",500)}),{data:O=[]}=T({queryKey:["all-registrations-finance"],queryFn:()=>j.entities.TournamentRegistration.list("-created_date",500)}),{data:I=[]}=T({queryKey:["all-tournaments-finance"],queryFn:()=>j.entities.Tournament.filter({entry_fee_type:"paid"})}),d=o.filter(e=>e.status==="paid"),h=o.filter(e=>e.status==="pending"),P=o.filter(e=>e.status==="refunded"),L=o.filter(e=>["chargeback","disputed"].includes(e.status)),p={},w={};d.forEach(e=>{p[e.method]=(p[e.method]||0)+(e.total_charged||0),w[e.currency]=(w[e.currency]||0)+(e.total_charged||0)});const u=d.reduce((e,s)=>e+(s.total_charged||0),0),$=d.reduce((e,s)=>e+(s.commission_amount||0),0),S=P.reduce((e,s)=>e+(s.refund_amount||s.amount||0),0),M=h.reduce((e,s)=>e+(s.total_charged||0),0),F=o.filter(e=>{const s=!x||[e.team_name,e.captain_email,e.tournament_name,e.reference,e.external_id].some(b=>b?.toLowerCase().includes(x.toLowerCase())),a=c==="all"||e.status===c,r=f==="all"||e.method===f,l=k==="all"||e.currency===k;return s&&a&&r&&l}),z=()=>{const e=["Fecha","Equipo","Email","Torneo","Tipo","Método","Moneda","Monto","Comisión","Total","Estado","Referencia"],s=F.map(n=>[n.created_date?D(new Date(n.created_date),"yyyy-MM-dd HH:mm"):"",n.team_name,n.captain_email,n.tournament_name,n.type,n.method,n.currency,n.amount,n.commission_amount,n.total_charged,n.status,n.reference]),a=[e,...s].map(n=>n.map(G=>`"${G??""}"`).join(",")).join(`
7`),r=new Blob([a],{type:"text/csv"}),l=URL.createObjectURL(r),b=document.createElement("a");b.href=l,b.download="flf_transactions.csv",b.click()},B=async(e,s)=>{try{const a=await j.functions.invoke("manageTournamentPayment",{action:"approve_payment",transaction_id:e.id,registration_id:s?.id,idempotency_key:crypto.randomUUID()});if(!a.data?.success)throw new Error(a.data?.error||"No se pudo aprobar el pago");N.success("Pago aprobado y registro confirmado"),C()}catch(a){const r=a.response?.data?.error||a.message||"No se pudo aprobar el pago",l=a.response?.data?.request_id;N.error(l?`${r} · Ref. ${l}`:r)}},K=async(e,s)=>{try{const a=await j.functions.invoke("manageTournamentPayment",{action:"reject_payment",transaction_id:e.id,registration_id:s?.id,idempotency_key:crypto.randomUUID()});if(!a.data?.success)throw new Error(a.data?.error||"No se pudo rechazar el pago");N.success("Pago rechazado"),C()}catch(a){const r=a.response?.data?.error||a.message||"No se pudo rechazar el pago",l=a.response?.data?.request_id;N.error(l?`${r} · Ref. ${l}`:r)}},V=[{id:"overview",label:"Resumen"},{id:"transactions",label:"Transacciones"},{id:"pending_review",label:`Pendientes (${h.length})`},{id:"analytics",label:"Analytics"}];return t.jsx("div",{className:"min-h-screen bg-black text-white p-4 md:p-8",children:t.jsxs("div",{className:"max-w-7xl mx-auto",children:[t.jsxs("div",{className:"flex items-center justify-between mb-6",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-black text-white",children:"Panel Financiero"}),t.jsx("p",{className:"text-sm text-white/40",children:"FLF PRO LEAGUE — Economía de torneos"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{"aria-label":"Actualizar",onClick:C,className:"w-9 h-9 flex items-center justify-center rounded-xl bg-white/[0.05] hover:bg-white/[0.09] transition-all border border-white/[0.07]",children:t.jsx(Q,{className:"w-4 h-4 text-white/50"})}),t.jsxs("button",{onClick:z,className:"flex items-center gap-2 px-4 py-2 rounded-xl bg-green-500/20 border border-green-500/30 text-green-300 text-sm font-bold hover:bg-green-500/30 transition-all",children:[t.jsx(te,{className:"w-4 h-4"})," Exportar CSV"]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-6",children:[t.jsx(i,{label:"Ingresos totales",value:`$${u.toFixed(2)}`,sub:`${d.length} pagos`,icon:J,color:"bg-green-500"}),t.jsx(i,{label:"Pendientes",value:`$${M.toFixed(2)}`,sub:`${h.length}
7 pendientes`,icon:se,color:"bg-amber-500"}),t.jsx(i,{label:"Reembolsado",value:`$${S.toFixed(2)}`,sub:`${P.length} reembolsos`,icon:ie,color:"bg-purple-500"}),t.jsx(i,{label:"Disputas",value:L.length.toString(),sub:"chargebacks + disputas",icon:ae,color:"bg-red-500"})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-6",children:[t.jsx(i,{label:"Comisiones",value:`$${$.toFixed(2)}`,sub:"total comisiones",icon:X,color:"bg-blue-500"}),t.jsx(i,{label:"Torneos de pago",value:I.length.toString(),sub:"con inscripción",icon:Y,color:"bg-cyan-500"}),t.jsx(i,{label:"Métodos activos",value:Object.keys(p).length.toString(),sub:"en uso",icon:re,color:"bg-indigo-500"})]}),t.jsx("div",{className:"flex gap-1 p-1 bg-white/[0.04] rounded-2xl border border-white/[0.06] mb-5 overflow-x-auto",children:V.map(e=>t.jsx("button",{onClick:()=>U(e.id),className:`px-4 py-2 rounded-xl text-xs font-bold whitespace-nowrap transition-all ${m===e.id?"bg-white text-black":"text-white/50 hover:text-white/70"}`,children:e.label},e.id))}),m==="overview"&&t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"p-4 rounded-2xl bg-white/[0.04] border border-white/[0.06]",children:[t.jsx("h3",{className:"text-sm font-black text-white mb-3",children:"Por método de pago"}),t.jsxs("div",{className:"space-y-2",children:[Object.entries(p).sort((e,s)=>s[1]-e[1]).map(([e,s])=>{const a=R(e),r=u>0?s/u*100:0;return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("span",{className:"text-xs text-white/70 flex items-center gap-1",children:[t.jsx("span",{children:a.icon}),a.label]}),t.jsxs("span",{className:"text-xs text-white font-bold",children:["$",s.toFixed(2)]})]}),t.jsx("div",{className:"h-1.5 bg-white/[0.05] rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-green-500 rounded-full",style:{width:`${r}%`}})})]},e)}),Object.keys(p).length===0&&t.jsx("p",{className:"text-white/30 text-xs text-center py-4",children:"Sin datos aún"})]})]}),t.jsxs("div",{className:"p-4 rounded-2xl bg-white/[0.04] border border-white/[0.06]",children:[t.jsx("h3",{className:"text-sm font-black text-white mb-3",children:"Por moneda"}),t.jsxs("div",{className:"space-y-2",children:[Object.entries(w).sort((e,s)=>s[1]-e[1]).map(([e,s])=>{const a=Z(e);return t.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-white/[0.04]",children:[t.jsxs("span",{className:"text-xs text-white/70",children:[a.flag," ",e]}),t.jsx("span",{className:"text-xs font-black text-white",children:E(s,e)})]},e)}),Object.keys(w).length===0&&t.jsx("p",{className:"text-white/30 text-xs text-center py-4",children:"Sin datos aún"})]})]}),t.jsxs("div",{className:"p-4 rounded-2xl bg-white/[0.04] border border-white/[0.06] md:col-span-2",children:[t.jsx("h3",{className:"text-sm font-black text-white mb-3",children:"Torneos con más ingresos"}),t.jsxs("div",{className:"space-y-2",children:[Object.entries(d.reduce((e,s)=>(s.tournament_name&&(e[s.tournament_name]=(e[s.tournament_name]||0)+(s.total_charged||0)),e),{})).sort((e,s)=>s[1]-e[1]).slice(0,5).map(([e,s])=>t.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-white/[0.04]",children:[t.jsx("span",{className:"text-xs text-white/70 truncate flex-1",children:e}),t.jsxs("span",{className:"text-xs font-black text-green-400",children:["$",s.toFixed(2)]})]},e)),d.length===0&&t.jsx("p",{className:"text-white/30 text-xs text-center py-4",children:"Sin ingresos registrados"})]})]})]}),m==="transactions"&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[t.jsxs("div",{className:"relative flex-1 min-w-48",children:[t.jsx(W,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-white/30"}),t.jsx("input",{value:x,onChange:e=>y(e.target.value),placeholder:"Buscar equipo, email, torneo...",className:"w-full pl-8 pr-3 py-2 bg-white/[0.04] border border-white/[0.07] rounded-xl text-xs text-white placeholder:text-white/25 outline-none"})]}),t.jsxs("select",{value:c,onChange:e=>_(e.target.value),className:"bg-white/[0.04] border border-white/[0.07] rounded-xl px-3 py-2 text-xs text-white outline-none",children:[t.jsx("option",{value:"all",children:"Todos los estados"}),Object.entries(v).map(([e,s])=>t.jsx("option",{value:e,children:s.label},e))]}),t.jsxs("select",{value:k,onChange:e=>q(e.target.value),className:"bg-white/[0.04] border border-white/[0.07] rounded-xl px-3 py-2 text-xs text-white outline-none",children:[t.jsx("option",{value:"all",children:"Todas las monedas"}),ee.slice(0,20).map(e=>t.jsxs("option",{value:e.code,children:[e.flag," ",e.code]},e.code))]})]}),t.jsxs("div",{className:"space-y-2",children:[A&&t.jsx("div",{className:"text-center py-8 text-white/30 text-sm",children:"Cargando..."}),F.map(e=>
7{const s=R(e.method),a=v[e.status]||v.pending;return t.jsxs("div",{className:"p-3 rounded-xl bg-white/[0.03] border border-white/[0.06] flex items-center gap-3",children:[t.jsx("span",{className:"text-xl flex-shrink-0",children:s.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[t.jsx("p",{className:"text-xs font-bold text-white truncate",children:e.team_name||"—"}),t.jsx("span",{className:`text-[9px] font-black px-1.5 py-0.5 rounded-full ${a.bg} ${a.color}`,children:a.label})]}),t.jsxs("p",{className:"text-[10px] text-white/30 truncate",children:[e.tournament_name," • ",s.label," • ",e.reference]})]}),t.jsxs("div",{className:"text-right flex-shrink-0",children:[t.jsx("p",{className:"text-sm font-black text-white",children:E(e.total_charged||e.amount,e.currency)}),t.jsx("p",{className:"text-[10px] text-white/30",children:e.created_date?D(new Date(e.created_date),"dd/MM/yy"):""})]})]},e.id)}),!A&&F.length===0&&t.jsx("p",{className:"text-center text-white/30 py-8 text-sm",children:"Sin transacciones"})]})]}),m==="pending_review"&&t.jsxs("div",{className:"space-y-3",children:[h.length===0&&t.jsx("p",{className:"text-center py-12 text-white/30",children:"Sin pagos pendientes de revisión"}),h.map(e=>{const s=R(e.method),a=O.find(r=>r.id===e.registration_id);return t.jsxs("div",{className:"p-4 rounded-2xl bg-amber-500/10 border border-amber-500/25",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsx("span",{className:"text-2xl",children:s.icon}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm font-black text-white",children:e.team_name}),t.jsxs("p",{className:"text-[11px] text-white/50",children:[e.tournament_name," • ",s.label]}),t.jsx("p",{className:"text-[11px] text-amber-300/70",children:e.captain_email})]}),t.jsxs("div",{className:"text-right",children:[t.jsx("p",{className:"text-lg font-black text-amber-300",children:E(e.total_charged||e.amount,e.currency)}),t.jsx("p",{className:"text-[10px] text-white/30",children:e.reference})]})]}),e.proof_url&&t.jsx("a",{href:e.proof_url,target:"_blank",rel:"noreferrer",className:"block mb-3 text-[11px] text-blue-400 underline truncate",children:"Ver comprobante"}),e.notes&&t.jsx("p",{className:"text-[11px] text-white/40 mb-3 italic",children:e.notes}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("button",{onClick:()=>B(e,a),className:"flex-1 flex items-center justify-center gap-1.5 py-2 rounded-xl bg-green-500 text-black text-xs font-black hover:bg-green-600 transition-all",children:[t.jsx(ne,{className:"w-3.5 h-3.5"})," Aprobar"]}),t.jsxs("button",{onClick:()=>K(e,a),className:"flex-1 flex items-center justify-center gap-1.5 py-2 rounded-xl bg-red-500/20 border border-red-500/30 text-red-300 text-xs font-black hover:bg-red-500/30 transition-all",children:[t.jsx(le,{className:"w-3.5 h-3.5"})," Rechazar"]})]})]},e.id)})]}),m==="analytics"&&t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"p-4 rounded-2xl bg-white/[0.04] border border-white/[0.06]",children:[t.jsx("h3",{className:"text-sm font-black text-white mb-3",children:"Estado de pagos"}),t.jsx("div",{className:"space-y-2",children:Object.entries(v).map(([e,s])=>{const a=o.filter(l=>l.status===e).length;if(!a)return null;const r=o.length>0?a/o.length*100:0;return t.jsxs("div",{children:[t.jsxs("div",{className:"flex justify-between mb-0.5",children:[t.jsxs("span",{className:`text-[11px] ${s.color}`,children:[s.icon," ",s.label]}),t.jsxs("span",{className:"text-[11px] text-white/50",children:[a," (",r.toFixed(0),"%)"]})]}),t.jsx("div",{className:"h-1.5 bg-white/[0.05] rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full rounded-full bg-white/30",style:{width:`${r}%`}})})]},e)})})]}),t.jsxs("div",{className:"p-4 rounded-2xl bg-white/[0.04] border border-white/[0.06]",children:[t.jsx("h3",{className:"text-sm font-black text-white mb-3",children:"Flujo financiero"}),t.jsx("div",{className:"space-y-2",children:[{label:"Ingresos brutos",value:u,color:"text-green-400"},{label:"Comisiones",value:$,color:"text-blue-400"},{label:"Reembolsado",value:S,color:"text-purple-400"},{label:"Pendiente cobro",value:M,color:"text-amber-400"},{label:"Neto estimado",value:u-S-$,color:"text-white"}].map(e=>t.jsxs("div",{className:"flex justify-between py-1.5 border-b border-white/[0.04]",children:[t.jsx("span",{className:"text-xs text-white/50",children:e.label}),t.jsxs("span",{className:`text-xs font-black ${e.color}`,children:["$",e.value.toFixed(2)," USD"]})]},e.label))})]})]})]})})}export{fe 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.