PageSourceSearch

https://maasy.ai/assets/AdminPayouts-CLMgXj2r.js

js maasy.ai collected 2026-09-24 13:55:28 UTC 5,465 bytes, 3 lines download raw bytes

1import{aq as I,ds as B,u as F,r as c,s as _,j as e,B as m,A as D,p as A,n as h,ct as C,cu as k,cv as j,cw as i,cx as T,cy as d,ah as L,ai as V,aj as z,ak as H,al as U,am as M,an as O,ao as q,ap as G,e as $}from"./index-CuMcGkrh.js";import{S as J}from"./skeleton-5C_Guuos.js";import{D as K}from"./download-B1BTuZAS.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new n.Error().stack;o&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[o]="517f7d35-eba7-435e-903d-56476af4dd78",n._sentryDebugIdIdentifier="sentry-dbid-517f7d35-eba7-435e-903d-56476af4dd78")}catch{}})();function Y(){const n=I(),{reportId:o}=B(),{user:p,isAdmin:y}=F(),[R,b]=c.useState(!0),[u,S]=c.useState([]),[t,f]=c.useState(null),[N,v]=c.useState(!1);c.useEffect(()=>{if(!p){n("/login?return_to=/admin/payouts");return}if(!y){n("/");return}w()},[p,y]),c.useEffect(()=>{o&&u.length&&f(u.find(s=>s.id===o)||null)},[o,u]);async function w(){b(!0);const{data:s}=await _.from("payout_reports").select("*").order("created_at",{ascending:!1});S(s||[]),b(!1)}async function E(s){v(!0);try{const{data:l,error:a}=await _.functions.invoke("execute-payout",{body:{report_id:s}});if(a)throw a;$.success(l!=null&&l.dry_run?"Dispersión simulada (dry-run)":"Dispersión iniciada"),await w(),f(null),n("/admin/payouts")}catch(l){$.error(l.message)}finally{v(!1)}}function P(s){const a=["partner_id,name,country,amount_usd,dlocal_beneficiary_id",...(s.breakdown||[]).map(x=>`${x.partner_id},${x.name},${x.country},${x.amount_usd},${x.dlocal_beneficiary_id}`)].join(`
2`),r=new Blob([a],{type:"text/csv"}),g=document.createElement("a");g.href=URL.createObjectURL(r),g.download=`payout-${s.period}.csv`,g.click()}if(R)return e.jsx("div",{className:"container py-12",children:e.jsx(J,{className:"h-96"})});if(t){const s=t.breakdown||[],l=s.reduce((a,r)=>(a[r.country]=(a[r.country]||0)+Number(r.amount_usd),a),{});return e.jsxs("div",{className:"container max-w-6xl mx-auto py-8 space-y-6",children:[e.jsxs(m,{variant:"ghost",size:"sm",onClick:()=>{f(null),n("/admin/payouts")},children:[e.jsx(D,{className:"w-4 h-4 mr-2"})," Volver"]}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold",children:["Reporte ",t.period]}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:["Total $",Number(t.total_usd).toFixed(2)," · ",t.partners_count," partners ·",e.jsx(A,{variant:"outline",className:"ml-2",children:t.status})]})]}),e.jsxs(h,{className:"p-5",children:[e.jsx("h3",{className:"font-semibold mb-3",children:"Desglose por país"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:Object.entries(l).map(([a,r])=>e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:a}),e.jsxs("div",{className:"text-xl font-bold",children:["$",r.toFixed(2)]})]},a))})]}),e.jsx(h,{children:e.jsxs(C,{children:[e.jsx(k,{children:e.jsxs(j,{children:[e.jsx(i,{children:"Partner"}),e.jsx(i,{children:"País"}),e.jsx(i,{children:"Beneficiary ID"}),e.jsx(i,{className:"text-right",children:"Monto"})]})}),e.jsx(T,{children:s.map((a,r)=>e.jsxs(j,{children:[e.jsx(d,{children:a.name}),e.jsx(d,{children:a.country}),e.jsx(d,{className:"font-mono text-xs",children:a.dlocal_beneficiary_id}),e.jsxs(d,{className:"text-right font-semibold",children:["$",Number(a.amount_usd).toFixed(2)]})]},r))})]})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(m,{variant:"outline",onClick:()=>P(t),children:[e.jsx(K,{className:"w-4 h-4 mr-2"})," Descargar CSV"]}),t.status==="pending"&&e.jsxs(L,{children:[e.jsx(V,{asChild:!0,children:e.jsx(m,{children:"Aprobar y dispersar"})}
2),e.jsxs(z,{children:[e.jsxs(H,{children:[e.jsx(U,{children:"Confirmar dispersión"}),e.jsxs(M,{children:["Vas a dispersar $",Number(t.total_usd).toFixed(2)," a ",t.partners_count," partners. Se enviará un wire desde Mercury a dLocal. Esta acción no se puede deshacer."]})]}),e.jsxs(O,{children:[e.jsx(q,{children:"Cancelar"}),e.jsx(G,{onClick:()=>E(t.id),disabled:N,children:N?"Procesando…":"Confirmar dispersión"})]})]})]})]})]})}return e.jsxs("div",{className:"container max-w-6xl mx-auto py-8 space-y-6",children:[e.jsxs(m,{variant:"ghost",size:"sm",onClick:()=>n("/admin"),children:[e.jsx(D,{className:"w-4 h-4 mr-2"})," Admin"]}),e.jsx("h1",{className:"text-3xl font-bold",children:"Pagos a partners"}),u.length===0?e.jsxs(h,{className:"p-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground",children:"Aún no hay reportes generados."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Se generan automáticamente el día 1 de cada mes."})]}):e.jsx(h,{children:e.jsxs(C,{children:[e.jsx(k,{children:e.jsxs(j,{children:[e.jsx(i,{children:"Período"}),e.jsx(i,{children:"Partners"}),e.jsx(i,{children:"Total USD"}),e.jsx(i,{children:"Estado"}),e.jsx(i,{className:"text-right",children:"Acción"})]})}),e.jsx(T,{children:u.map(s=>e.jsxs(j,{children:[e.jsx(d,{className:"font-mono",children:s.period}),e.jsx(d,{children:s.partners_count}),e.jsxs(d,{className:"font-semibold",children:["$",Number(s.total_usd).toFixed(2)]}),e.jsx(d,{children:e.jsx(A,{variant:"outline",children:s.status})}),e.jsx(d,{className:"text-right",children:e.jsx(m,{size:"sm",variant:"outline",onClick:()=>n(`/admin/payouts/${s.id}`),children:s.status==="pending"?"Revisar":"Ver"})})]},s.id))})]})})]})}export{Y as default};
3//# sourceMappingURL=AdminPayouts-CLMgXj2r.js.map

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.