import { useState, useEffect, useRef } from "react"; // ─── DOMAIN CONFIG ──────────────────────────────────────────────────────────── const AFFILIATE_PORTAL_URL = "https://join.businessfundingnow.com"; const ADMIN_PORTAL_URL = "https://affiliateadmin.businessfundingnow.com"; const REFERRAL_BASE_URL = "https://apply.businessfundingnow.com"; // ─── CONSTANTS ──────────────────────────────────────────────────────────────── const TIERS = [ { name: "Bronze Broker", min: 0, max: 49999, rate: 0.02, color: "#CD7F32", bg: "#2a1a0a" }, { name: "Silver Broker", min: 50000, max: 249999, rate: 0.025, color: "#C0C0C0", bg: "#1a1a1a" }, { name: "Gold Broker", min: 250000, max: 999999, rate: 0.03, color: "#FFD700", bg: "#1a1500" }, { name: "Platinum Broker", min: 1000000, max: Infinity, rate: 0.04, color: "#E5E4E2", bg: "#0f0f14" }, ]; const STAGES = ["Lead Captured", "Application Submitted", "Under Review", "Docs Requested", "Approved", "Funded", "Declined"]; const TRAINING_MODULES = [ { id: "m1", title: "Getting Started", icon: "🚀", lessons: [ { id: "l-101", title: "Welcome to BFN Edge Affiliate Program", duration: "8 min" }, { id: "l-102", title: "How the Platform Works", duration: "12 min" }, { id: "l-103", title: "Your Affiliate Dashboard Tour", duration: "10 min" }, { id: "l-104", title: "Setting Up Your Profile", duration: "6 min" }, ] }, { id: "m2", title: "Understanding Business Funding", icon: "💼", lessons: [ { id: "l-201", title: "Types of Business Funding Products", duration: "15 min" }, { id: "l-202", title: "Qualifying Criteria for Clients", duration: "11 min" }, { id: "l-203", title: "The Funding Process Explained", duration: "14 min" }, { id: "l-204", title: "Common Client Questions & Answers", duration: "9 min" }, ] }, { id: "m3", title: "Sales & Referral Strategies", icon: "📈", lessons: [ { id: "l-301", title: "Identifying Ideal Referral Clients", duration: "13 min" }, { id: "l-302", title: "Effective Outreach Scripts", duration: "10 min" }, { id: "l-303", title: "Leveraging Your Network", duration: "8 min" }, { id: "l-304", title: "Tracking & Optimizing Your Funnel", duration: "12 min" }, ] }, { id: "m4", title: "Compliance & Best Practices", icon: "⚖️", lessons: [ { id: "l-401", title: "FTC & Disclosure Requirements", duration: "11 min" }, { id: "l-402", title: "What You Can and Cannot Promise", duration: "9 min" }, { id: "l-403", title: "Data Privacy & Client Confidentiality", duration: "7 min" }, { id: "l-404", title: "Certification & Next Steps", duration: "5 min" }, ] }, ]; // ─── MOCK DATA ───────────────────────────────────────────────────────────────── const MOCK_AFFILIATES = [ { id: "a1", name: "Sarah Chen", email: "sarah@example.com", phone: "+1-555-0101", company: "Chen Advisory", tier: "Gold Broker", status: "Active", affiliate_code: "SARAH-BFN", total_earned: 18420, pending_comm: 2100, commission_rate: 0.03, created_at: "2024-11-15", referral_method: "LinkedIn", ghl_contact_id: "ghl_001" }, { id: "a2", name: "Marcus Williams", email: "marcus@fundingpro.com", phone: "+1-555-0202", company: "Funding Pro LLC", tier: "Platinum Broker", status: "Active", affiliate_code: "MARCUS-BFN", total_earned: 62800, pending_comm: 5400, commission_rate: 0.04, created_at: "2024-09-03", referral_method: "Referral", ghl_contact_id: "ghl_002" }, { id: "a3", name: "Priya Patel", email: "priya@pateladvisors.com", phone: "+1-555-0303", company: "Patel Advisors", tier: "Silver Broker", status: "Active", affiliate_code: "PRIYA-BFN", total_earned: 9650, pending_comm: 850, commission_rate: 0.025, created_at: "2025-01-20", referral_method: "Website", ghl_contact_id: "ghl_003" }, { id: "a4", name: "James Okonkwo", email: "james@bizbroker.net", phone: "+1-555-0404", company: "BizBroker Net", tier: "Bronze Broker", status: "Pending", affiliate_code: null, total_earned: 0, pending_comm: 0, commission_rate: 0.02, created_at: "2025-06-01", referral_method: "Google", ghl_contact_id: null }, { id: "a5", name: "Lisa Nguyen", email: "lisa@capitalconnect.io", phone: "+1-555-0505", company: "Capital Connect", tier: "Bronze Broker", status: "Pending", affiliate_code: null, total_earned: 0, pending_comm: 0, commission_rate: 0.02, created_at: "2025-06-02", referral_method: "Instagram", ghl_contact_id: null }, ]; const MOCK_DEALS = [ { id: "d1", affiliate_id: "a1", business_name: "Green Leaf Café", loan_amount: 75000, stage: "Funded", commission: 2250, commission_paid: true, paid_at: "2025-05-10", created_at: "2025-04-01" }, { id: "d2", affiliate_id: "a1", business_name: "TechForge Solutions", loan_amount: 140000, stage: "Approved", commission: 4200, commission_paid: false, created_at: "2025-05-15" }, { id: "d3", affiliate_id: "a2", business_name: "Sunrise Logistics", loan_amount: 320000, stage: "Funded", commission: 12800, commission_paid: true, paid_at: "2025-04-28", created_at: "2025-03-10" }, { id: "d4", affiliate_id: "a2", business_name: "Pacific Dental Group", loan_amount: 185000, stage: "Under Review", commission: 7400, commission_paid: false, created_at: "2025-05-20" }, { id: "d5", affiliate_id: "a3", business_name: "Bloom Boutique", loan_amount: 45000, stage: "Application Submitted", commission: 1125, commission_paid: false, created_at: "2025-06-01" }, ]; const MOCK_LINKS = [ { id: "lk1", affiliate_id: "a1", code: "SARAH-BFN", label: "Primary Link", clicks: 342, conversions: 8, active: true }, { id: "lk2", affiliate_id: "a1", code: "SARAH-BFN-002", label: "LinkedIn Campaign", clicks: 128, conversions: 3, active: true }, { id: "lk3", affiliate_id: "a2", code: "MARCUS-BFN", label: "Primary Link", clicks: 891, conversions: 21, active: true }, ]; // ─── UTILS ──────────────────────────────────────────────────────────────────── const fmt = (n) => n?.toLocaleString("en-US", { style: "currency", currency: "USD", minimumFractionDigits: 0 }) ?? "$0"; const fmtNum = (n) => n?.toLocaleString() ?? "0"; function getTier(earned) { return TIERS.find(t => earned >= t.min && earned <= t.max) || TIERS[0]; } function getStageColor(stage) { const map = { "Lead Captured": "#64748b", "Application Submitted": "#3b82f6", "Under Review": "#f59e0b", "Docs Requested": "#8b5cf6", "Approved": "#10b981", "Funded": "#22c55e", "Declined": "#ef4444" }; return map[stage] || "#64748b"; } function StatusBadge({ status }) { const colors = { Active: "#22c55e", Pending: "#f59e0b", Suspended: "#ef4444", Rejected: "#64748b" }; return ( {status.toUpperCase()} ); } // ─── AI CHAT WIDGET ────────────────────────────────────────────────────────── function AIChat({ affiliate, onClose }) { const [messages, setMessages] = useState([ { role: "assistant", content: `Hey ${affiliate?.name?.split(" ")[0] || "there"}! 👋 I'm your BFN Edge AI assistant. Ask me anything about your affiliate account, commission rates, how to qualify clients, or tips to boost your referrals!` } ]); const [input, setInput] = useState(""); const [loading, setLoading] = useState(false); const bottomRef = useRef(null); useEffect(() => { bottomRef.current?.scrollIntoView({ behavior: "smooth" }); }, [messages]); const send = async () => { if (!input.trim() || loading) return; const userMsg = input.trim(); setInput(""); setMessages(m => [...m, { role: "user", content: userMsg }]); setLoading(true); const context = affiliate ? `Affiliate context: Name: ${affiliate.name}, Tier: ${affiliate.tier}, Total Earned: ${fmt(affiliate.total_earned)}, Commission Rate: ${(affiliate.commission_rate * 100).toFixed(1)}%, Status: ${affiliate.status}.` : ""; try { const res = await fetch("https://api.anthropic.com/v1/messages", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ model: "claude-sonnet-4-20250514", max_tokens: 1000, system: `You are a helpful assistant for BFN Edge Affiliate Platform — a business funding referral program. ${context} Help affiliates understand their commissions (2-4% based on tier), how to qualify clients, referral strategies, and platform features. Be concise, friendly, and professional. Use $ formatting for amounts.`, messages: [...messages.filter(m => m.role !== "assistant" || messages.indexOf(m) > 0), { role: "user", content: userMsg }].map(m => ({ role: m.role, content: m.content })) }) }); const data = await res.json(); const reply = data.content?.[0]?.text || "I couldn't get a response. Please try again."; setMessages(m => [...m, { role: "assistant", content: reply }]); } catch { setMessages(m => [...m, { role: "assistant", content: "Connection error. Please try again." }]); } setLoading(false); }; return (
BFN AI Assistant
● Online
{messages.map((m, i) => (
{m.content}
))} {loading && (
{[0,1,2].map(i =>
)}
)}
setInput(e.target.value)} onKeyDown={e => e.key === "Enter" && send()} placeholder="Ask anything..." style={{ flex: 1, background: "#161e2d", border: "1px solid #1e2a3a", borderRadius: 10, color: "#e2e8f0", padding: "9px 14px", fontSize: 13, outline: "none" }} />
); } // ─── SIGN-UP PAGE ───────────────────────────────────────────────────────────── function SignUpPage({ onSubmit, onBack }) { const [form, setForm] = useState({ name: "", email: "", phone: "", company: "", website: "", referralMethod: "", volume: "", bio: "" }); const [submitted, setSubmitted] = useState(false); const [loading, setLoading] = useState(false); const handleSubmit = async () => { if (!form.name || !form.email) return; setLoading(true); await new Promise(r => setTimeout(r, 900)); setSubmitted(true); setLoading(false); onSubmit?.(form); }; const F = ({ label, field, type = "text", placeholder, options }) => (
{options ? ( ) : ( setForm({ ...form, [field]: e.target.value })} placeholder={placeholder} style={inputStyle} /> )}
); if (submitted) return (
🎉
Application Submitted!
Thanks, {form.name}! Your application is under review. We'll email you at {form.email} within 24 hours.
); return (
{/* Left panel */}
BFN EDGE
AFFILIATE NETWORK
Earn up to 4% on every funded deal
Join hundreds of brokers and advisors earning recurring commissions by connecting businesses with the funding they need.
{TIERS.map(t => (
{t.name} — {(t.rate * 100).toFixed(1)}% commission
))}
© 2025 Business Funding Now · businessfundingnow.com
{/* Right panel - form */}
Join the Affiliate Program
Complete the form below. Approval takes less than 24 hours.