Spaces:
Paused
Paused
CBV01 commited on
Commit ·
d3be83c
1
Parent(s): 0bfcc32
feat(campaigns): real telegram metrics, fix failed card colors, compact card height, fix account avatar, and accurate group permission detection
Browse files- backend/main.py +53 -28
- frontend/next.config.js +4 -0
- frontend/src/app/campaigns/page.tsx +220 -133
backend/main.py
CHANGED
|
@@ -1095,7 +1095,7 @@ async def get_dialogs(req: FetchDialogsRequest, user_id: str = Depends(get_curre
|
|
| 1095 |
is_group = bool(dialog.is_group)
|
| 1096 |
is_channel = bool(dialog.is_channel)
|
| 1097 |
|
| 1098 |
-
# Fix for Telethon Megagroups (Supergroups)
|
| 1099 |
is_supergroup = False
|
| 1100 |
username = None
|
| 1101 |
participants_count = 0
|
|
@@ -1103,37 +1103,62 @@ async def get_dialogs(req: FetchDialogsRequest, user_id: str = Depends(get_curre
|
|
| 1103 |
try:
|
| 1104 |
if hasattr(dialog, 'entity') and dialog.entity:
|
| 1105 |
ent = dialog.entity
|
| 1106 |
-
|
| 1107 |
-
|
| 1108 |
-
|
| 1109 |
-
|
| 1110 |
-
|
| 1111 |
-
is_broadcast = bool(getattr(ent, 'broadcast', False))
|
| 1112 |
-
is_creator = bool(getattr(ent, 'creator', False))
|
| 1113 |
-
admin_rights = getattr(ent, 'admin_rights', None)
|
| 1114 |
-
default_banned = getattr(ent, 'default_banned_rights', None)
|
| 1115 |
-
banned = getattr(ent, 'banned_rights', None)
|
| 1116 |
-
left = bool(getattr(ent, 'left', False))
|
| 1117 |
-
kicked = bool(getattr(ent, 'kicked', False))
|
| 1118 |
-
deactivated = bool(getattr(ent, 'deactivated', False))
|
| 1119 |
-
|
| 1120 |
-
if left or kicked or deactivated:
|
| 1121 |
can_send = False
|
| 1122 |
-
elif is_creator:
|
| 1123 |
-
can_send = True
|
| 1124 |
-
elif is_broadcast:
|
| 1125 |
-
# Telegram broadcast channel: ONLY admins with post_messages can post
|
| 1126 |
-
can_send = bool(admin_rights and getattr(admin_rights, 'post_messages', False))
|
| 1127 |
else:
|
| 1128 |
-
|
| 1129 |
-
|
| 1130 |
-
|
| 1131 |
-
|
| 1132 |
-
|
| 1133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1134 |
can_send = False
|
| 1135 |
-
|
| 1136 |
can_send = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1137 |
except Exception as perm_err:
|
| 1138 |
log_debug(f"DIALOGS_PERM_CHECK_ERR: {str(perm_err)}")
|
| 1139 |
can_send = False
|
|
|
|
| 1095 |
is_group = bool(dialog.is_group)
|
| 1096 |
is_channel = bool(dialog.is_channel)
|
| 1097 |
|
| 1098 |
+
# Fix for Telethon Megagroups (Supergroups) vs Broadcast Channels vs Basic Groups
|
| 1099 |
is_supergroup = False
|
| 1100 |
username = None
|
| 1101 |
participants_count = 0
|
|
|
|
| 1103 |
try:
|
| 1104 |
if hasattr(dialog, 'entity') and dialog.entity:
|
| 1105 |
ent = dialog.entity
|
| 1106 |
+
ent_class = ent.__class__.__name__
|
| 1107 |
+
|
| 1108 |
+
# If entity is forbidden or empty, user has no access / banned
|
| 1109 |
+
if 'Forbidden' in ent_class or 'Empty' in ent_class:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1110 |
can_send = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1111 |
else:
|
| 1112 |
+
username = getattr(ent, 'username', None)
|
| 1113 |
+
participants_count = getattr(ent, 'participants_count', 0) or 0
|
| 1114 |
+
|
| 1115 |
+
# In Telegram TL, supergroups have megagroup=True
|
| 1116 |
+
if is_channel and hasattr(ent, 'megagroup'):
|
| 1117 |
+
is_supergroup = bool(ent.megagroup) # type: ignore
|
| 1118 |
+
|
| 1119 |
+
# Any channel that is not a supergroup IS a broadcast channel
|
| 1120 |
+
is_broadcast = bool(getattr(ent, 'broadcast', False)) or (is_channel and not is_supergroup)
|
| 1121 |
+
is_creator = bool(getattr(ent, 'creator', False))
|
| 1122 |
+
admin_rights = getattr(ent, 'admin_rights', None)
|
| 1123 |
+
default_banned = getattr(ent, 'default_banned_rights', None)
|
| 1124 |
+
banned = getattr(ent, 'banned_rights', None)
|
| 1125 |
+
left = bool(getattr(ent, 'left', False))
|
| 1126 |
+
kicked = bool(getattr(ent, 'kicked', False))
|
| 1127 |
+
deactivated = bool(getattr(ent, 'deactivated', False))
|
| 1128 |
+
restricted = bool(getattr(ent, 'restricted', False))
|
| 1129 |
+
migrated_to = getattr(ent, 'migrated_to', None)
|
| 1130 |
+
|
| 1131 |
+
if left or kicked or deactivated or restricted or (migrated_to is not None):
|
| 1132 |
can_send = False
|
| 1133 |
+
elif is_creator:
|
| 1134 |
can_send = True
|
| 1135 |
+
elif is_broadcast:
|
| 1136 |
+
# Telegram broadcast channel: ONLY admins with post_messages can broadcast
|
| 1137 |
+
can_send = bool(admin_rights and getattr(admin_rights, 'post_messages', False))
|
| 1138 |
+
else:
|
| 1139 |
+
# Group / Supergroup
|
| 1140 |
+
if admin_rights:
|
| 1141 |
+
can_send = True
|
| 1142 |
+
else:
|
| 1143 |
+
# Check if group has banned regular members from sending messages
|
| 1144 |
+
banned_by_default = False
|
| 1145 |
+
if default_banned:
|
| 1146 |
+
if (getattr(default_banned, 'send_messages', False) or
|
| 1147 |
+
getattr(default_banned, 'send_plain', False)):
|
| 1148 |
+
banned_by_default = True
|
| 1149 |
+
|
| 1150 |
+
# Check if this user specifically has banned rights
|
| 1151 |
+
user_banned = False
|
| 1152 |
+
if banned:
|
| 1153 |
+
if (getattr(banned, 'send_messages', False) or
|
| 1154 |
+
getattr(banned, 'send_plain', False) or
|
| 1155 |
+
getattr(banned, 'view_messages', False)):
|
| 1156 |
+
user_banned = True
|
| 1157 |
+
|
| 1158 |
+
if banned_by_default or user_banned:
|
| 1159 |
+
can_send = False
|
| 1160 |
+
else:
|
| 1161 |
+
can_send = True
|
| 1162 |
except Exception as perm_err:
|
| 1163 |
log_debug(f"DIALOGS_PERM_CHECK_ERR: {str(perm_err)}")
|
| 1164 |
can_send = False
|
frontend/next.config.js
CHANGED
|
@@ -7,6 +7,10 @@ const nextConfig = {
|
|
| 7 |
source: '/api/:path*',
|
| 8 |
destination: `${normalized}/api/:path*`,
|
| 9 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
];
|
| 11 |
},
|
| 12 |
};
|
|
|
|
| 7 |
source: '/api/:path*',
|
| 8 |
destination: `${normalized}/api/:path*`,
|
| 9 |
},
|
| 10 |
+
{
|
| 11 |
+
source: '/static/:path*',
|
| 12 |
+
destination: `${normalized}/static/:path*`,
|
| 13 |
+
},
|
| 14 |
];
|
| 15 |
},
|
| 16 |
};
|
frontend/src/app/campaigns/page.tsx
CHANGED
|
@@ -34,11 +34,56 @@ import {
|
|
| 34 |
Filter,
|
| 35 |
Smartphone
|
| 36 |
} from 'lucide-react';
|
| 37 |
-
import { apiFetch } from '@/lib/auth';
|
| 38 |
import { Preloader } from '@/components/Preloader';
|
| 39 |
import { SpintaxModal } from '@/components/SpintaxModal';
|
| 40 |
import { TemplateAiAssistantModal } from '@/components/TemplateAiAssistantModal';
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
export default function CampaignsPage() {
|
| 43 |
const [isCreating, setIsCreating] = useState(false);
|
| 44 |
const [campaigns, setCampaigns] = useState<any[]>([]);
|
|
@@ -514,7 +559,7 @@ export default function CampaignsPage() {
|
|
| 514 |
accentText: 'text-[#2dd4bf]',
|
| 515 |
ringColor: '#2dd4bf',
|
| 516 |
statusText: 'COMPLETED',
|
| 517 |
-
actionBtn: 'bg-
|
| 518 |
};
|
| 519 |
case 'processing':
|
| 520 |
case 'active':
|
|
@@ -538,7 +583,7 @@ export default function CampaignsPage() {
|
|
| 538 |
accentText: 'text-[#fbbf24]',
|
| 539 |
ringColor: '#fbbf24',
|
| 540 |
statusText: 'PAUSED',
|
| 541 |
-
actionBtn: 'bg-
|
| 542 |
};
|
| 543 |
case 'failed':
|
| 544 |
case 'error':
|
|
@@ -550,18 +595,18 @@ export default function CampaignsPage() {
|
|
| 550 |
accentText: 'text-[#fb7185]',
|
| 551 |
ringColor: '#fb7185',
|
| 552 |
statusText: 'FAILED',
|
| 553 |
-
actionBtn: 'bg-rose-
|
| 554 |
};
|
| 555 |
default:
|
| 556 |
return {
|
| 557 |
-
topBeamColor: 'from-transparent via-
|
| 558 |
-
radialGlow: '
|
| 559 |
-
iconBg: 'bg-[#
|
| 560 |
-
dotColor: 'bg-
|
| 561 |
-
accentText: 'text-
|
| 562 |
-
ringColor: '#
|
| 563 |
statusText: status ? status.toUpperCase() : 'DRAFT',
|
| 564 |
-
actionBtn: 'bg-
|
| 565 |
};
|
| 566 |
}
|
| 567 |
};
|
|
@@ -706,12 +751,13 @@ export default function CampaignsPage() {
|
|
| 706 |
</div>
|
| 707 |
) : viewMode === 'grid' ? (
|
| 708 |
/* Natural Modern Grid Cards - Two Per Line (Matching Screenshot) */
|
| 709 |
-
<div className="grid grid-cols-1 lg:grid-cols-2 gap-5">
|
| 710 |
{filteredCampaigns.map((camp) => {
|
| 711 |
const progressPct = Math.min(100, Math.round(((camp.sent_count || 0) / Math.max(1, camp.total_targets || 1)) * 100));
|
| 712 |
let failedCount = 0;
|
| 713 |
try {
|
| 714 |
-
|
|
|
|
| 715 |
} catch (e) { }
|
| 716 |
|
| 717 |
let parsedGroups: string[] = [];
|
|
@@ -729,7 +775,7 @@ export default function CampaignsPage() {
|
|
| 729 |
? (senderAccount.first_name ? `${senderAccount.first_name} ${senderAccount.last_name || ''}`.trim() : (senderAccount.username ? `@${senderAccount.username}` : senderAccount.phone_number))
|
| 730 |
: (camp.phone_number || "Telegram Fleet Node");
|
| 731 |
|
| 732 |
-
const radius =
|
| 733 |
const circumference = 2 * Math.PI * radius;
|
| 734 |
const strokeDashoffset = circumference - (progressPct / 100) * circumference;
|
| 735 |
|
|
@@ -747,7 +793,7 @@ export default function CampaignsPage() {
|
|
| 747 |
return (
|
| 748 |
<div
|
| 749 |
key={camp.id}
|
| 750 |
-
className="relative rounded-2xl bg-[#111513] border border-white/[0.05] p-
|
| 751 |
style={{ backgroundImage: cardStyle.radialGlow !== 'none' ? cardStyle.radialGlow : undefined }}
|
| 752 |
>
|
| 753 |
{/* Angled Glowing Top Beam */}
|
|
@@ -757,19 +803,19 @@ export default function CampaignsPage() {
|
|
| 757 |
|
| 758 |
<div>
|
| 759 |
{/* Header: Icon, Title, Status & Action Button */}
|
| 760 |
-
<div className="flex items-start justify-between gap-3 mb-2
|
| 761 |
-
<div className="flex items-center gap-
|
| 762 |
{/* Status Icon with Lightning Badge */}
|
| 763 |
-
<div className={`w-
|
| 764 |
-
<Zap size={
|
| 765 |
</div>
|
| 766 |
<div className="min-w-0">
|
| 767 |
-
<h3 className="font-bold text-white text-base tracking-tight truncate leading-
|
| 768 |
{camp.name || "Broadcast Campaign"}
|
| 769 |
</h3>
|
| 770 |
-
<div className="flex items-center gap-
|
| 771 |
-
<span className={`w-
|
| 772 |
-
<span className={`text-[
|
| 773 |
{cardStyle.statusText}
|
| 774 |
</span>
|
| 775 |
</div>
|
|
@@ -778,92 +824,106 @@ export default function CampaignsPage() {
|
|
| 778 |
|
| 779 |
{/* Action Button & Menu */}
|
| 780 |
<div className="flex items-center gap-1 shrink-0">
|
| 781 |
-
{camp.status
|
| 782 |
<button
|
| 783 |
onClick={() => handleTogglePause(camp.id)}
|
| 784 |
-
className=
|
| 785 |
-
title=
|
| 786 |
>
|
| 787 |
-
{
|
| 788 |
-
|
| 789 |
-
<Play size={12} className="fill-current" />
|
| 790 |
-
<span>RESUME</span>
|
| 791 |
-
</>
|
| 792 |
-
) : (
|
| 793 |
-
<>
|
| 794 |
-
<Pause size={12} />
|
| 795 |
-
<span>PAUSE</span>
|
| 796 |
-
</>
|
| 797 |
-
)}
|
| 798 |
</button>
|
| 799 |
-
) : (
|
| 800 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 801 |
COMPLETED
|
| 802 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 803 |
)}
|
| 804 |
|
| 805 |
<button
|
| 806 |
onClick={() => handleEdit(camp)}
|
| 807 |
-
className="p-1
|
| 808 |
title="Edit Campaign"
|
| 809 |
>
|
| 810 |
-
<Edit3 size={
|
| 811 |
</button>
|
| 812 |
<button
|
| 813 |
onClick={() => handleDelete(camp.id)}
|
| 814 |
-
className="p-1
|
| 815 |
title="Delete Campaign"
|
| 816 |
>
|
| 817 |
-
<Trash2 size={
|
| 818 |
</button>
|
| 819 |
</div>
|
| 820 |
</div>
|
| 821 |
|
| 822 |
-
{/* Meta Row: Sender Account & Date
|
| 823 |
-
<div className="flex flex-wrap items-center gap-2 text-
|
| 824 |
-
<div className="flex items-center gap-1.5
|
| 825 |
-
<
|
| 826 |
-
|
| 827 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 828 |
</div>
|
| 829 |
|
| 830 |
-
<span className="text-neutral-
|
| 831 |
|
| 832 |
-
<div className="flex items-center gap-1
|
| 833 |
-
<Calendar size={
|
| 834 |
<span>{formattedDate}</span>
|
| 835 |
</div>
|
| 836 |
|
| 837 |
{camp.media_url && (
|
| 838 |
<>
|
| 839 |
-
<span className="text-neutral-
|
| 840 |
-
<span className="flex items-center gap-1 text-[
|
| 841 |
-
<Paperclip size={
|
| 842 |
</span>
|
| 843 |
</>
|
| 844 |
)}
|
| 845 |
</div>
|
| 846 |
|
| 847 |
-
{/* Middle Section: Circular Gauge + 4
|
| 848 |
-
<div className="flex items-center gap-
|
| 849 |
{/* Circular Progress Gauge */}
|
| 850 |
-
<div className="relative w-
|
| 851 |
-
<svg className="w-
|
| 852 |
<circle
|
| 853 |
-
cx="
|
| 854 |
-
cy="
|
| 855 |
r={radius}
|
| 856 |
stroke="currentColor"
|
| 857 |
-
strokeWidth="5"
|
| 858 |
fill="transparent"
|
| 859 |
-
className="text-white/[0.
|
| 860 |
/>
|
| 861 |
<circle
|
| 862 |
-
cx="
|
| 863 |
-
cy="
|
| 864 |
r={radius}
|
| 865 |
stroke={cardStyle.ringColor}
|
| 866 |
-
strokeWidth="5"
|
| 867 |
strokeDasharray={circumference}
|
| 868 |
strokeDashoffset={strokeDashoffset}
|
| 869 |
strokeLinecap="round"
|
|
@@ -872,73 +932,77 @@ export default function CampaignsPage() {
|
|
| 872 |
/>
|
| 873 |
</svg>
|
| 874 |
<div className="absolute inset-0 flex items-center justify-center">
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 878 |
</div>
|
| 879 |
</div>
|
| 880 |
|
| 881 |
-
{/* 2x2 Metric Grid (
|
| 882 |
-
<div className="grid grid-cols-2 gap-
|
| 883 |
-
<div className="bg-white/[0.03] rounded-
|
| 884 |
-
<div className="text-[
|
| 885 |
-
|
| 886 |
</div>
|
| 887 |
-
<div className="text-
|
| 888 |
-
{camp.total_targets || 0}
|
| 889 |
</div>
|
| 890 |
</div>
|
| 891 |
|
| 892 |
-
<div className="bg-white/[0.03] rounded-
|
| 893 |
-
<div className="text-[
|
| 894 |
-
|
| 895 |
</div>
|
| 896 |
-
<div className="text-
|
| 897 |
{camp.sent_count || 0}
|
| 898 |
</div>
|
| 899 |
</div>
|
| 900 |
|
| 901 |
-
<div className="bg-white/[0.03] rounded-
|
| 902 |
-
<div className="text-[
|
| 903 |
-
<span>
|
| 904 |
{failedCount > 0 && (
|
| 905 |
-
<span className="text-[
|
| 906 |
{failedCount} err
|
| 907 |
</span>
|
| 908 |
)}
|
| 909 |
</div>
|
| 910 |
-
<div className=
|
| 911 |
{progressPct}%
|
| 912 |
</div>
|
| 913 |
</div>
|
| 914 |
|
| 915 |
-
<div className="bg-white/[0.03] rounded-
|
| 916 |
-
<div className="text-[
|
| 917 |
-
|
| 918 |
</div>
|
| 919 |
-
<div className="text-
|
| 920 |
{camp.interval_hours > 0 || camp.interval_minutes > 0
|
| 921 |
-
? `${camp.interval_hours > 0 ? `${camp.interval_hours}h ` : ''}${camp.interval_minutes > 0 ? `${camp.interval_minutes}m` : ''}`
|
| 922 |
-
: 'Single'}
|
| 923 |
</div>
|
| 924 |
</div>
|
| 925 |
</div>
|
| 926 |
</div>
|
| 927 |
|
| 928 |
{/* Message Snippet */}
|
| 929 |
-
<div className="mt-
|
| 930 |
"{camp.message_text || camp.message || '...'}"
|
| 931 |
</div>
|
| 932 |
</div>
|
| 933 |
|
| 934 |
{/* Footer: Target Entities */}
|
| 935 |
-
<div className="mt-
|
| 936 |
<div className="flex items-center gap-1.5">
|
| 937 |
-
<Users size={
|
| 938 |
<span>{parsedGroups.length} Telegram {parsedGroups.length === 1 ? 'Target' : 'Targets'}</span>
|
| 939 |
</div>
|
| 940 |
{camp.batch_number && camp.batch_number > 1 && (
|
| 941 |
-
<span className="text-[
|
| 942 |
)}
|
| 943 |
</div>
|
| 944 |
</div>
|
|
@@ -947,7 +1011,7 @@ export default function CampaignsPage() {
|
|
| 947 |
</div>
|
| 948 |
) : (
|
| 949 |
/* List View Upgraded */
|
| 950 |
-
<div className="space-y-
|
| 951 |
{filteredCampaigns.map((camp) => {
|
| 952 |
const progressPct = Math.min(100, Math.round(((camp.sent_count || 0) / Math.max(1, camp.total_targets || 1)) * 100));
|
| 953 |
const cardStyle = getCampaignCardStyle(camp.status);
|
|
@@ -959,32 +1023,37 @@ export default function CampaignsPage() {
|
|
| 959 |
return (
|
| 960 |
<div
|
| 961 |
key={camp.id}
|
| 962 |
-
className="relative rounded-2xl bg-[#111513] border border-white/[0.05] p-4 transition-all flex flex-col md:flex-row md:items-center justify-between gap-
|
| 963 |
style={{ backgroundImage: cardStyle.radialGlow !== 'none' ? cardStyle.radialGlow : undefined }}
|
| 964 |
>
|
| 965 |
{/* Angled Glowing Top Beam */}
|
| 966 |
<div
|
| 967 |
className={`absolute -top-px left-[20%] right-[20%] h-[2px] bg-gradient-to-r ${cardStyle.topBeamColor} pointer-events-none`}
|
| 968 |
/>
|
| 969 |
-
<div className="flex items-center gap-3
|
| 970 |
-
<div className={`w-
|
| 971 |
-
<Zap size={
|
| 972 |
</div>
|
| 973 |
<div className="min-w-0">
|
| 974 |
<div className="flex items-center gap-2">
|
| 975 |
<h4 className="font-bold text-white text-sm tracking-tight truncate">{camp.name || "Broadcast Campaign"}</h4>
|
| 976 |
-
<span className={`w-
|
| 977 |
<span className={`text-[9px] font-bold uppercase tracking-wider ${cardStyle.accentText}`}>{cardStyle.statusText}</span>
|
| 978 |
</div>
|
| 979 |
-
<div className="flex flex-wrap items-center gap-2
|
| 980 |
-
<
|
| 981 |
-
<
|
| 982 |
-
|
| 983 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 984 |
<span>•</span>
|
| 985 |
<span className="font-mono text-neutral-500">{camp.phone_number}</span>
|
| 986 |
<span>•</span>
|
| 987 |
-
<span>{camp.sent_count || 0} / {camp.total_targets || 0}
|
| 988 |
{camp.media_url && (
|
| 989 |
<>
|
| 990 |
<span>•</span>
|
|
@@ -997,30 +1066,52 @@ export default function CampaignsPage() {
|
|
| 997 |
</div>
|
| 998 |
</div>
|
| 999 |
|
| 1000 |
-
<div className="flex items-center gap-2
|
| 1001 |
-
{camp.status
|
| 1002 |
<button
|
| 1003 |
onClick={() => handleTogglePause(camp.id)}
|
| 1004 |
-
className=
|
| 1005 |
-
title=
|
| 1006 |
>
|
| 1007 |
-
|
| 1008 |
-
<span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1009 |
</button>
|
| 1010 |
)}
|
| 1011 |
<button
|
| 1012 |
onClick={() => handleEdit(camp)}
|
| 1013 |
-
className="p-1
|
| 1014 |
title="Edit"
|
| 1015 |
>
|
| 1016 |
-
<Edit3 size={
|
| 1017 |
</button>
|
| 1018 |
<button
|
| 1019 |
onClick={() => handleDelete(camp.id)}
|
| 1020 |
-
className="p-1
|
| 1021 |
title="Delete"
|
| 1022 |
>
|
| 1023 |
-
<Trash2 size={
|
| 1024 |
</button>
|
| 1025 |
</div>
|
| 1026 |
</div>
|
|
@@ -1131,14 +1222,12 @@ export default function CampaignsPage() {
|
|
| 1131 |
<div className="flex items-center gap-2.5 min-w-0">
|
| 1132 |
{selectedAcc ? (
|
| 1133 |
<>
|
| 1134 |
-
<
|
| 1135 |
-
{selectedAcc.profile_photo
|
| 1136 |
-
|
| 1137 |
-
|
| 1138 |
-
|
| 1139 |
-
|
| 1140 |
-
<span className="absolute -bottom-0.5 -right-0.5 w-2 h-2 rounded-full bg-emerald-400 ring-1 ring-card" />
|
| 1141 |
-
</div>
|
| 1142 |
<div className="text-left truncate">
|
| 1143 |
<span className="font-bold text-foreground block truncate leading-tight">
|
| 1144 |
{selectedAcc.first_name ? `${selectedAcc.first_name} ${selectedAcc.last_name || ''}` : selectedAcc.phone_number}
|
|
@@ -1176,14 +1265,12 @@ export default function CampaignsPage() {
|
|
| 1176 |
}`}
|
| 1177 |
>
|
| 1178 |
<div className="flex items-center gap-2.5 min-w-0">
|
| 1179 |
-
<
|
| 1180 |
-
{acc.profile_photo
|
| 1181 |
-
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
<span className="absolute -bottom-0.5 -right-0.5 w-2 h-2 rounded-full bg-emerald-400 ring-1 ring-card" />
|
| 1186 |
-
</div>
|
| 1187 |
<div className="text-left min-w-0">
|
| 1188 |
<div className="font-bold text-xs truncate text-foreground flex items-center gap-1.5">
|
| 1189 |
<span>{acc.first_name ? `${acc.first_name} ${acc.last_name || ''}` : acc.phone_number}</span>
|
|
|
|
| 34 |
Filter,
|
| 35 |
Smartphone
|
| 36 |
} from 'lucide-react';
|
| 37 |
+
import { apiFetch, getApiBase } from '@/lib/auth';
|
| 38 |
import { Preloader } from '@/components/Preloader';
|
| 39 |
import { SpintaxModal } from '@/components/SpintaxModal';
|
| 40 |
import { TemplateAiAssistantModal } from '@/components/TemplateAiAssistantModal';
|
| 41 |
|
| 42 |
+
function TelegramAvatar({
|
| 43 |
+
photo,
|
| 44 |
+
name,
|
| 45 |
+
phone,
|
| 46 |
+
size = "w-7 h-7 text-xs",
|
| 47 |
+
ringClass = "border-indigo-500/30"
|
| 48 |
+
}: {
|
| 49 |
+
photo?: string | null;
|
| 50 |
+
name?: string;
|
| 51 |
+
phone?: string;
|
| 52 |
+
size?: string;
|
| 53 |
+
ringClass?: string;
|
| 54 |
+
}) {
|
| 55 |
+
const [hasError, setHasError] = React.useState(false);
|
| 56 |
+
const initial = (name?.trim()?.charAt(0) || phone?.slice(-2) || 'A').toUpperCase();
|
| 57 |
+
|
| 58 |
+
const resolvedSrc = React.useMemo(() => {
|
| 59 |
+
if (!photo || hasError) return null;
|
| 60 |
+
if (photo.startsWith('http://') || photo.startsWith('https://')) return photo;
|
| 61 |
+
try {
|
| 62 |
+
const apiBase = getApiBase();
|
| 63 |
+
const cleanPath = photo.startsWith('/') ? photo : `/${photo}`;
|
| 64 |
+
return `${apiBase}${cleanPath}`;
|
| 65 |
+
} catch {
|
| 66 |
+
return photo;
|
| 67 |
+
}
|
| 68 |
+
}, [photo, hasError]);
|
| 69 |
+
|
| 70 |
+
return (
|
| 71 |
+
<div className={`relative ${size} rounded-lg bg-gradient-to-br from-indigo-500/20 via-purple-500/15 to-indigo-600/20 text-indigo-300 font-bold flex items-center justify-center shrink-0 border ${ringClass} overflow-hidden shadow-xs select-none`}>
|
| 72 |
+
{resolvedSrc ? (
|
| 73 |
+
<img
|
| 74 |
+
src={resolvedSrc}
|
| 75 |
+
alt={name || 'Account'}
|
| 76 |
+
className="w-full h-full object-cover"
|
| 77 |
+
onError={() => setHasError(true)}
|
| 78 |
+
/>
|
| 79 |
+
) : (
|
| 80 |
+
<span className="leading-none">{initial}</span>
|
| 81 |
+
)}
|
| 82 |
+
<span className="absolute -bottom-0.5 -right-0.5 w-2 h-2 rounded-full bg-emerald-400 ring-1 ring-[#111513]" />
|
| 83 |
+
</div>
|
| 84 |
+
);
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
export default function CampaignsPage() {
|
| 88 |
const [isCreating, setIsCreating] = useState(false);
|
| 89 |
const [campaigns, setCampaigns] = useState<any[]>([]);
|
|
|
|
| 559 |
accentText: 'text-[#2dd4bf]',
|
| 560 |
ringColor: '#2dd4bf',
|
| 561 |
statusText: 'COMPLETED',
|
| 562 |
+
actionBtn: 'bg-teal-500/15 text-teal-300 hover:bg-teal-500/25 border border-teal-500/30'
|
| 563 |
};
|
| 564 |
case 'processing':
|
| 565 |
case 'active':
|
|
|
|
| 583 |
accentText: 'text-[#fbbf24]',
|
| 584 |
ringColor: '#fbbf24',
|
| 585 |
statusText: 'PAUSED',
|
| 586 |
+
actionBtn: 'bg-amber-500/15 text-amber-300 hover:bg-amber-500/25 border border-amber-500/30'
|
| 587 |
};
|
| 588 |
case 'failed':
|
| 589 |
case 'error':
|
|
|
|
| 595 |
accentText: 'text-[#fb7185]',
|
| 596 |
ringColor: '#fb7185',
|
| 597 |
statusText: 'FAILED',
|
| 598 |
+
actionBtn: 'bg-rose-500/15 text-rose-300 hover:bg-rose-500/25 border border-rose-500/30'
|
| 599 |
};
|
| 600 |
default:
|
| 601 |
return {
|
| 602 |
+
topBeamColor: 'from-transparent via-sky-400/60 to-transparent',
|
| 603 |
+
radialGlow: 'radial-gradient(circle at 50% -20%, rgba(56, 189, 248, 0.08) 0%, transparent 60%)',
|
| 604 |
+
iconBg: 'bg-[#10222a] text-[#38bdf8]',
|
| 605 |
+
dotColor: 'bg-[#38bdf8]',
|
| 606 |
+
accentText: 'text-[#38bdf8]',
|
| 607 |
+
ringColor: '#38bdf8',
|
| 608 |
statusText: status ? status.toUpperCase() : 'DRAFT',
|
| 609 |
+
actionBtn: 'bg-sky-500/15 text-sky-300 hover:bg-sky-500/25 border border-sky-500/30'
|
| 610 |
};
|
| 611 |
}
|
| 612 |
};
|
|
|
|
| 751 |
</div>
|
| 752 |
) : viewMode === 'grid' ? (
|
| 753 |
/* Natural Modern Grid Cards - Two Per Line (Matching Screenshot) */
|
| 754 |
+
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4.5">
|
| 755 |
{filteredCampaigns.map((camp) => {
|
| 756 |
const progressPct = Math.min(100, Math.round(((camp.sent_count || 0) / Math.max(1, camp.total_targets || 1)) * 100));
|
| 757 |
let failedCount = 0;
|
| 758 |
try {
|
| 759 |
+
const parsedFailed = JSON.parse(camp.failed_groups || '[]');
|
| 760 |
+
failedCount = Array.isArray(parsedFailed) ? parsedFailed.length : 0;
|
| 761 |
} catch (e) { }
|
| 762 |
|
| 763 |
let parsedGroups: string[] = [];
|
|
|
|
| 775 |
? (senderAccount.first_name ? `${senderAccount.first_name} ${senderAccount.last_name || ''}`.trim() : (senderAccount.username ? `@${senderAccount.username}` : senderAccount.phone_number))
|
| 776 |
: (camp.phone_number || "Telegram Fleet Node");
|
| 777 |
|
| 778 |
+
const radius = 22;
|
| 779 |
const circumference = 2 * Math.PI * radius;
|
| 780 |
const strokeDashoffset = circumference - (progressPct / 100) * circumference;
|
| 781 |
|
|
|
|
| 793 |
return (
|
| 794 |
<div
|
| 795 |
key={camp.id}
|
| 796 |
+
className="relative rounded-2xl bg-[#111513] border border-white/[0.05] p-4 sm:p-5 transition-all duration-300 hover:translate-y-[-2px] flex flex-col justify-between group/card shadow-sm overflow-hidden"
|
| 797 |
style={{ backgroundImage: cardStyle.radialGlow !== 'none' ? cardStyle.radialGlow : undefined }}
|
| 798 |
>
|
| 799 |
{/* Angled Glowing Top Beam */}
|
|
|
|
| 803 |
|
| 804 |
<div>
|
| 805 |
{/* Header: Icon, Title, Status & Action Button */}
|
| 806 |
+
<div className="flex items-start justify-between gap-3 mb-2">
|
| 807 |
+
<div className="flex items-center gap-2.5 min-w-0">
|
| 808 |
{/* Status Icon with Lightning Badge */}
|
| 809 |
+
<div className={`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${cardStyle.iconBg}`}>
|
| 810 |
+
<Zap size={16} className="fill-current" />
|
| 811 |
</div>
|
| 812 |
<div className="min-w-0">
|
| 813 |
+
<h3 className="font-bold text-white text-sm sm:text-base tracking-tight truncate leading-tight">
|
| 814 |
{camp.name || "Broadcast Campaign"}
|
| 815 |
</h3>
|
| 816 |
+
<div className="flex items-center gap-1.5 mt-0.5">
|
| 817 |
+
<span className={`w-1.5 h-1.5 rounded-full ${cardStyle.dotColor}`} />
|
| 818 |
+
<span className={`text-[10px] font-bold uppercase tracking-wider ${cardStyle.accentText}`}>
|
| 819 |
{cardStyle.statusText}
|
| 820 |
</span>
|
| 821 |
</div>
|
|
|
|
| 824 |
|
| 825 |
{/* Action Button & Menu */}
|
| 826 |
<div className="flex items-center gap-1 shrink-0">
|
| 827 |
+
{camp.status === 'failed' || camp.status === 'error' ? (
|
| 828 |
<button
|
| 829 |
onClick={() => handleTogglePause(camp.id)}
|
| 830 |
+
className="px-2.5 py-1 rounded-lg text-xs font-semibold tracking-wide transition-all flex items-center gap-1.5 cursor-pointer bg-rose-500/15 text-rose-300 hover:bg-rose-500/25 border border-rose-500/30"
|
| 831 |
+
title="Retry Failed Campaign"
|
| 832 |
>
|
| 833 |
+
<Play size={11} className="fill-current text-rose-400" />
|
| 834 |
+
<span>RETRY</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 835 |
</button>
|
| 836 |
+
) : camp.status === 'paused' ? (
|
| 837 |
+
<button
|
| 838 |
+
onClick={() => handleTogglePause(camp.id)}
|
| 839 |
+
className="px-2.5 py-1 rounded-lg text-xs font-semibold tracking-wide transition-all flex items-center gap-1.5 cursor-pointer bg-amber-500/15 text-amber-300 hover:bg-amber-500/25 border border-amber-500/30"
|
| 840 |
+
title="Resume Campaign"
|
| 841 |
+
>
|
| 842 |
+
<Play size={11} className="fill-current text-amber-400" />
|
| 843 |
+
<span>RESUME</span>
|
| 844 |
+
</button>
|
| 845 |
+
) : camp.status === 'completed' ? (
|
| 846 |
+
<div className="px-2.5 py-1 rounded-lg text-xs font-semibold text-teal-300 bg-teal-500/15 border border-teal-500/30">
|
| 847 |
COMPLETED
|
| 848 |
</div>
|
| 849 |
+
) : (
|
| 850 |
+
<button
|
| 851 |
+
onClick={() => handleTogglePause(camp.id)}
|
| 852 |
+
className="px-2.5 py-1 rounded-lg text-xs font-semibold tracking-wide transition-all flex items-center gap-1.5 cursor-pointer bg-white/[0.04] text-neutral-300 hover:bg-white/[0.08] border border-white/[0.08]"
|
| 853 |
+
title="Pause Campaign"
|
| 854 |
+
>
|
| 855 |
+
<Pause size={11} />
|
| 856 |
+
<span>PAUSE</span>
|
| 857 |
+
</button>
|
| 858 |
)}
|
| 859 |
|
| 860 |
<button
|
| 861 |
onClick={() => handleEdit(camp)}
|
| 862 |
+
className="p-1 text-neutral-500 hover:text-white rounded-lg transition-colors cursor-pointer"
|
| 863 |
title="Edit Campaign"
|
| 864 |
>
|
| 865 |
+
<Edit3 size={13} />
|
| 866 |
</button>
|
| 867 |
<button
|
| 868 |
onClick={() => handleDelete(camp.id)}
|
| 869 |
+
className="p-1 text-neutral-500 hover:text-rose-400 rounded-lg transition-colors cursor-pointer"
|
| 870 |
title="Delete Campaign"
|
| 871 |
>
|
| 872 |
+
<Trash2 size={13} />
|
| 873 |
</button>
|
| 874 |
</div>
|
| 875 |
</div>
|
| 876 |
|
| 877 |
+
{/* Meta Row: Sender Account Avatar & Date */}
|
| 878 |
+
<div className="flex flex-wrap items-center gap-2 text-[11px] text-neutral-400 mt-1 mb-2.5 font-normal">
|
| 879 |
+
<div className="flex items-center gap-1.5 min-w-0 max-w-[260px]">
|
| 880 |
+
<TelegramAvatar
|
| 881 |
+
photo={senderAccount?.profile_photo}
|
| 882 |
+
name={senderAccount?.first_name || camp.phone_number}
|
| 883 |
+
phone={camp.phone_number}
|
| 884 |
+
size="w-5 h-5 text-[9px]"
|
| 885 |
+
/>
|
| 886 |
+
<span className="text-neutral-200 font-semibold truncate">{accountDisplayName}</span>
|
| 887 |
+
<span className="text-neutral-500 font-mono text-[10px] shrink-0">({camp.phone_number})</span>
|
| 888 |
</div>
|
| 889 |
|
| 890 |
+
<span className="text-neutral-700">|</span>
|
| 891 |
|
| 892 |
+
<div className="flex items-center gap-1 shrink-0 text-neutral-400">
|
| 893 |
+
<Calendar size={11} className="text-neutral-500" />
|
| 894 |
<span>{formattedDate}</span>
|
| 895 |
</div>
|
| 896 |
|
| 897 |
{camp.media_url && (
|
| 898 |
<>
|
| 899 |
+
<span className="text-neutral-700">|</span>
|
| 900 |
+
<span className="flex items-center gap-1 text-[10px] font-bold text-indigo-400">
|
| 901 |
+
<Paperclip size={10} /> Media
|
| 902 |
</span>
|
| 903 |
</>
|
| 904 |
)}
|
| 905 |
</div>
|
| 906 |
|
| 907 |
+
{/* Middle Section: Circular Gauge + 4 Real Telegram Metric Tiles */}
|
| 908 |
+
<div className="flex items-center gap-3 my-1">
|
| 909 |
{/* Circular Progress Gauge */}
|
| 910 |
+
<div className="relative w-14 h-14 shrink-0 flex items-center justify-center">
|
| 911 |
+
<svg className="w-14 h-14 -rotate-90" viewBox="0 0 56 56">
|
| 912 |
<circle
|
| 913 |
+
cx="28"
|
| 914 |
+
cy="28"
|
| 915 |
r={radius}
|
| 916 |
stroke="currentColor"
|
| 917 |
+
strokeWidth="4.5"
|
| 918 |
fill="transparent"
|
| 919 |
+
className="text-white/[0.06]"
|
| 920 |
/>
|
| 921 |
<circle
|
| 922 |
+
cx="28"
|
| 923 |
+
cy="28"
|
| 924 |
r={radius}
|
| 925 |
stroke={cardStyle.ringColor}
|
| 926 |
+
strokeWidth="4.5"
|
| 927 |
strokeDasharray={circumference}
|
| 928 |
strokeDashoffset={strokeDashoffset}
|
| 929 |
strokeLinecap="round"
|
|
|
|
| 932 |
/>
|
| 933 |
</svg>
|
| 934 |
<div className="absolute inset-0 flex items-center justify-center">
|
| 935 |
+
{camp.status === 'failed' || camp.status === 'error' ? (
|
| 936 |
+
<span className="text-[10px] font-black font-mono text-rose-400">FAILED</span>
|
| 937 |
+
) : ['pending', 'scheduled', 'draft'].includes(camp.status) && progressPct === 0 ? (
|
| 938 |
+
<span className="text-[10px] font-bold font-mono text-neutral-400">DRAFT</span>
|
| 939 |
+
) : (
|
| 940 |
+
<span className="text-[11px] font-bold font-mono text-white">{progressPct}%</span>
|
| 941 |
+
)}
|
| 942 |
</div>
|
| 943 |
</div>
|
| 944 |
|
| 945 |
+
{/* 2x2 Metric Grid (Real Telegram Broadcast Metrics) */}
|
| 946 |
+
<div className="grid grid-cols-2 gap-1.5 flex-1">
|
| 947 |
+
<div className="bg-white/[0.03] rounded-lg px-2.5 py-1.5">
|
| 948 |
+
<div className="text-[9px] font-bold uppercase tracking-wider text-neutral-400">
|
| 949 |
+
Target Groups
|
| 950 |
</div>
|
| 951 |
+
<div className="text-sm font-bold text-white font-mono mt-0.5">
|
| 952 |
+
{camp.total_targets || parsedGroups.length || 0}
|
| 953 |
</div>
|
| 954 |
</div>
|
| 955 |
|
| 956 |
+
<div className="bg-white/[0.03] rounded-lg px-2.5 py-1.5">
|
| 957 |
+
<div className="text-[9px] font-bold uppercase tracking-wider text-neutral-400">
|
| 958 |
+
Delivered
|
| 959 |
</div>
|
| 960 |
+
<div className="text-sm font-bold text-white font-mono mt-0.5">
|
| 961 |
{camp.sent_count || 0}
|
| 962 |
</div>
|
| 963 |
</div>
|
| 964 |
|
| 965 |
+
<div className="bg-white/[0.03] rounded-lg px-2.5 py-1.5">
|
| 966 |
+
<div className="text-[9px] font-bold uppercase tracking-wider text-neutral-400 flex items-center justify-between">
|
| 967 |
+
<span>Delivery Rate</span>
|
| 968 |
{failedCount > 0 && (
|
| 969 |
+
<span className="text-[8px] font-bold text-rose-400 bg-rose-500/10 px-1 py-0.2 rounded">
|
| 970 |
{failedCount} err
|
| 971 |
</span>
|
| 972 |
)}
|
| 973 |
</div>
|
| 974 |
+
<div className={`text-sm font-bold font-mono mt-0.5 ${cardStyle.accentText}`}>
|
| 975 |
{progressPct}%
|
| 976 |
</div>
|
| 977 |
</div>
|
| 978 |
|
| 979 |
+
<div className="bg-white/[0.03] rounded-lg px-2.5 py-1.5">
|
| 980 |
+
<div className="text-[9px] font-bold uppercase tracking-wider text-neutral-400">
|
| 981 |
+
Cadence
|
| 982 |
</div>
|
| 983 |
+
<div className="text-sm font-bold text-sky-400 font-mono mt-0.5 truncate">
|
| 984 |
{camp.interval_hours > 0 || camp.interval_minutes > 0
|
| 985 |
+
? `${camp.interval_hours > 0 ? `${camp.interval_hours}h ` : ''}${camp.interval_minutes > 0 ? `${camp.interval_minutes}m` : ''}`.trim()
|
| 986 |
+
: 'Single Run'}
|
| 987 |
</div>
|
| 988 |
</div>
|
| 989 |
</div>
|
| 990 |
</div>
|
| 991 |
|
| 992 |
{/* Message Snippet */}
|
| 993 |
+
<div className="mt-2 px-2.5 py-1 rounded-lg bg-white/[0.02] text-[10px] text-neutral-400 font-mono truncate leading-normal">
|
| 994 |
"{camp.message_text || camp.message || '...'}"
|
| 995 |
</div>
|
| 996 |
</div>
|
| 997 |
|
| 998 |
{/* Footer: Target Entities */}
|
| 999 |
+
<div className="mt-2 pt-2 border-t border-white/[0.04] flex items-center justify-between text-[11px] text-neutral-400 font-medium">
|
| 1000 |
<div className="flex items-center gap-1.5">
|
| 1001 |
+
<Users size={11} className="text-neutral-500" />
|
| 1002 |
<span>{parsedGroups.length} Telegram {parsedGroups.length === 1 ? 'Target' : 'Targets'}</span>
|
| 1003 |
</div>
|
| 1004 |
{camp.batch_number && camp.batch_number > 1 && (
|
| 1005 |
+
<span className="text-[9px] font-mono text-neutral-500">Batch #{camp.batch_number}</span>
|
| 1006 |
)}
|
| 1007 |
</div>
|
| 1008 |
</div>
|
|
|
|
| 1011 |
</div>
|
| 1012 |
) : (
|
| 1013 |
/* List View Upgraded */
|
| 1014 |
+
<div className="space-y-2.5">
|
| 1015 |
{filteredCampaigns.map((camp) => {
|
| 1016 |
const progressPct = Math.min(100, Math.round(((camp.sent_count || 0) / Math.max(1, camp.total_targets || 1)) * 100));
|
| 1017 |
const cardStyle = getCampaignCardStyle(camp.status);
|
|
|
|
| 1023 |
return (
|
| 1024 |
<div
|
| 1025 |
key={camp.id}
|
| 1026 |
+
className="relative rounded-2xl bg-[#111513] border border-white/[0.05] p-3.5 sm:p-4 transition-all flex flex-col md:flex-row md:items-center justify-between gap-3.5 group/card overflow-hidden"
|
| 1027 |
style={{ backgroundImage: cardStyle.radialGlow !== 'none' ? cardStyle.radialGlow : undefined }}
|
| 1028 |
>
|
| 1029 |
{/* Angled Glowing Top Beam */}
|
| 1030 |
<div
|
| 1031 |
className={`absolute -top-px left-[20%] right-[20%] h-[2px] bg-gradient-to-r ${cardStyle.topBeamColor} pointer-events-none`}
|
| 1032 |
/>
|
| 1033 |
+
<div className="flex items-center gap-3 min-w-0">
|
| 1034 |
+
<div className={`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${cardStyle.iconBg}`}>
|
| 1035 |
+
<Zap size={16} className="fill-current" />
|
| 1036 |
</div>
|
| 1037 |
<div className="min-w-0">
|
| 1038 |
<div className="flex items-center gap-2">
|
| 1039 |
<h4 className="font-bold text-white text-sm tracking-tight truncate">{camp.name || "Broadcast Campaign"}</h4>
|
| 1040 |
+
<span className={`w-1.5 h-1.5 rounded-full ${cardStyle.dotColor}`} />
|
| 1041 |
<span className={`text-[9px] font-bold uppercase tracking-wider ${cardStyle.accentText}`}>{cardStyle.statusText}</span>
|
| 1042 |
</div>
|
| 1043 |
+
<div className="flex flex-wrap items-center gap-2 text-[11px] text-neutral-400 font-medium mt-1">
|
| 1044 |
+
<div className="flex items-center gap-1.5 font-semibold text-neutral-300">
|
| 1045 |
+
<TelegramAvatar
|
| 1046 |
+
photo={senderAccount?.profile_photo}
|
| 1047 |
+
name={senderAccount?.first_name || camp.phone_number}
|
| 1048 |
+
phone={camp.phone_number}
|
| 1049 |
+
size="w-4 h-4 text-[8px]"
|
| 1050 |
+
/>
|
| 1051 |
+
<span>{accountDisplayName}</span>
|
| 1052 |
+
</div>
|
| 1053 |
<span>•</span>
|
| 1054 |
<span className="font-mono text-neutral-500">{camp.phone_number}</span>
|
| 1055 |
<span>•</span>
|
| 1056 |
+
<span>{camp.sent_count || 0} / {camp.total_targets || 0} delivered ({progressPct}%)</span>
|
| 1057 |
{camp.media_url && (
|
| 1058 |
<>
|
| 1059 |
<span>•</span>
|
|
|
|
| 1066 |
</div>
|
| 1067 |
</div>
|
| 1068 |
|
| 1069 |
+
<div className="flex items-center gap-2 shrink-0 self-end md:self-auto">
|
| 1070 |
+
{camp.status === 'failed' || camp.status === 'error' ? (
|
| 1071 |
<button
|
| 1072 |
onClick={() => handleTogglePause(camp.id)}
|
| 1073 |
+
className="px-2.5 py-1 rounded-lg text-xs font-semibold transition-all flex items-center gap-1.5 cursor-pointer bg-rose-500/15 text-rose-300 hover:bg-rose-500/25 border border-rose-500/30"
|
| 1074 |
+
title="Retry"
|
| 1075 |
>
|
| 1076 |
+
<Play size={11} className="fill-current text-rose-400" />
|
| 1077 |
+
<span>RETRY</span>
|
| 1078 |
+
</button>
|
| 1079 |
+
) : camp.status === 'paused' ? (
|
| 1080 |
+
<button
|
| 1081 |
+
onClick={() => handleTogglePause(camp.id)}
|
| 1082 |
+
className="px-2.5 py-1 rounded-lg text-xs font-semibold transition-all flex items-center gap-1.5 cursor-pointer bg-amber-500/15 text-amber-300 hover:bg-amber-500/25 border border-amber-500/30"
|
| 1083 |
+
title="Resume"
|
| 1084 |
+
>
|
| 1085 |
+
<Play size={11} className="fill-current text-amber-400" />
|
| 1086 |
+
<span>RESUME</span>
|
| 1087 |
+
</button>
|
| 1088 |
+
) : camp.status === 'completed' ? (
|
| 1089 |
+
<div className="px-2.5 py-1 rounded-lg text-xs font-semibold text-teal-300 bg-teal-500/15 border border-teal-500/30">
|
| 1090 |
+
COMPLETED
|
| 1091 |
+
</div>
|
| 1092 |
+
) : (
|
| 1093 |
+
<button
|
| 1094 |
+
onClick={() => handleTogglePause(camp.id)}
|
| 1095 |
+
className="px-2.5 py-1 rounded-lg text-xs font-semibold transition-all flex items-center gap-1.5 cursor-pointer bg-white/[0.04] text-neutral-300 hover:bg-white/[0.08] border border-white/[0.08]"
|
| 1096 |
+
title="Pause"
|
| 1097 |
+
>
|
| 1098 |
+
<Pause size={11} />
|
| 1099 |
+
<span>PAUSE</span>
|
| 1100 |
</button>
|
| 1101 |
)}
|
| 1102 |
<button
|
| 1103 |
onClick={() => handleEdit(camp)}
|
| 1104 |
+
className="p-1 text-neutral-500 hover:text-white rounded-lg transition-colors cursor-pointer"
|
| 1105 |
title="Edit"
|
| 1106 |
>
|
| 1107 |
+
<Edit3 size={13} />
|
| 1108 |
</button>
|
| 1109 |
<button
|
| 1110 |
onClick={() => handleDelete(camp.id)}
|
| 1111 |
+
className="p-1 text-neutral-500 hover:text-rose-400 rounded-lg transition-colors cursor-pointer"
|
| 1112 |
title="Delete"
|
| 1113 |
>
|
| 1114 |
+
<Trash2 size={13} />
|
| 1115 |
</button>
|
| 1116 |
</div>
|
| 1117 |
</div>
|
|
|
|
| 1222 |
<div className="flex items-center gap-2.5 min-w-0">
|
| 1223 |
{selectedAcc ? (
|
| 1224 |
<>
|
| 1225 |
+
<TelegramAvatar
|
| 1226 |
+
photo={selectedAcc.profile_photo}
|
| 1227 |
+
name={selectedAcc.first_name}
|
| 1228 |
+
phone={selectedAcc.phone_number}
|
| 1229 |
+
size="w-6 h-6 text-[10px]"
|
| 1230 |
+
/>
|
|
|
|
|
|
|
| 1231 |
<div className="text-left truncate">
|
| 1232 |
<span className="font-bold text-foreground block truncate leading-tight">
|
| 1233 |
{selectedAcc.first_name ? `${selectedAcc.first_name} ${selectedAcc.last_name || ''}` : selectedAcc.phone_number}
|
|
|
|
| 1265 |
}`}
|
| 1266 |
>
|
| 1267 |
<div className="flex items-center gap-2.5 min-w-0">
|
| 1268 |
+
<TelegramAvatar
|
| 1269 |
+
photo={acc.profile_photo}
|
| 1270 |
+
name={acc.first_name}
|
| 1271 |
+
phone={acc.phone_number}
|
| 1272 |
+
size="w-7 h-7 text-xs"
|
| 1273 |
+
/>
|
|
|
|
|
|
|
| 1274 |
<div className="text-left min-w-0">
|
| 1275 |
<div className="font-bold text-xs truncate text-foreground flex items-center gap-1.5">
|
| 1276 |
<span>{acc.first_name ? `${acc.first_name} ${acc.last_name || ''}` : acc.phone_number}</span>
|