PageSourceSearch

https://maasy.ai/assets/AdNetworkPublisher-CMw3RZE2.js

js maasy.ai collected 2026-10-02 00:28:45 UTC 10,174 bytes, 7 lines download raw bytes

1import{ax as q,e as b,u as N,r as v,z as p,j as e,o as l,w as o,B as C,Q as k,aE as F,s as m,f as D,aQ as E,aC as S,aH as y,aI as _,q as w,a_ as $,aX as M,ac as T}from"./index-BwaMfbd5.js";import{u as I}from"./usePlanCapabilities-BfhxK_Xm.js";import{D as j}from"./dollar-sign-AcsFX6va.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new s.Error().stack;t&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[t]="0f670226-35e8-4951-b9b5-5622ecca0c5e",s._sentryDebugIdIdentifier="sentry-dbid-0f670226-35e8-4951-b9b5-5622ecca0c5e")}catch{}})();/**
2 * @license lucide-react v0.462.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 z=q("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);function L(){const{user:s}=b(),{activeBrand:t}=N(),[a,c]=v.useState(!1),{data:i,isLoading:n}=p({queryKey:["publisher-account",s==null?void 0:s.id,t==null?void 0:t.id],queryFn:async()=>{const{data:d}=await m.from("publisher_accounts").select("*").eq("user_id",s.id).eq("project_id",t.id).maybeSingle();return d},enabled:!!(s!=null&&s.id)&&!!(t!=null&&t.id)}),{data:x}=p({queryKey:["pending-payouts",s==null?void 0:s.id],queryFn:async()=>{const{data:d}=await m.from("publisher_pending_payouts").select("amount_usd").eq("user_id",s.id).eq("status","pending");return d||[]},enabled:!!(s!=null&&s.id)}),g=(x==null?void 0:x.reduce((d,u)=>d+(u.amount_usd||0),0))||0;if(n||i!=null&&i.charges_enabled)return null;const f=async()=>{if(t!=null&&t.id){c(!0);try{const{data:d,error:u}=await m.functions.invoke("create-connect-account",{body:{brand_id:t.id,country:"MX"}});if(u)throw u;d!=null&&d.url&&window.open(d.url,"_blank")}catch(d){D.error(d.message||"Error al conectar cuenta")}finally{c(!1)}}};return e.jsx(l,{className:"border-green-500/30 bg-green-500/5",children:e.jsx(o,{className:"py-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-gradient-to-br from-green-500 to-emerald-600 flex items-center justify-center flex-shrink-0",children:e.jsx(z,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("h3",{className:"font-semibold",children:"Conecta tu cuenta bancaria"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Para recibir tus ganancias del Ad Network necesitas conectar tu cuenta bancaria. Solo toma 2 minutos."}),g>0&&e.jsxs("p",{className:"text-sm text-green-400 font-medium",children:["Tienes $",g.toFixed(2)," en ganancias acumuladas — se transferirán automáticamente al completar."]}),(i==null?void 0:i.onboarding_status)==="onboarding"&&e.jsx("p",{className:"text-xs text-amber-400",children:"Onboarding en progreso — complétalo para recibir pagos."}),e.jsxs(C,{onClick:f,disabled:a,size:"sm",className:"mt-2",children:[a?e.jsx(k,{className:"h-4 w-4 animate-spin mr-1.5"}):e.jsx(F,{className:"h-4 w-4 mr-1.5"}),i?"Continuar onboarding":"Conectar cuenta bancaria"]})]})]})})})}function P(){const{user:s}=b(),{activeBrand:t}=N(),{data:a}=p({queryKey:["publisher-account-earnings",s==null?void 0:s.id,t==null?void 0:t.id],queryFn:async()=>{const{data:r}=await m.from("publisher_accounts").select("*").eq("user_id",s.id).eq("project_id",t.id).maybeSingle();return r},enabled:!!(s!=null&&s.id)&&!!(t!=null&&t.id)}),{data:c}=p({queryKey:["publisher-completed-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:r}=await m.from("ad_network_slots").select("*").eq("publisher_project_id",t.id).in("status",["completed","scheduled"]).order("created_at",{ascending:!1}).limit(20);return r||[]},enabled:!!(t!=null&&t.id)}),{data:i}=p({queryKey:["publisher-pending-payouts",s==null?void 0:s.id],queryFn:async()=>{const{data:r}=await m.from("publisher_pending_payouts").select("amount_usd").eq("user_id",s.id).eq("status","pending");return r||[]},enabled:!!(s!=null&&s.id)});if(!(a!=null&&a.charges_enabled))return null;const n=(a==null?void 0:a.total_earned_usd)||0,x=(a==null?void 0:a.total_paid_out_usd)||0,g=(i==null?void 0:i.reduce((r,h)=>r+(h.amount_usd||0),0))||0,f=new Date,d=`${f.getFullYear()}
6-${String(f.getMonth()+1).padStart(2,"0")}`,u=(c==null?void 0:c.filter(r=>{var h;return(h=r.created_at)==null?void 0:h.startsWith(d)}).reduce((r,h)=>r+(h.publisher_payout_usd||0),0))||0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid sm:grid-cols-3 gap-4",children:[e.jsx(l,{children:e.jsxs(o,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs mb-1",children:[e.jsx(E,{className:"h-3.5 w-3.5"})," Este mes"]}),e.jsxs("p",{className:"text-2xl font-bold text-green-400",children:["$",u.toFixed(2)]})]})}),e.jsx(l,{children:e.jsxs(o,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs mb-1",children:[e.jsx(j,{className:"h-3.5 w-3.5"})," Total acumulado"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",n.toFixed(2)]})]})}),e.jsx(l,{children:e.jsxs(o,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs mb-1",children:[e.jsx(S,{className:"h-3.5 w-3.5"})," Pagado"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",x.toFixed(2)]}),g>0&&e.jsxs("p",{className:"text-xs text-amber-400 mt-1",children:["+ $",g.toFixed(2)," pendiente"]})]})})]}),c&&c.length>0&&e.jsxs(l,{children:[e.jsx(y,{children:e.jsx(_,{className:"text-sm",children:"Historial de ganancias"})}),e.jsx(o,{children:e.jsx("div",{className:"space-y-2",children:c.map(r=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-border/30 last:border-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium capitalize",children:r.slot_tier}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(r.created_at).toLocaleDateString("es-MX")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(w,{variant:r.status==="completed"?"default":"secondary",className:"text-xs",children:r.status}),e.jsxs("span",{className:"text-sm font-medium text-green-400",children:["+$",(r.publisher_payout_usd||0).toFixed(2)]})]})]},r.id))})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx($,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Los pagos se transfieren automáticamente a tu cuenta bancaria al completar cada slot."})]})]})}function A(){const s=I(),{user:t}=b(),{data:a}=p({queryKey:["ad-network-publisher-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:n}=await m.from("ad_network_slots").select("*").order("created_at",{ascending:!1}).limit(20);return n||[]},enabled:!!(t!=null&&t.id)&&s.can_receive_ads});if(!s.can_receive_ads)return e.jsx(l,{className:"border-dashed border-muted-foreground/30",children:e.jsxs(o,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(j,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"font-medium mb-1",children:"Monetiza tu newsletter"}),e.jsx("p",{className:"text-xs",children:"Disponible desde el plan Creative. Actualiza para recibir ofertas de anunciantes."})]})});const c=(a==null?void 0:a.filter(n=>n.status==="completed"))||[],i=c.reduce((n,x)=>n+(x.price_usd||0)*(1-(x.commission_pct||20)/100),0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-green-500 to-emerald-600 flex items-center justify-center",children:e.jsx(j,{className:"h-4.5 w-4.5 text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Publisher Dashboard"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ingresos y ofertas de anunciantes para tu newsletter"})]})]}),e.jsx(L,{}),e.jsx(P,{}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-4",children:[e.jsx(l,{children:e.jsxs(o,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs mb-1",children:[e.jsx(j,{className:"h-3.5 w-3.5"})," Earnings totales"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",i.toFixed(2)]})]})}),e.jsx(l,{children:e.jsxs(o,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs mb-1",children:[e.jsx(M,{className:"h-3.5 w-3.5"})," Slots completados"]}),e.jsx("p",{className:"text-2xl font-bold",children:c.length})]})}),e.jsx(l,{children:e.jsxs(o,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs mb-1",children:[e.jsx(T,{className:"h-3.5 w-3.5"})," Pendientes"]}),e.jsx("p",{className:"text-2xl font-bold",children:(a==null?void 0:a.filter(n=>n.status==="pending"||n.status==="scheduled").length)||0})]})})]}),(!a||a.length===0)&&e.jsx(l,{className:"border-dashed",children:e.jsx(o,{className:"py-8 text-center text-muted-foreground text-sm",children:"Aún no has recibido ofertas de anunciantes. Tu newsletter ap
6arecerá en el marketplace cuando tengas suscriptores activos."})}),a&&a.length>0&&e.jsxs(l,{children:[e.jsx(y,{children:e.jsx(_,{className:"text-sm",children:"Historial de Slots"})}),e.jsx(o,{children:e.jsx("div",{className:"space-y-2",children:a.map(n=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-border/30 last:border-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium capitalize",children:n.slot_tier}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(n.created_at).toLocaleDateString("es-MX")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(w,{variant:n.status==="completed"?"default":"secondary",className:"text-xs",children:n.status}),e.jsxs("span",{className:"text-sm font-medium",children:["$",n.price_usd]})]})]},n.id))})})]})]})}export{A as default};
7//# sourceMappingURL=AdNetworkPublisher-CMw3RZE2.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.