1import{y as D,l as B,a as H,n as j,j as e,am as u,B as T,U as v,e as o,i as z,Q as p,R as y,E as K,G as _,I as g,J as N,C as t,b as i,c as l,d as r,bJ as Q,x as V,f as I,a5 as x,aP as L,aQ as M,aR as f,aS as n,aT as P,aU as c,o as J}from"./index-Byg2HWAE.js";import{r as S}from"./vendor-Qgthw7N1.js";import{U as W}from"./user-plus-DIMyHSLg.js";import{L as G}from"./link-2-CaYPiQ6T.js";import{C as X}from"./copy-DV8e8Olv.js";/** 2 * @license lucide-react v0.453.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=D("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);/** 7 * @license lucide-react v0.453.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const A=D("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);function le(){B();const{toast:b}=H(),[R,$]=S.useState("overview"),[F,w]=S.useState(!1),{data:a,isLoading:E}=j({queryKey:["/api/affiliate/stats"]}),{data:m=[],isLoading:k}=j({queryKey:["/api/affiliate/referrals"]}),{data:C=[],isLoading:Y}=j({queryKey:["/api/affiliate/payouts"]}),{data:h=[],isLoading:q}=j({queryKey:["/api/affiliate/analytics"]}),O=async()=>{if(a!=null&&a.referralLink)try{await navigator.clipboard.writeText(a.referralLink),w(!0),b({title:"Referral link copied to clipboard!"}),setTimeout(()=>w(!1),2e3)}catch{b({title:"Failed to copy link",description:"Please copy the link manually",variant:"destructive"})}},U=s=>{switch(s){case"active":return"default";case"pending_review":return"secondary";case"rejected":return"destructive";case"suspended":return"outline";default:return"outline"}};return E?e.jsx("div",{className:"container-mobile py-8",children:e.jsxs("div",{className:"animate-pulse space-y-6",children:[e.jsx("div",{className:"h-8 bg-gray-200 rounded w-1/3"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[1,2,3,4].map(s=>e.jsx("div",{className:"h-32 bg-gray-200 rounded"},s))})]})}):a?e.jsxs("div",{className:"container-mobile py-8",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-8",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(v,{className:"h-6 w-6 sm:h-8 sm:w-8 text-blue-600"}),"Affiliate Dashboard"]}),e.jsx("p",{className:"text-sm sm:text-base text-gray-600 mt-2",children:"Track your referrals and earnings"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{variant:U(a.status),className:"capitalize",children:a.status.replace("_"," ")}),a.status==="pending_review"&&e.jsxs(o,{variant:"secondary",children:[e.jsx(z,{className:"h-3 w-3 mr-1"}),"Pending Review"]})]})]}),a.status==="pending_review"&&e.jsxs(p,{className:"mb-6",children:[e.jsx(u,{className:"h-4 w-4"}),e.jsx(y,{children:"Your affiliate application is under review. You'll receive an email notification once it's approved."})]}),a.status==="rejected"&&e.jsxs(p,{variant:"destructive",className:"mb-6",children:[e.jsx(u,{className:"h-4 w-4"}),e.jsx(y,{children:"Your affiliate application was not approved. Please contact support if you have questions."})]}),a.status==="suspended"&&e.jsxs(p,{variant:"destructive",className:"mb-6",children:[e.jsx(u,{className:"h-4 w-4"}),e.jsx(y,{children:"Your affiliate account has been suspended. Please contact support for more information."})]}),e.jsxs(K,{value:R,onValueChange:$,className:"space-y-6",children:[e.jsxs(_,{children:[e.jsx(g,{value:"overview",children:"Overview"}),e.jsx(g,{value:"referrals",children:"Referrals"}),e.jsx(g,{value:"payouts",children:"Payouts"}),e.jsx(g,{value:"analytics",children:"Analytics"})]}),e.jsxs(N,{value:"overview",className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[e.jsxs(t,{children:[e.jsxs(i,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(l,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(Z,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(r,{children:[e.jsx("div",{className:"text-2xl font-bold",children:a.totalClicks.toLocaleStr
11ing()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link visits"})]})]}),e.jsxs(t,{children:[e.jsxs(i,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(l,{className:"text-sm font-medium",children:"Signups"}),e.jsx(W,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(r,{children:[e.jsx("div",{className:"text-2xl font-bold",children:a.totalSignups}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.totalClicks>0?`${(a.totalSignups/a.totalClicks*100).toFixed(1)}% conversion`:"No clicks yet"})]})]}),e.jsxs(t,{children:[e.jsxs(i,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(l,{className:"text-sm font-medium",children:"Paid Conversions"}),e.jsx(Q,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(r,{children:[e.jsx("div",{className:"text-2xl font-bold",children:a.totalConversions}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.totalSignups>0?`${(a.totalConversions/a.totalSignups*100).toFixed(1)}% of signups`:"No signups yet"})]})]}),e.jsxs(t,{children:[e.jsxs(i,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(l,{className:"text-sm font-medium",children:"Total Earned"}),e.jsx(V,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(r,{children:[e.jsxs("div",{className:"text-2xl font-bold text-green-600",children:["$",(a.totalCommissionOwed+a.totalCommissionPaid).toFixed(2)]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.commissionRate,"% commission rate"]})]})]})]}),e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsxs(l,{className:"flex items-center gap-2",children:[e.jsx(G,{className:"h-5 w-5"}),"Your Referral Link"]}),e.jsxs("p",{className:"text-sm text-gray-600",children:["Share this link to earn ",a.commissionRate,"% commission on referrals"]})]}),e.jsxs(r,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-lg",children:[e.jsx("code",{className:"flex-1 text-sm font-mono break-all",children:a.referralLink}),e.jsx(T,{size:"sm",variant:"outline",onClick:O,disabled:!a.referralLink,children:F?e.jsx(I,{className:"h-4 w-4"}):e.jsx(X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Referral Code:"})," ",a.referralCode]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Payout Threshold:"})," $",a.payoutThreshold]})]}),a.totalCommissionOwed>=a.payoutThreshold&&e.jsxs(p,{children:[e.jsx(A,{className:"h-4 w-4"}),e.jsxs(y,{children:["You have ",e.jsxs("strong",{children:["$",a.totalCommissionOwed.toFixed(2)]})," ready for payout!",a.nextPayoutDate&&e.jsxs("span",{children:[" Next payout: ",x(new Date(a.nextPayoutDate),"MMM dd, yyyy")]})]})]})]})]}),e.jsxs(t,{children:[e.jsx(i,{children:e.jsx(l,{children:"Recent Referrals"})}),e.jsx(r,{children:k?e.jsx("div",{className:"text-center py-4",children:"Loading..."}):m.slice(0,5).length>0?e.jsx("div",{className:"space-y-3",children:m.slice(0,5).map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.userEmail}),e.jsxs("div",{className:"text-sm text-gray-500",children:["Signed up ",x(new Date(s.signupDate),"MMM dd, yyyy")]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx(o,{variant:s.status==="converted"?"default":"secondary",children:s.status}),s.commissionEarned>0&&e.jsxs("div",{className:"text-sm font-medium text-green-600",children:["+$",s.commissionEarned.toFixed(2)]})]})]},s.id))}):e.jsxs("div",{className:"text-center py-8 text-gray-500",children:[e.jsx(v,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"No referrals yet"}),e.jsx("p",{className:"text-sm",children:"Share your referral link to get started"})]})})]})]}),e.jsx(N,{value:"referrals",className:"space-y-6",children:e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(l,{children:"All Referrals"}),e.jsx("p",{className:"text-sm text-gray-600",children:"Track your referred users and their conversion status"})]}),e.jsx(r,{children:k?e.jsx("div",{className:"text-center py-8",children:"Loading referrals..."}):m.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(L,{children:[e.jsx(M,{children:e.jsxs(f,{children:[e.jsx(n,{children:"User"}),e.jsx(n,{children:"Signup Date"}),e.jsx(n,{children:"Status"}),e.jsx(n,{children:"Conversion"}),e.jsx(n,{children:"Commission"})]})}),e.jsx(P,{children:m.map(s=>e.jsxs(f,{children:[e.jsx(c,{children:s.userEmail}),e.jsx(c,{children:x(new Date(s.signupDate),"MMM dd, yyyy")}),e.jsx(c,{children:e.jsx(o,{variant:s.status==="converted"?"default":s.status==="signup"?"secondary":"outline",children:s.status})}),e.jsx(c,{children:s.conversionDate?e.jsxs("div",{children:[e.jsx("div",{children:x(new Date(s.conversionDate),"MMM dd, yyyy")}),s.conversionAmount&&e.jsxs("div",{className:"text-sm text-gray-500",children:["$",s.conversionAmount.toFixed(2)]})]}):e.jsx("span",{className:"text-gray-400",children:"â"})}),e.jsx(c,{children:s.commissionEarned>0?e.jsxs("span",{className:"font-medium text-green-600",children:["+$",s.commissionEarned.toFixed(2)]}):e.jsx("span",{className:"text-gray-400",children:"$0.00"})})]},s.id))})]})}):e.jsxs("div",{className:"text-center py-8 text-gray-500",children:[e.jsx(v,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"No referrals yet"}),e.jsx("p",{className:"text-sm",children:"Share your referral link to start earning"})]})})]})}),e.jsxs(N,{value:"payouts",className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs(t,{children:[e.jsx(i,{className:"pb-2",children:e.jsx(l,{className:"text-sm font-medium",children:"Pending"})}),e.jsxs(r,{children:[e.jsxs("div",{className:"text-2xl font-bold text-orange-600",children:["$",a.totalCommissionOwed.toFixed(2)]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Available for payout"})]})]}),e.jsxs(t,{children:[e.jsx(i,{className:"pb-2",children:e.jsx(l,{className:"text-sm font-medium",children:"Paid Out"})}),e.jsxs(r,{children:[e.jsxs("div",{className:"text-2xl font-bold text-green-600",children:["$",a.totalCommissionPaid.toFixed(2)]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total received"})]})]}),e.jsxs(t,{children:[e.jsx(i,{className:"pb-2",children:e.jsx(l,{className:"text-sm font-medium",children:"Threshold"})}),e.jsxs(r,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:["$",a.payoutThreshold]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Minimum payout amount"})]})]})]}),e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(l,{children:"Payout History"}),e.jsx("p",{className:"text-sm text-gray-600",children:"View your payment history and status"})]}),e.jsx(r,{children:Y?e.jsx("div",{className:"text-center py-8",children:"Loading payouts..."}):C.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(L,{children:[e.jsx(M,{children:e.jsxs(f,{children:[e.jsx(n,{children:"Date"}),e.jsx(n,{children:"Amount"}),e.jsx(n,{children:"Method"}),e.jsx(n,{children:"Status"}),e.jsx(n,{children:"Notes"})]})}),e.jsx(P,{children:C.map(s=>e.jsxs(f,{children:[e.jsx(c,{children:x(new Date(s.createdAt),"MMM dd, yyyy")}),e.jsxs(c,{className:"font-medium",children:["$",s.amount.toFixed(2)]}),e.jsx(c,{children:s.paymentMethod}),e.jsx(c,{children:e.jsx(o,{variant:s.status==="completed"?"default":s.status==="processing"?"secondary":s.status==="failed"?"destructive":"outline",children:s.status})}),e.jsx(c,{children:e.jsx("span",{className:"text-sm text-gray-600",children:s.notes||"â"})})]},s.id))})]})}):e.jsxs("div",{className:"text-center py-8 text-gray-500",children:[e.jsx(A,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"No payouts yet"}),e.jsx("p",{className:"text-sm",children:"Payouts are processed when you reach the minimum threshold"})]})})]})]}),e.jsx(N,{value:"analytics",className:"space-y-6",children:e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(l,{children:"Performance Analytics"}),e.jsx("p",{className:"text-sm text-gray-600",children:"Track your referral performance over time"})]}),e.jsx(r,{children:q?e.jsx("div",{className:"text-center py-8",children:"Loading analytics..."}):h.length>0?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:h.reduce((s,d)=>s+d.clicks,0)}),e.jsx("div",{className:"text-sm text-gray-600",children:"Total Clicks"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-green-600",children:h.reduce((s,d)=>s+d.signups,0)}),e.jsx("div",{className:"text-sm text-gray-600",children:"Total Signups"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:h.reduce((s,d)=>s+d.conversions,0)}),e.jsx("div",{className:"text-sm text-gray-600",children:"Total Conversions"})]})]}),e.jsx("div",{className:"text-center text-sm text-gray-500",children:"Detailed analytics charts coming soon..."})]}):e.jsxs("div",{className:"text-center py-8 text-gray-500",children:[e.jsx(J,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}
11),e.jsx("p",{children:"No analytics data yet"}),e.jsx("p",{className:"text-sm",children:"Start referring users to see your performance metrics"})]})})]})})]})]}):e.jsx("div",{className:"container-mobile py-8",children:e.jsx("div",{className:"text-center",children:e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsx(u,{className:"h-16 w-16 text-gray-400 mx-auto mb-4"}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100 mb-2",children:"No Affiliate Account Found"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"You haven't applied to become an affiliate yet."}),e.jsx(T,{onClick:()=>window.location.href="/affiliate-signup",children:"Apply to Become an Affiliate"})]})})})}export{le 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.