From 9a3b23b9de260d1e4edb26aa3c4ffaf6235a40c8 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Thu, 20 Nov 2025 02:28:22 +0300 Subject: [PATCH] feat: complete URL-based referral system integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Frontend changes: - Add ReferralHandler to App.tsx to capture ?ref= URL parameter - Store referrer address in localStorage for KYC registration - Improve DashboardContext error handling for Supabase All referral functionality now complete: - URL parameter capture and storage - On-chain referral initiation via InviteUserModal - Auto-confirmation via OnKycApproved hook - DefaultReferrer fallback to QaziMuhammedAccount - Real-time stats and event subscription - Referral score calculation (0-500 points) 🤖 Generated with Claude Code Co-Authored-By: Claude --- web/src/App.tsx | 26 +++++++++++++++++++++++--- web/src/contexts/DashboardContext.tsx | 9 ++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/web/src/App.tsx b/web/src/App.tsx index 746e3fe8..f8f011b5 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -1,4 +1,5 @@ -import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; +import { useEffect } from 'react'; +import { BrowserRouter as Router, Routes, Route, useLocation } from 'react-router-dom'; import { ThemeProvider } from '@/components/theme-provider'; import Index from '@/pages/Index'; import Login from '@/pages/Login'; @@ -32,6 +33,24 @@ import { ErrorBoundary } from '@/components/ErrorBoundary'; import './App.css'; import './i18n/config'; +function ReferralHandler() { + const location = useLocation(); + + useEffect(() => { + // Check for ?ref= parameter in URL + const params = new URLSearchParams(location.search); + const refParam = params.get('ref'); + + if (refParam) { + // Store referrer address in localStorage + localStorage.setItem('referrerAddress', refParam); + console.log('Referrer address saved:', refParam); + } + }, [location]); + + return null; +} + function App() { return ( @@ -45,8 +64,9 @@ function App() { - - } /> + + + } /> } /> } /> diff --git a/web/src/contexts/DashboardContext.tsx b/web/src/contexts/DashboardContext.tsx index 9ac52fe2..8cc7fb1f 100644 --- a/web/src/contexts/DashboardContext.tsx +++ b/web/src/contexts/DashboardContext.tsx @@ -35,7 +35,10 @@ export function DashboardProvider({ children }: { children: ReactNode }) { }, [user, selectedAccount, api, isApiReady]); const fetchProfile = async () => { - if (!user) return; + if (!user) { + setLoading(false); + return; + } try { const { data, error } = await supabase @@ -45,13 +48,13 @@ export function DashboardProvider({ children }: { children: ReactNode }) { .maybeSingle(); if (error) { - console.error('Profile fetch error:', error); + console.warn('Profile fetch error (this is normal if Supabase is not configured):', error.message); return; } setProfile(data); } catch (error) { - console.error('Error fetching profile:', error); + console.warn('Error fetching profile (this is normal if Supabase is not configured):', error); } finally { setLoading(false); }