PageSourceSearch

https://smartmentor.ai/assets/Referrals.DTz9sH-3.js

js smartmentor.ai collected 2026-10-05 16:21:05 UTC 15,219 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-ui-core.DP8knyZn.js";import{r,L as s}from"./vendor-react.BBoGJFYM.js";import{j as t,a,s as l,p as o}from"./index.CdjOtu-m.js";import{L as n,m as d,R as i,x as c,p as x,an as p,q as m,aF as u,am as h,aG as f,bw as b,aq as y,ad as g}from"./vendor-icons.BjAWwE8z.js";import{palette as j,PageShell as w}from"./Wallet.NiJIN2i4.js";import"./vendor-supabase.DS-aP8MZ.js";import"./vendor-ui-forms.CjLBxE3d.js";import"./vendor-utils.BlEnRQrd.js";import"./vendor-ui-display.BT2Z6Vpo.js";import"./vendor-query.CfjDb5WU.js";import"./vendor-media.DY6E_qVO.js";import"./vendor-charts.RWeJ_I16.js";import"./vendor-motion.DCvbjL6b.js";import"./CreditPurchaseModal.Bp5Lk_c4.js";const v=({p:r})=>e.jsx("div",{"aria-hidden":!0,className:"fixed inset-0 pointer-events-none",style:{backgroundImage:[`linear-gradient(${r.gridLine} 1px, transparent 1px)`,`linear-gradient(90deg, ${r.gridLine} 1px, transparent 1px)`].join(", "),backgroundSize:"40px 40px",zIndex:0}}),N=({title:r,value:s,sub:t,icon:a,iconAccent:l,p:o})=>e.jsx("div",{className:"rounded-2xl p-5 transition-all duration-200 hover:scale-[1.01]",style:{background:o.statCardBg,border:`1px solid ${o.statCardBorder}`},children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.14em] mb-2",style:{color:o.mutedText},children:r}),e.jsx("p",{className:"text-3xl font-bold",style:{fontFamily:"'Roboto Slab', serif",color:o.headlineColor},children:s}),t&&e.jsx("p",{className:"text-xs mt-1",style:{color:o.mutedText},children:t})]}),e.jsx("div",{className:"rounded-xl flex items-center justify-center flex-shrink-0",style:{width:40,height:40,background:`${l}18`,border:`1px solid ${l}28`},children:a})]})}),k=({title:r,children:s,p:t})=>e.jsxs("div",{className:"rounded-2xl overflow-hidden w-full",style:{background:t.cardBg,border:`1px solid ${t.cardBorder}`},children:[e.jsx("div",{className:"px-5 sm:px-6 py-3.5",style:{borderBottom:`1px solid ${t.divider}`,background:t.tableHeaderBg},children:e.jsx("h3",{className:"text-[10px] font-bold uppercase tracking-[0.14em]",style:{color:t.tableHeaderText},children:r})}),e.jsx("div",{className:"p-5 sm:p-6",children:s})]}),C=({label:r,icon:s,iconColor:t,onClick:a,p:l})=>e.jsxs("button",{type:"button",onClick:a,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold transition-all hover:opacity-80 active:scale-[0.97]",style:{background:l.stepLockedBg,border:`1px solid ${l.stepLockedBorder}`,color:l.bodyText,cursor:"pointer",fontFamily:"inherit"},children:[e.jsx(s,{className:"h-4 w-4",style:{color:t}}),r]}),_=()=>{const{resolvedTheme:s}=t(),g="light"===s?o.light:o.dark,{user:j}=a(),[w,_]=r.useState(null),[T,B]=r.useState(!0),[$,R]=r.useState(null),[S,A]=r.useState(!1),[E,U]=r.useState(!1),L=r.useCallback(async()=>{if(j)try{B(!0),R(null);const{data:e,error:r}=await l.from("profiles").select("referral_code").eq("user_id",j.id).single();if(r)throw r;const{data:s,error:t}=await l.from("user_reward_events").select("*").eq("user_id",j.id).order("created_at",{ascending:!1});if(t)throw t;const{data:a,error:o}=await l.from("profiles").select("user_id, full_name, email, created_at").eq("referrer_user_id",j.id).order("created_at",{ascending:!1});if(o)throw o;const n={};(s||[]).forEach(e=>{"referral_signup"===e.reward_type&&e.user_id&&(n[e.user_id]=(n[e.user_id]||0)+(e.credits_awarded||0))});const d=(a||[]).map(e=>({id:e.user_id,full_name:e.full_name||"Unnamed",email:e.email||"—",joined_at:e.created_at,credits_awarded:n[e.user_id]||0,status:n[e.user_id]?"rewarded":"pending"})),i=(s||[]).reduce((e,r)=>e+(r.credits_awarded||0),0),c=d.filter(e=>"pending"===e.status).length;_({referralCode:(null==e?void 0:e.referral_code)||"—",totalReferrals:d.length,creditsEarned:i,pendingRewards:c,referredUsers:d})}catch(e){R((null==e?void 0:e.message)||"Failed to load referral data")}finally{B(!1)}},[j]);r.useEffect(()=>{L()},[L]),r.useEffect(()=>{const e=()=>L();return window.addEventListener("referral:refresh",e),()=>window.removeEventListener("referral:refresh",e)},[L]);const F=()=>`${window.location.origin}/signup?ref=${(null==w?void 0:w.referralCode)??""}`,q=`Join SmartMentor and ace your next interview! Use my referral code ${null==w?void 0:w.referralCode} and we both earn bonus credits. 🚀`,I=[{label:"LinkedIn",icon:f,iconColor:"#60a5fa",onClick:()=>window.open(`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(F())}`,"_blank","noopener")},{label:"Twitter / X",icon:b,iconColor:"#93c5fd",onClick:()=>window.open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(q)}&url=${encodeURIComponent(F())}`,"_blank","noopener")},{label:"WhatsApp",icon:y,iconColor:"#6ee7b7",onClick:()=>window.open(`https://wa.me/?text=${encodeURIComponent(q+" "+F())}`,"_blank","noopener")}];return T?e.jsxs("div",{className:"min-h-screen w-full flex items-center justify-center",style:{background:g.sectionBg},children:[e.jsx(v,{p:g}),e.jsxs("div",{className:"relative z-10 flex flex-col items-center gap-4",children:[e.jsx("div",{className:"p-4 rounded-2xl",style:{background:g.cardBg,border:`1px solid ${g.cardBorder}`},children:e.jsx(n,{className:"h-8 w-8 animate-spin",style:{color:g.accentText}})}),e.jsx("p",{className:"text-sm",style:{color:g.mutedText},children:"Loading referral data…"})]})]}):$?e.jsxs("div",{className:"min-h-screen w-full flex items-center justify-center p-6",style:{background:g.sectionBg},children:[e.jsx(v,{p:g}),e.jsxs("div",{className:"relative z-10 rounded-2xl p-8 max-w-md w-full text-center space-y-4",style:{background:g.cardBg,border:`1px solid ${g.cardBorder}`},children:[e.jsx(d,{className:"h-10 w-10 mx-auto",style:{color:g.redAccent}}),e.jsx("p",{className:"font-semibold",style:{color:g.headlineColor},children:"Failed to load referral data"}),e.jsx("p",{className:"text-sm",style:{color:g.mutedText},children:$}),e.jsxs("button",{type:"button",onClick:L,className:"px-5 py-2.5 rounded-xl text-sm font-semibold mx-auto flex items-center gap-2 transition-opacity hover:opacity-80",style:{background:g.btnPrimaryBg,color:"#fff",border:"none",cursor:"pointer",fontFamily:"inherit"},children:[e.jsx(i,{className:"h-4 w-4"})," Retry"]})]})]}):w?e.jsx("div",{className:"w-full transition-colors duration-300",style:{background:"transparent"},children:e.jsx("div",{className:"relative z-10 w-full px-3 sm:px-4 lg:px-6 py-4 sm:py-6",children:e.jsxs("div",{className:"w-full space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(N,{title:"Total Referrals",value:w.totalReferrals,sub:"Signed-up users",icon:e.jsx(c,{className:"h-5 w-5",style:{color:g.blueAccent}}),iconAccent:g.blueAccent,p:g}),e.jsx(N,{title:"Credits Earned",value:w.creditsEarned,sub:"From referral rewards",icon:e.jsx(x,{className:"h-5 w-5",style:{color:g.purpleAccent}}),iconAccent:g.purpleAccent,p:g}),e.jsx(N,{title:"Pending Rewards",value:w.pendingRewards,sub:"Awaiting activation",icon:e.jsx(p,{className:"h-5 w-5",style:{color:g.orangeAccent}}),iconAccent:g.orangeAccent,p:g})]}),e.jsx(k,{title:"Your Referral Code",p:g,children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-4 roun
1ded-2xl px-5 sm:px-7 py-4 sm:py-5 flex-wrap",style:{background:g.stepActiveBg,border:`2px solid ${g.stepActiveBorder}`,boxShadow:"0 0 28px rgba(139,92,246,0.14)"},children:[e.jsx("span",{className:"text-3xl sm:text-4xl font-black tracking-[0.22em] select-all flex-1",style:{fontFamily:"'Roboto Slab', serif",color:g.headlineColor},children:w.referralCode}),e.jsxs("button",{type:"button",onClick:async()=>{if(null==w?void 0:w.referralCode){try{await navigator.clipboard.writeText(w.referralCode)}catch{const e=document.createElement("textarea");e.value=w.referralCode,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}A(!0),setTimeout(()=>A(!1),2500)}},className:"flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold transition-all hover:opacity-90 active:scale-[0.97] flex-shrink-0",style:{background:S?"rgba(110,231,183,0.18)":g.btnPrimaryBg,color:S?g.greenAccent:"#fff",border:S?"1px solid rgba(110,231,183,0.35)":"none",cursor:"pointer",fontFamily:"inherit",boxShadow:S?"none":"0 4px 14px rgba(124,58,237,0.30)"},children:[S?e.jsx(m,{className:"h-4 w-4"}):e.jsx(u,{className:"h-4 w-4"}),S?"Copied!":"Copy Code"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wide mb-2",style:{color:g.labelText},children:"Referral Link"}),e.jsxs("div",{className:"flex items-center gap-3 rounded-xl px-4 py-3",style:{background:g.inputBg,border:`1px solid ${g.inputBorder}`},children:[e.jsx("p",{className:"text-xs font-mono flex-1 truncate",style:{color:g.mutedText},children:F()}),e.jsxs("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(F())}catch{}U(!0),setTimeout(()=>U(!1),2500)},className:"flex-shrink-0 flex items-center gap-1.5 text-xs font-semibold transition-opacity hover:opacity-70",style:{background:"none",border:"none",cursor:"pointer",color:E?g.greenAccent:g.accentText},"aria-label":"Copy referral link",children:[E?e.jsx(m,{className:"h-3.5 w-3.5"}):e.jsx(u,{className:"h-3.5 w-3.5"}),E?"Copied":"Copy"]})]})]}),e.jsxs("div",{className:"rounded-xl p-4 space-y-3",style:{background:"rgba(139,92,246,0.08)",border:"1px solid rgba(139,92,246,0.18)"},children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wide",style:{color:g.accentText},children:"How it works"}),["Share your code with friends and colleagues","They sign up using your referral code","You both earn bonus interview credits instantly"].map((r,s)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-xs font-bold rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",style:{width:20,height:20,background:g.badgeBg,border:`1px solid ${g.badgeBorder}`,color:g.accentText},children:s+1}),e.jsx("p",{className:"text-sm",style:{color:g.bodyText},children:r})]},s))]})]})}),e.jsx(k,{title:"Share Your Code",p:g,children:e.jsxs("div",{className:"flex flex-wrap gap-3",children:[I.map(r=>e.jsx(C,{...r,p:g},r.label)),"undefined"!=typeof navigator&&"share"in navigator&&e.jsxs("button",{type:"button",onClick:()=>{navigator.share({title:"Join SmartMentor",text:q,url:F()}).catch(()=>{})},className:"flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold transition-all hover:opacity-80 active:scale-[0.97]",style:{background:g.btnPrimaryBg,color:"#fff",border:"none",cursor:"pointer",fontFamily:"inherit",boxShadow:"0 4px 14px rgba(124,58,237,0.28)"},children:[e.jsx(h,{className:"h-4 w-4"}),"More Options"]})]})}),w.referredUsers.length>0?e.jsx(k,{title:`Referred Users (${w.referredUsers.length})`,p:g,children:e.jsx("div",{className:"overflow-x-auto -mx-1",children:e.jsxs("table",{className:"w-full min-w-[540px] text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:g.tableHeaderBg,borderBottom:`1px solid ${g.tableBorder}`},children:["Name","Email","Joined","Credits","Status"].map(r=>e.jsx("th",{className:"text-left py-3 px-4 text-[10px] font-bold uppercase tracking-[0.12em]",style:{color:g.tableHeaderText},children:r},r))})}),e.jsx("tbody",{children:w.referredUsers.map((r,s)=>e.jsxs("tr",{className:"transition-colors duration-150",style:{borderBottom:s<w.referredUsers.length-1?`1px solid ${g.tableBorder}`:"none"},onMouseEnter:e=>e.currentTarget.style.background=g.tableRowHover,onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[e.jsx("td",{className:"py-3 px-4 font-semibold",style:{color:g.bodyText},children:r.full_name}),e.jsx("td",{className:"py-3 px-4 text-xs",style:{color:g.mutedText},children:r.email}),e.jsx("td",{className:"py-3 px-4 text-xs whitespace-nowrap",style:{color:g.mutedText},children:new Date(r.joined_at).toLocaleDateString("en-IN",{day:"numeric",month:"short",year:"numeric"})}),e.jsx("td",{className:"py-3 px-4",children:e.jsx("span",{className:"font-bold",style:{color:r.credits_awarded>0?g.greenAccent:g.mutedText},children:r.credits_awarded>0?`+${r.credits_awarded}`:"—"})}),e.jsx("td",{className:"py-3 px-4",children:e.jsx("span",{className:"text-xs font-semibold px-2.5 py-1 rounded-full whitespace-nowrap",style:{color:"rewarded"===r.status?g.greenAccent:g.orangeAccent,background:"rewarded"===r.status?"rgba(110,231,183,0.10)":"rgba(251,191,36,0.10)",border:"1px solid "+("rewarded"===r.status?"rgba(110,231,183,0.25)":"rgba(251,191,36,0.25)")},children:"rewarded"===r.status?"✓ Rewarded":"⏳ Pending"})})]},r.id))})]})})}):e.jsx(k,{title:"Referred Users",p:g,children:e.jsxs("div",{className:"text-center py-10 space-y-3",children:[e.jsx("div",{className:"mx-auto h-14 w-14 roun
1ded-2xl flex items-center justify-center",style:{background:g.tileBg??"rgba(255,255,255,0.05)",border:`1px solid ${g.cardBorder}`},children:e.jsx(c,{className:"h-6 w-6",style:{color:g.mutedText}})}),e.jsx("p",{className:"font-semibold",style:{color:g.headlineColor},children:"No referrals yet"}),e.jsx("p",{className:"text-sm",style:{color:g.mutedText},children:"Share your code above to start earning rewards"})]})})]})})}):null};function T(){const{resolvedTheme:o}=t(),n="light"===o?j.light:j.dark,{user:d}=a(),[c,p]=r.useState(!1);return r.useEffect(()=>{if(!d)return;let e=!1;return(async()=>{const{data:r}=await l.from("profiles").select("referral_frozen").eq("user_id",d.id).maybeSingle();!e&&(null==r?void 0:r.referral_frozen)&&p(!0)})(),()=>{e=!0}},[d]),e.jsxs(w,{p:n,title:"Referral Dashboard",subtitle:"Share your link and earn interview practice credits",icon:x,seoTitle:"Referral Dashboard — SmartMentor.ai",seoDesc:"Track your referrals and earn interview practice credits",canonicalUrl:"https://smartmentor.ai/referrals",headerExtra:e.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new Event("referral:refresh")),className:"flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-semibold transition-all hover:opacity-80 active:scale-[0.97]",style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.18)",color:n.bodyText,cursor:"pointer"},children:[e.jsx(i,{className:"h-4 w-4"})," Refresh"]}),children:[c&&e.jsxs("div",{role:"alert",className:"rounded-2xl p-4 mb-4 flex items-start gap-3",style:{background:"rgba(234,179,8,0.10)",border:"1px solid rgba(234,179,8,0.40)"},children:[e.jsx(g,{className:"h-5 w-5 flex-shrink-0 mt-0.5",style:{color:"#eab308"}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm",style:{color:n.headlineColor},children:"Your referral rewards have been paused"}),e.jsxs("p",{className:"text-xs mt-1",style:{color:n.bodyText},children:["New referral credits won't be granted until this is resolved."," ",e.jsx(s,{to:"/contact-us?inquiry=referral",className:"underline font-medium",style:{color:n.accentText},children:"Contact support"})," ","for help."]})]})]}),e.jsx("div",{className:"rounded-2xl overflow-hidden",style:{background:n.cardBg,border:`1px solid ${n.cardBorder}`,backdropFilter:"blur(12px)"},children:e.jsx(_,{})})]})}export{T 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.