From e023373f56a06afc2b95b32930986bd1cdd4d241 Mon Sep 17 00:00:00 2001 From: Fringg Date: Sun, 15 Mar 2026 01:14:25 +0300 Subject: [PATCH] feat: dual referral links UI (bot + cabinet) with independent copy states - add bot referral link section with Telegram icon (conditionally rendered) - add cabinet referral link section with chain-link icon - independent copy button state per link type - add bot_referral_link to ReferralInfo type - add i18n keys: botLink, cabinetLink in ru/en/fa/zh --- src/locales/en.json | 6 ++- src/locales/fa.json | 6 ++- src/locales/ru.json | 6 ++- src/locales/zh.json | 4 +- src/pages/Referral.tsx | 114 ++++++++++++++++++++++++++++++----------- src/types/index.ts | 1 + 6 files changed, 100 insertions(+), 37 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 2462568..a87d9f8 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -726,8 +726,10 @@ }, "referral": { "title": "Referral Program", - "yourLink": "Your Referral Link", - "copyLink": "Copy Link", + "yourLink": "Your Referral Links", + "botLink": "Bot link", + "cabinetLink": "Cabinet link", + "copyLink": "Copy", "copied": "Copied!", "shareButton": "Share", "shareMessage": "Join me on {{botName}} and earn up to {{percent}}% cashback!", diff --git a/src/locales/fa.json b/src/locales/fa.json index 5e04133..75e3a6b 100644 --- a/src/locales/fa.json +++ b/src/locales/fa.json @@ -577,8 +577,10 @@ }, "referral": { "title": "برنامه معرفی", - "yourLink": "لینک معرفی شما", - "copyLink": "کپی لینک", + "yourLink": "لینک‌های معرفی شما", + "botLink": "لینک ربات", + "cabinetLink": "لینک کابینت", + "copyLink": "کپی", "copied": "کپی شد!", "shareButton": "اشتراک‌گذاری", "shareMessage": "از طریق لینک من به {{botName}} بپیوند و تا {{percent}}٪ پاداش بگیر!", diff --git a/src/locales/ru.json b/src/locales/ru.json index 9d7d773..f8e5496 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -754,8 +754,10 @@ }, "referral": { "title": "Реферальная программа", - "yourLink": "Ваша реферальная ссылка", - "copyLink": "Копировать ссылку", + "yourLink": "Ваши реферальные ссылки", + "botLink": "Ссылка на бота", + "cabinetLink": "Ссылка на кабинет", + "copyLink": "Копировать", "copied": "Скопировано!", "shareButton": "Поделиться", "shareMessage": "Заходи в {{botName}} по моей ссылке и получай до {{percent}}% кешбэка!", diff --git a/src/locales/zh.json b/src/locales/zh.json index 091c92f..e24f931 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -578,7 +578,9 @@ "referral": { "title": "推荐计划", "yourLink": "您的推荐链接", - "copyLink": "复制链接", + "botLink": "机器人链接", + "cabinetLink": "面板链接", + "copyLink": "复制", "copied": "已复制!", "shareButton": "分享", "shareMessage": "通过我的链接加入 {{botName}},获取高达 {{percent}}% 返现!", diff --git a/src/pages/Referral.tsx b/src/pages/Referral.tsx index f414ec4..3fc6110 100644 --- a/src/pages/Referral.tsx +++ b/src/pages/Referral.tsx @@ -94,7 +94,7 @@ export default function Referral() { const navigate = useNavigate(); const { formatAmount, currencySymbol, formatPositive, formatWithCurrency } = useCurrency(); const queryClient = useQueryClient(); - const [copied, setCopied] = useState(false); + const [copiedLink, setCopiedLink] = useState<'cabinet' | 'bot' | null>(null); const copyTimerRef = useRef | null>(null); useEffect(() => { @@ -112,6 +112,7 @@ export default function Referral() { const referralLink = info?.referral_code ? `${window.location.origin}/login?ref=${info.referral_code}` : ''; + const botReferralLink = info?.bot_referral_link || ''; const { data: terms } = useQuery({ queryKey: ['referral-terms'], @@ -213,13 +214,13 @@ export default function Referral() { ); }, [terms, t, formatAmount, formatPositive, currencySymbol]); - const copyLink = async () => { - if (!referralLink) return; + const copyLink = async (link: string, type: 'cabinet' | 'bot') => { + if (!link) return; try { - await copyToClipboard(referralLink); - setCopied(true); + await copyToClipboard(link); + setCopiedLink(type); if (copyTimerRef.current) clearTimeout(copyTimerRef.current); - copyTimerRef.current = setTimeout(() => setCopied(false), 2000); + copyTimerRef.current = setTimeout(() => setCopiedLink(null), 2000); } catch { // clipboard write failed silently } @@ -315,32 +316,85 @@ export default function Referral() { - {/* Referral Link */} + {/* Referral Links */}

{t('referral.yourLink')}

-
- -
- - +
+ {/* Bot link */} + {botReferralLink && ( +
+
+ + + + {t('referral.botLink')} +
+
+ + +
+
+ )} + {/* Cabinet link */} +
+
+ + + + {t('referral.cabinetLink')} +
+
+ +
+ + +
+

diff --git a/src/types/index.ts b/src/types/index.ts index 20b0d6f..09ca609 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -419,6 +419,7 @@ export interface PaymentMethod { export interface ReferralInfo { referral_code: string; referral_link: string; + bot_referral_link?: string; total_referrals: number; active_referrals: number; total_earnings_kopeks: number;