@@ -8,6 +8,7 @@ import { PokemonReferralCard } from './PokemonReferralCard';
88import { MyReferralsView } from './MyReferralsView' ;
99import { ReferralModalTab } from '@/lib/constants/modal.constants' ;
1010import { REFERRAL_CODE } from '@/lib/constants/referral.constants' ;
11+ import { useToast } from '@/contexts/ui/ToastContext' ;
1112
1213interface ReferralInvitationModalProps {
1314 isOpen : boolean ;
@@ -115,6 +116,7 @@ export const ReferralInvitationModal: React.FC<ReferralInvitationModalProps> = (
115116 showBonusModal,
116117} ) => {
117118 const [ activeTab , setActiveTab ] = useState < ReferralModalTab > ( ReferralModalTab . CARD ) ;
119+ const { addToast } = useToast ( ) ;
118120
119121 // If user has already applied a referral code and is on the apply-code tab, switch to card tab
120122 useEffect ( ( ) => {
@@ -130,6 +132,23 @@ export const ReferralInvitationModal: React.FC<ReferralInvitationModalProps> = (
130132 const referralLink = `${ window . location . origin } /?ref=${ referralCode } ` ;
131133 const referrerName = account ?. profile ?. displayName || 'Nexus Explorer' ;
132134
135+ const handleCopyReferralCode = async ( ) => {
136+ try {
137+ await navigator . clipboard . writeText ( referralCode ) ;
138+ addToast ( {
139+ title : 'Copied!' ,
140+ message : `Referral code ${ referralCode } copied to clipboard` ,
141+ type : 'success' ,
142+ } ) ;
143+ } catch ( error ) {
144+ addToast ( {
145+ title : 'Copy Failed' ,
146+ message : 'Failed to copy referral code. Please try again.' ,
147+ type : 'error' ,
148+ } ) ;
149+ }
150+ } ;
151+
133152 return (
134153 < div
135154 className = 'fixed inset-0 flex items-center justify-center z-50 p-4'
@@ -139,7 +158,33 @@ export const ReferralInvitationModal: React.FC<ReferralInvitationModalProps> = (
139158 < div className = 'bg-gradient-to-br from-slate-900 to-slate-800 rounded-2xl p-8 w-full max-w-2xl mx-4 border border-white/20 shadow-2xl relative overflow-hidden max-h-[90vh] overflow-y-auto' >
140159 < div className = 'relative z-10' >
141160 < div className = 'flex justify-between items-center p-4 border-b border-gray-700' >
142- < h2 className = 'text-xl font-bold' > Referral Center</ h2 >
161+ < div className = 'flex items-center gap-3' >
162+ < h2 className = 'text-xl font-bold' > Referral Center</ h2 >
163+ < div className = 'flex items-center gap-2 px-3 py-1.5 bg-white/10 rounded-lg border border-white/20' >
164+ < span className = 'text-sm font-mono text-cyan-400 font-semibold' > { referralCode } </ span >
165+ < button
166+ onClick = { handleCopyReferralCode }
167+ className = 'p-1.5 hover:bg-white/20 rounded transition-colors focus:outline-none focus:ring-2 focus:ring-cyan-400'
168+ aria-label = 'Copy referral code'
169+ title = 'Copy referral code'
170+ >
171+ < svg
172+ xmlns = 'http://www.w3.org/2000/svg'
173+ className = 'h-4 w-4 text-white'
174+ fill = 'none'
175+ viewBox = '0 0 24 24'
176+ stroke = 'currentColor'
177+ strokeWidth = { 2 }
178+ >
179+ < path
180+ strokeLinecap = 'round'
181+ strokeLinejoin = 'round'
182+ d = 'M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z'
183+ />
184+ </ svg >
185+ </ button >
186+ </ div >
187+ </ div >
143188
144189 { /* AÑADIR ESTE BOTÓN DE CIERRE */ }
145190 </ div >
0 commit comments