diff --git a/src/api/partners.ts b/src/api/partners.ts index 7cfffae..45e3bad 100644 --- a/src/api/partners.ts +++ b/src/api/partners.ts @@ -16,10 +16,23 @@ export interface PartnerApplicationInfo { processed_at: string | null; } +export interface PartnerCampaignInfo { + id: number; + name: string; + start_parameter: string; + bonus_type: string; + balance_bonus_kopeks: number; + subscription_duration_days: number | null; + subscription_traffic_gb: number | null; + deep_link: string | null; + web_link: string | null; +} + export interface PartnerStatusResponse { partner_status: string; commission_percent: number | null; latest_application: PartnerApplicationInfo | null; + campaigns: PartnerCampaignInfo[]; } export interface PartnerApplicationRequest { diff --git a/src/locales/en.json b/src/locales/en.json index d019f31..c67989b 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -670,6 +670,12 @@ "applying": "Submitting...", "submitApplication": "Submit Application", "applyError": "Failed to submit application. Please try again.", + "yourCampaigns": "Your campaigns", + "campaignBonus": { + "balance": "+{{amount}} to balance", + "subscription": "{{days}} days subscription", + "tariff": "Bonus tariff" + }, "fields": { "companyName": "Company Name", "companyNamePlaceholder": "Your company or brand name", diff --git a/src/locales/fa.json b/src/locales/fa.json index c50f3ea..64d47b6 100644 --- a/src/locales/fa.json +++ b/src/locales/fa.json @@ -561,6 +561,12 @@ "applying": "در حال ارسال...", "submitApplication": "ارسال درخواست", "applyError": "ارسال درخواست ناموفق بود. لطفاً دوباره تلاش کنید.", + "yourCampaigns": "کمپین‌های شما", + "campaignBonus": { + "balance": "+{{amount}} به موجودی", + "subscription": "{{days}} روز اشتراک", + "tariff": "تعرفه جایزه" + }, "fields": { "companyName": "نام شرکت", "companyNamePlaceholder": "نام شرکت یا برند شما", diff --git a/src/locales/ru.json b/src/locales/ru.json index 64fbd77..c36eab4 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -697,6 +697,12 @@ "applying": "Отправка...", "submitApplication": "Отправить заявку", "applyError": "Не удалось отправить заявку. Попробуйте снова.", + "yourCampaigns": "Ваши кампании", + "campaignBonus": { + "balance": "+{{amount}} на баланс", + "subscription": "{{days}} дн. подписки", + "tariff": "Бонусный тариф" + }, "fields": { "companyName": "Название компании", "companyNamePlaceholder": "Название вашей компании или бренда", diff --git a/src/locales/zh.json b/src/locales/zh.json index ff928ea..00d2b79 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -561,6 +561,12 @@ "applying": "提交中...", "submitApplication": "提交申请", "applyError": "提交申请失败,请重试。", + "yourCampaigns": "您的活动", + "campaignBonus": { + "balance": "+{{amount}} 余额", + "subscription": "{{days}} 天订阅", + "tariff": "奖励套餐" + }, "fields": { "companyName": "公司名称", "companyNamePlaceholder": "您的公司或品牌名称", diff --git a/src/pages/Referral.tsx b/src/pages/Referral.tsx index 42d3c63..8682615 100644 --- a/src/pages/Referral.tsx +++ b/src/pages/Referral.tsx @@ -8,6 +8,16 @@ import { partnerApi } from '../api/partners'; import { withdrawalApi } from '../api/withdrawals'; import { useCurrency } from '../hooks/useCurrency'; +const LinkIcon = () => ( + + + +); + const CopyIcon = () => ( (null); const { data: info, isLoading } = useQuery({ queryKey: ['referral-info'], @@ -508,6 +519,85 @@ export default function Referral() { )} + {/* ==================== Partner Campaigns Section ==================== */} + + {isPartner && partnerStatus?.campaigns && partnerStatus.campaigns.length > 0 && ( +
+
+
+ +
+

+ {t('referral.partner.yourCampaigns')} +

+
+ +
+ {partnerStatus.campaigns.map((campaign) => { + const shareUrl = campaign.deep_link || campaign.web_link || ''; + const isCopied = copiedCampaignId === campaign.id; + + const copyCampaignLink = () => { + if (!shareUrl) return; + navigator.clipboard.writeText(shareUrl); + setCopiedCampaignId(campaign.id); + setTimeout(() => setCopiedCampaignId(null), 2000); + }; + + const bonusBadge = (() => { + switch (campaign.bonus_type) { + case 'balance': + return { + label: t('referral.partner.campaignBonus.balance', { + amount: formatWithCurrency(campaign.balance_bonus_kopeks / 100, 0), + }), + className: 'badge-success', + }; + case 'subscription': + return { + label: t('referral.partner.campaignBonus.subscription', { + days: campaign.subscription_duration_days ?? 0, + }), + className: 'badge-info', + }; + case 'tariff': + return { + label: t('referral.partner.campaignBonus.tariff'), + className: 'badge-info', + }; + default: + return null; + } + })(); + + return ( +
+
+ {campaign.name} + {bonusBadge && {bonusBadge.label}} +
+
+ + +
+
+ ); + })} +
+
+ )} + {/* ==================== Withdrawal Section (approved partners only) ==================== */} {isPartner && (