// Chart Growth Hub — Student "Refer & Earn" panel. Open to ALL students (Free Trial + VIP), // not VIP-only — the bonus is tiered by the REFERRER's own membership: VIP members earn // ₱4,000 per successful referral, Free Trial members earn ₱1,000. Whole panel is hidden // while the $88 VIP promo is running (see REFERRAL_ACTIVE in config.js) and auto-activates // the moment the promo ends and price reverts to $499. // Reads students.referral_code (auto-generated at signup) and the referrals table // (status: pending is informational only right now, earned = referred person became VIP, // paid = admin has sent the money manually). Exposes window.ReferralPanel. (function(){ const { useState, useEffect } = React; const STATUS_META = { earned: { label:'Earned — payout pending', color:'#fbbf24', bg:'rgba(251,191,36,.12)' }, paid: { label:'Paid', color:'var(--green)', bg:'rgba(52,211,153,.12)' }, }; function ReferralPanel({client, session, isVIP}){ const [code,setCode]=useState(null); const [refs,setRefs]=useState(null); const [copied,setCopied]=useState(false); async function load(){ const { data:stu } = await client.from('students').select('referral_code').eq('id',session.user.id).maybeSingle(); setCode(stu&&stu.referral_code||null); const { data:r } = await client.from('referrals').select('*').eq('referrer_student_id',session.user.id).order('created_at',{ascending:false}); setRefs(r||[]); } useEffect(()=>{ load(); /* eslint-disable-next-line */ },[]); if(code===null || refs===null) return null; const link = code ? (location.origin + location.pathname.replace(/[^/]*$/,'') + 'Sign Up.html?ref=' + code) : ''; const earned = refs.filter(r=>r.status==='earned').reduce((s,r)=>s+Number(r.reward_php||0),0); const paid = refs.filter(r=>r.status==='paid').reduce((s,r)=>s+Number(r.reward_php||0),0); const CFG = window.CG_CONFIG||{}; const vipBonus = CFG.REFERRAL_BONUS_VIP_PHP||4000; const trialBonus = CFG.REFERRAL_BONUS_TRIAL_PHP||1000; const bonusCopy = isVIP ? `Earn ₱${vipBonus.toLocaleString('en-US')} for every friend who becomes a VIP member using your link.` : `Earn ₱${trialBonus.toLocaleString('en-US')} for every friend who becomes a VIP member using your link — upgrade to VIP to earn ₱${vipBonus.toLocaleString('en-US')} per referral instead.`; function copy(){ navigator.clipboard.writeText(link).then(()=>{ setCopied(true); setTimeout(()=>setCopied(false),2000); }); } return
{bonusCopy}