PageSourceSearch

https://www.tubeboostr.ai/assets/AdminAffiliates-DeN9Xpy8.js

js tubeboostr.ai collected 2026-10-05 14:24:36 UTC 5,006 bytes, 1 lines download raw bytes

1import{ab as T,r as D,n as E,j as e,e as M,B as c,X as _,U as q,f as p,g as j}from"./index-DnFRH9_L.js";import{C as g,a as f,b as w,d as N,c as b}from"./card-D-MVnJuk.js";import{T as B,a as F,b as y,c as t,d as P,e as a}from"./table-EG_2K3dp.js";import{B as o}from"./badge-8sAUhzBX.js";import{D as R,a as Q,b as U,c as u}from"./dropdown-menu-kKmTumGV.js";import{u as z}from"./useMutation-CzkBmSGH.js";import{E as H}from"./ellipsis-CvPS-Nzc.js";import{C as L}from"./check-B7CpPNb4.js";import{C as I}from"./clock-C_bhf0UT.js";import"./index-BnL4qY8P.js";import"./Combination-kISE9yI6.js";import"./index-Bb-fnLL9.js";import"./circle-DRKgxEhK.js";function ae(){const C=T(),[n,h]=D.useState("all"),{data:v,isLoading:A}=E({queryKey:["admin-affiliates"],queryFn:async()=>{const{data:s,error:i}=await p.from("affiliates").select("*").order("created_at",{ascending:!1}).limit(100);if(i)throw i;return s||[]}}),l=z({mutationFn:async({id:s,status:i})=>{const{error:x}=await p.from("affiliates").update({status:i}).eq("id",s);if(x)throw x},onSuccess:()=>{j.success("Affiliate status updated"),C.invalidateQueries({queryKey:["admin-affiliates"]})},onError:s=>{j.error(s.message||"Failed to update status")}}),m=s=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(s),S=s=>{switch(s){case"approved":return e.jsx(o,{className:"bg-green-500/10 text-green-400 hover:bg-green-500/20",children:"Approved"});case"suspended":return e.jsx(o,{className:"bg-red-500/10 text-red-400 hover:bg-red-500/20",children:"Suspended"});default:return e.jsx(o,{className:"bg-yellow-500/10 text-yellow-400 hover:bg-yellow-500/20",children:"Pending"})}};if(A)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(M,{className:"w-8 h-8 animate-spin text-red-500"})});const r=v||[],k=r.filter(s=>s.status==="pending").length,d=n==="all"?r:r.filter(s=>s.status===n);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Manage Affiliates"}),e.jsx("p",{className:"text-muted-foreground",children:"Approve, suspend, or review affiliate accounts"})]}),e.jsxs(g,{children:[e.jsxs(f,{children:[e.jsx(w,{children:"Quick Actions"}),e.jsx(N,{children:"Affiliate review shortcuts"})]}),e.jsxs(b,{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(c,{size:"sm",variant:n==="pending"?"default":"outline",onClick:()=>h("pending"),children:["Review Pending (",k,")"]}),e.jsxs(c,{size:"sm",variant:n==="all"?"default":"outline",onClick:()=>h("all"),children:["Show All (",r.length,")"]})]}),e.jsx("a",{href:"/admin/payouts",className:"block p-3 rounded-lg bg-accent/50 hover:bg-accent transition-colors",children:e.jsx("span",{className:"font-medium",children:"Process Affiliate Payout Requests"})})]})]}),e.jsxs(g,{children:[e.jsxs(f,{children:[e.jsx(w,{children:"All Affiliates"}),e.jsxs(N,{children:["Showing ",d.length," of ",r.length," affiliates"]})]}),e.jsx(b,{children:d.length>0?e.jsxs(B,{children:[e.jsx(F,{children:e.jsxs(y,{children:[e.jsx(t,{children:"Referral Code"}),e.jsx(t,{children:"Email"}),e.jsx(t,{children:"Status"}),e.jsx(t,{children:"Clicks"}),e.jsx(t,{children:"Earnings"}),e.jsx(t,{children:"Pending"}),e.jsx(t,{children:"Joined"}),e.jsx(t,{className:"text-right",children:"Actions"})]})}),e.jsx(P,{children:d.map(s=>e.jsxs(y,{children:[e.jsx(a,{className:"font-mono font-medium",children:s.referral_code}),e.jsx(a,{children:s.payout_email||"-"}),e.jsx(a,{children:S(s.status)}),e.jsx(a,{children:s.click_count??0}),e.jsx(a,{className:"text-green-400",children:m(Number(s.total_earnings))}),e.jsx(a,{className:"text-orange-400",children:m(Number(s.pending_balance))}),e.jsx(a,{children:new Date(s.created_at).toLocaleDateString()}),e.jsx(a,{className:"text-right",children:e.jsxs(R,{children:[e.jsx(Q,{asChild:!0,children:e.jsx(c,{variant:"ghost",size:"icon",children:e.jsx(H,{className:"w-4 h-4"})})}),e.jsxs(U,{align:"end",children:[e.jsxs(u,{onClick:()=>l.mutate({id:s.id,status:"approved"}),disabled:s.status==="approved",children:[e.jsx(L,{className:"w-4 h-4 mr-2 text-green-400"}),"Approve"]}),e.jsxs(u,{onClick:()=>l.mutate({id:s.id,status:"pending"}),disabled:s.status==="pending",children:[e.jsx(I,{className:"w-4 h-4 mr-2 text-yellow-400"}),"Set Pending"]}),e.jsxs(u,{onClick:()=>l.mutate({id:s.id,status:"suspended"}),disabled:s.status==="suspended",className:"text-destructive",children:[e.jsx(_,{className:"w-4 h-4 mr-2"}),"Suspend"]})]})]})})]},s.id))})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(q,{className:"w-12 h-12 text-muted-foreground mx-auto mb-3"}),e.jsx("p",{className:"text-lg font-medium text-foreground mb-1",children:r.length===0?"N
1o affiliates yet":"No affiliates match this filter"}),e.jsx("p",{className:"text-muted-foreground",children:r.length===0?"Affiliates will appear here when they sign up":"Try switching filters to view other affiliate statuses."})]})})]})]})}export{ae 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.