Spaces:
Running
Running
axeronis commited on
Commit ·
a7e3546
1
Parent(s): f1c284f
refactor: Update all admin panel components to aurora dark theme
Browse files- frontend/components/admin/AnalyticsTab.tsx +42 -24
- frontend/components/admin/AnnouncementsTab.tsx +94 -24
- frontend/components/admin/LandingTab.tsx +41 -20
- frontend/components/admin/PartnersTab.tsx +85 -77
- frontend/components/admin/TenantsTab.tsx +124 -53
- frontend/components/admin/UserDetailsModal.tsx +61 -61
frontend/components/admin/AnalyticsTab.tsx
CHANGED
|
@@ -32,29 +32,33 @@ export default function AnalyticsTab() {
|
|
| 32 |
}
|
| 33 |
}
|
| 34 |
|
| 35 |
-
if (loading) return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
return (
|
| 38 |
<div className="space-y-6">
|
| 39 |
-
{/* Info Card */}
|
| 40 |
-
<div className="bg-gradient-to-r from-
|
| 41 |
-
<div className="p-2 bg-
|
| 42 |
<TrendingUp className="w-5 h-5" />
|
| 43 |
</div>
|
| 44 |
<div>
|
| 45 |
-
<h3 className="font-bold text-
|
| 46 |
-
<p className="text-xs text-
|
| 47 |
Обзор ключевых метрик платформы: рост пользователей и финансовые показатели (MRR).
|
| 48 |
Данные обновляются в реальном времени на основе активных подписок.
|
| 49 |
</p>
|
| 50 |
</div>
|
| 51 |
</div>
|
| 52 |
|
| 53 |
-
<div className="grid grid-cols-1 md:grid-cols-
|
| 54 |
{/* Growth Chart */}
|
| 55 |
-
<div className="bg-
|
| 56 |
-
<h3 className="text-lg font-bold mb-4 flex items-center gap-2">
|
| 57 |
-
<Users className="w-5 h-5 text-indigo-
|
| 58 |
Рост пользователей
|
| 59 |
</h3>
|
| 60 |
<div className="h-64">
|
|
@@ -66,10 +70,17 @@ export default function AnalyticsTab() {
|
|
| 66 |
<stop offset="95%" stopColor="#6366f1" stopOpacity={0} />
|
| 67 |
</linearGradient>
|
| 68 |
</defs>
|
| 69 |
-
<CartesianGrid strokeDasharray="3 3" vertical={false} />
|
| 70 |
-
<XAxis dataKey="date" tickFormatter={(str) => str.slice(5)} />
|
| 71 |
-
<YAxis />
|
| 72 |
-
<Tooltip
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
<Area type="monotone" dataKey="count" stroke="#6366f1" fillOpacity={1} fill="url(#colorCount)" />
|
| 74 |
</AreaChart>
|
| 75 |
</ResponsiveContainer>
|
|
@@ -77,22 +88,29 @@ export default function AnalyticsTab() {
|
|
| 77 |
</div>
|
| 78 |
|
| 79 |
{/* Revenue Chart */}
|
| 80 |
-
<div className="bg-
|
| 81 |
-
<h3 className="text-lg font-bold mb-4 flex items-center gap-2">
|
| 82 |
-
<DollarSign className="w-5 h-5 text-emerald-
|
| 83 |
Выручка (MRR)
|
| 84 |
</h3>
|
| 85 |
<div className="mb-4">
|
| 86 |
-
<span className="text-3xl font-bold text-
|
| 87 |
-
<span className="text-sm text-slate-
|
| 88 |
</div>
|
| 89 |
-
<div className="h-
|
| 90 |
<ResponsiveContainer width="100%" height="100%">
|
| 91 |
<LineChart data={revenueData?.history || []}>
|
| 92 |
-
<CartesianGrid strokeDasharray="3 3" vertical={false} />
|
| 93 |
-
<XAxis dataKey="date" tickFormatter={(str) => str.slice(5)} />
|
| 94 |
-
<YAxis />
|
| 95 |
-
<Tooltip
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
<Line type="monotone" dataKey="amount" stroke="#10b981" strokeWidth={3} dot={false} />
|
| 97 |
</LineChart>
|
| 98 |
</ResponsiveContainer>
|
|
|
|
| 32 |
}
|
| 33 |
}
|
| 34 |
|
| 35 |
+
if (loading) return (
|
| 36 |
+
<div className="p-8 text-center text-slate-400">
|
| 37 |
+
<div className="animate-pulse">Загрузка аналитики...</div>
|
| 38 |
+
</div>
|
| 39 |
+
)
|
| 40 |
|
| 41 |
return (
|
| 42 |
<div className="space-y-6">
|
| 43 |
+
{/* Info Card - Aurora Style */}
|
| 44 |
+
<div className="bg-gradient-to-r from-indigo-500/10 to-purple-500/10 border border-indigo-500/20 p-4 rounded-xl flex items-start gap-3">
|
| 45 |
+
<div className="p-2 bg-indigo-500/20 rounded-lg text-indigo-400">
|
| 46 |
<TrendingUp className="w-5 h-5" />
|
| 47 |
</div>
|
| 48 |
<div>
|
| 49 |
+
<h3 className="font-bold text-white text-sm">Аналитика и Доходы</h3>
|
| 50 |
+
<p className="text-xs text-slate-400 mt-1 leading-relaxed">
|
| 51 |
Обзор ключевых метрик платформы: рост пользователей и финансовые показатели (MRR).
|
| 52 |
Данные обновляются в реальном времени на основе активных подписок.
|
| 53 |
</p>
|
| 54 |
</div>
|
| 55 |
</div>
|
| 56 |
|
| 57 |
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 58 |
{/* Growth Chart */}
|
| 59 |
+
<div className="bg-slate-900/50 backdrop-blur-sm p-6 rounded-2xl border border-white/10">
|
| 60 |
+
<h3 className="text-lg font-bold text-white mb-4 flex items-center gap-2">
|
| 61 |
+
<Users className="w-5 h-5 text-indigo-400" />
|
| 62 |
Рост пользователей
|
| 63 |
</h3>
|
| 64 |
<div className="h-64">
|
|
|
|
| 70 |
<stop offset="95%" stopColor="#6366f1" stopOpacity={0} />
|
| 71 |
</linearGradient>
|
| 72 |
</defs>
|
| 73 |
+
<CartesianGrid strokeDasharray="3 3" vertical={false} stroke="#334155" />
|
| 74 |
+
<XAxis dataKey="date" tickFormatter={(str) => str.slice(5)} stroke="#64748b" />
|
| 75 |
+
<YAxis stroke="#64748b" />
|
| 76 |
+
<Tooltip
|
| 77 |
+
contentStyle={{
|
| 78 |
+
backgroundColor: '#1e293b',
|
| 79 |
+
border: '1px solid #334155',
|
| 80 |
+
borderRadius: '8px',
|
| 81 |
+
color: '#fff'
|
| 82 |
+
}}
|
| 83 |
+
/>
|
| 84 |
<Area type="monotone" dataKey="count" stroke="#6366f1" fillOpacity={1} fill="url(#colorCount)" />
|
| 85 |
</AreaChart>
|
| 86 |
</ResponsiveContainer>
|
|
|
|
| 88 |
</div>
|
| 89 |
|
| 90 |
{/* Revenue Chart */}
|
| 91 |
+
<div className="bg-slate-900/50 backdrop-blur-sm p-6 rounded-2xl border border-white/10">
|
| 92 |
+
<h3 className="text-lg font-bold text-white mb-4 flex items-center gap-2">
|
| 93 |
+
<DollarSign className="w-5 h-5 text-emerald-400" />
|
| 94 |
Выручка (MRR)
|
| 95 |
</h3>
|
| 96 |
<div className="mb-4">
|
| 97 |
+
<span className="text-3xl font-bold text-white">${revenueData?.current_mrr || 0}</span>
|
| 98 |
+
<span className="text-sm text-slate-400 ml-2">текущий MRR</span>
|
| 99 |
</div>
|
| 100 |
+
<div className="h-52">
|
| 101 |
<ResponsiveContainer width="100%" height="100%">
|
| 102 |
<LineChart data={revenueData?.history || []}>
|
| 103 |
+
<CartesianGrid strokeDasharray="3 3" vertical={false} stroke="#334155" />
|
| 104 |
+
<XAxis dataKey="date" tickFormatter={(str) => str.slice(5)} stroke="#64748b" />
|
| 105 |
+
<YAxis stroke="#64748b" />
|
| 106 |
+
<Tooltip
|
| 107 |
+
contentStyle={{
|
| 108 |
+
backgroundColor: '#1e293b',
|
| 109 |
+
border: '1px solid #334155',
|
| 110 |
+
borderRadius: '8px',
|
| 111 |
+
color: '#fff'
|
| 112 |
+
}}
|
| 113 |
+
/>
|
| 114 |
<Line type="monotone" dataKey="amount" stroke="#10b981" strokeWidth={3} dot={false} />
|
| 115 |
</LineChart>
|
| 116 |
</ResponsiveContainer>
|
frontend/components/admin/AnnouncementsTab.tsx
CHANGED
|
@@ -70,70 +70,140 @@ export default function AnnouncementsTab() {
|
|
| 70 |
} catch (e) { toast.error('Error', 'Network error') }
|
| 71 |
}
|
| 72 |
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
return (
|
| 76 |
<div className="space-y-6">
|
|
|
|
| 77 |
<div className="flex justify-between items-center">
|
| 78 |
-
<
|
|
|
|
|
|
|
|
|
|
| 79 |
<button
|
| 80 |
onClick={() => setShowModal(true)}
|
| 81 |
-
className="flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-lg
|
| 82 |
>
|
| 83 |
<Plus className="w-4 h-4" />
|
| 84 |
Новое объявление
|
| 85 |
</button>
|
| 86 |
</div>
|
| 87 |
|
|
|
|
| 88 |
<div className="grid gap-4">
|
| 89 |
{announcements.map(item => (
|
| 90 |
-
<div
|
| 91 |
-
}
|
|
|
|
|
|
|
|
|
|
| 92 |
<div className="flex justify-between items-start">
|
| 93 |
-
<div>
|
| 94 |
-
<h4 className="font-bold flex items-center gap-2">
|
| 95 |
{item.title}
|
| 96 |
-
{item.is_active &&
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
</h4>
|
| 98 |
-
<p className="text-slate-
|
| 99 |
-
<p className="text-xs text-slate-
|
|
|
|
|
|
|
| 100 |
</div>
|
| 101 |
{item.is_active && (
|
| 102 |
-
<button
|
|
|
|
|
|
|
|
|
|
| 103 |
<X className="w-5 h-5" />
|
| 104 |
</button>
|
| 105 |
)}
|
| 106 |
</div>
|
| 107 |
</div>
|
| 108 |
))}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
</div>
|
| 110 |
|
| 111 |
-
{/* Create Modal */}
|
| 112 |
{showModal && (
|
| 113 |
-
<div className="fixed inset-0 bg-black/
|
| 114 |
-
<div className="bg-white rounded-
|
| 115 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
<div className="space-y-4">
|
| 117 |
<div>
|
| 118 |
-
<label className="block text-sm font-
|
| 119 |
-
<input
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
</div>
|
| 121 |
<div>
|
| 122 |
-
<label className="block text-sm font-
|
| 123 |
-
<textarea
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
</div>
|
| 125 |
<div>
|
| 126 |
-
<label className="block text-sm font-
|
| 127 |
-
<select
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
<option value="info">Информация (Синий)</option>
|
| 129 |
<option value="success">Успех (Зеленый)</option>
|
| 130 |
<option value="warning">Внимание (Желтый)</option>
|
| 131 |
<option value="error">Важно (Красный)</option>
|
| 132 |
</select>
|
| 133 |
</div>
|
| 134 |
-
<div className="flex justify-end gap-
|
| 135 |
-
<button
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
</div>
|
| 138 |
</div>
|
| 139 |
</div>
|
|
|
|
| 70 |
} catch (e) { toast.error('Error', 'Network error') }
|
| 71 |
}
|
| 72 |
|
| 73 |
+
const getTypeColor = (type: string) => {
|
| 74 |
+
switch (type) {
|
| 75 |
+
case 'success': return 'border-emerald-500/50 bg-emerald-500/10'
|
| 76 |
+
case 'warning': return 'border-amber-500/50 bg-amber-500/10'
|
| 77 |
+
case 'error': return 'border-red-500/50 bg-red-500/10'
|
| 78 |
+
default: return 'border-indigo-500/50 bg-indigo-500/10'
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
if (loading) return (
|
| 83 |
+
<div className="flex items-center justify-center p-12">
|
| 84 |
+
<div className="w-8 h-8 rounded-full border-2 border-indigo-500 border-t-transparent animate-spin"></div>
|
| 85 |
+
</div>
|
| 86 |
+
)
|
| 87 |
|
| 88 |
return (
|
| 89 |
<div className="space-y-6">
|
| 90 |
+
{/* Header */}
|
| 91 |
<div className="flex justify-between items-center">
|
| 92 |
+
<div>
|
| 93 |
+
<h3 className="text-lg font-bold text-white">Системные объявления</h3>
|
| 94 |
+
<p className="text-sm text-slate-400">Управление объявлениями для всех пользователей</p>
|
| 95 |
+
</div>
|
| 96 |
<button
|
| 97 |
onClick={() => setShowModal(true)}
|
| 98 |
+
className="flex items-center gap-2 px-4 py-2.5 bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg font-medium transition-colors"
|
| 99 |
>
|
| 100 |
<Plus className="w-4 h-4" />
|
| 101 |
Новое объявление
|
| 102 |
</button>
|
| 103 |
</div>
|
| 104 |
|
| 105 |
+
{/* Announcements Grid */}
|
| 106 |
<div className="grid gap-4">
|
| 107 |
{announcements.map(item => (
|
| 108 |
+
<div
|
| 109 |
+
key={item.id}
|
| 110 |
+
className={`p-5 rounded-xl border-l-4 ${getTypeColor(item.type)} ${item.is_active ? '' : 'opacity-50'
|
| 111 |
+
} bg-slate-900/50 backdrop-blur-sm border border-white/10`}
|
| 112 |
+
>
|
| 113 |
<div className="flex justify-between items-start">
|
| 114 |
+
<div className="flex-1">
|
| 115 |
+
<h4 className="font-bold text-white flex items-center gap-2">
|
| 116 |
{item.title}
|
| 117 |
+
{item.is_active && (
|
| 118 |
+
<span className="text-xs bg-emerald-500/20 text-emerald-400 px-2 py-0.5 rounded-full">
|
| 119 |
+
Активно
|
| 120 |
+
</span>
|
| 121 |
+
)}
|
| 122 |
</h4>
|
| 123 |
+
<p className="text-slate-400 mt-2">{item.message}</p>
|
| 124 |
+
<p className="text-xs text-slate-500 mt-3">
|
| 125 |
+
{new Date(item.created_at).toLocaleString('ru-RU')}
|
| 126 |
+
</p>
|
| 127 |
</div>
|
| 128 |
{item.is_active && (
|
| 129 |
+
<button
|
| 130 |
+
onClick={() => handleDeactivate(item.id)}
|
| 131 |
+
className="text-red-400 hover:bg-red-500/20 p-2 rounded-lg transition-colors"
|
| 132 |
+
>
|
| 133 |
<X className="w-5 h-5" />
|
| 134 |
</button>
|
| 135 |
)}
|
| 136 |
</div>
|
| 137 |
</div>
|
| 138 |
))}
|
| 139 |
+
|
| 140 |
+
{announcements.length === 0 && (
|
| 141 |
+
<div className="p-8 text-center text-slate-500 bg-slate-900/50 rounded-xl border border-white/10">
|
| 142 |
+
<Megaphone className="w-12 h-12 mx-auto mb-3 text-slate-600" />
|
| 143 |
+
<p>Нет объявлений</p>
|
| 144 |
+
</div>
|
| 145 |
+
)}
|
| 146 |
</div>
|
| 147 |
|
| 148 |
+
{/* Create Modal - Aurora Dark Style */}
|
| 149 |
{showModal && (
|
| 150 |
+
<div className="fixed inset-0 bg-black/70 backdrop-blur-sm flex items-center justify-center z-50 p-4">
|
| 151 |
+
<div className="bg-slate-900 border border-white/10 rounded-2xl max-w-md w-full p-6 shadow-2xl">
|
| 152 |
+
<div className="flex items-center justify-between mb-6">
|
| 153 |
+
<h3 className="text-lg font-bold text-white">Создать объявление</h3>
|
| 154 |
+
<button
|
| 155 |
+
onClick={() => setShowModal(false)}
|
| 156 |
+
className="p-1 text-slate-400 hover:text-white transition-colors"
|
| 157 |
+
>
|
| 158 |
+
<X className="w-5 h-5" />
|
| 159 |
+
</button>
|
| 160 |
+
</div>
|
| 161 |
+
|
| 162 |
<div className="space-y-4">
|
| 163 |
<div>
|
| 164 |
+
<label className="block text-sm font-medium text-slate-400 mb-2">Заголовок</label>
|
| 165 |
+
<input
|
| 166 |
+
value={title}
|
| 167 |
+
onChange={e => setTitle(e.target.value)}
|
| 168 |
+
className="w-full bg-slate-800 border border-white/10 rounded-lg p-3 text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50"
|
| 169 |
+
placeholder="Введите заголовок..."
|
| 170 |
+
/>
|
| 171 |
</div>
|
| 172 |
<div>
|
| 173 |
+
<label className="block text-sm font-medium text-slate-400 mb-2">Текст сообщения</label>
|
| 174 |
+
<textarea
|
| 175 |
+
value={message}
|
| 176 |
+
onChange={e => setMessage(e.target.value)}
|
| 177 |
+
className="w-full bg-slate-800 border border-white/10 rounded-lg p-3 text-white h-24 resize-none focus:outline-none focus:ring-2 focus:ring-indigo-500/50"
|
| 178 |
+
placeholder="Введите текст объявления..."
|
| 179 |
+
/>
|
| 180 |
</div>
|
| 181 |
<div>
|
| 182 |
+
<label className="block text-sm font-medium text-slate-400 mb-2">Тип</label>
|
| 183 |
+
<select
|
| 184 |
+
value={type}
|
| 185 |
+
onChange={e => setType(e.target.value)}
|
| 186 |
+
className="w-full bg-slate-800 border border-white/10 rounded-lg p-3 text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50"
|
| 187 |
+
>
|
| 188 |
<option value="info">Информация (Синий)</option>
|
| 189 |
<option value="success">Успех (Зеленый)</option>
|
| 190 |
<option value="warning">Внимание (Желтый)</option>
|
| 191 |
<option value="error">Важно (Красный)</option>
|
| 192 |
</select>
|
| 193 |
</div>
|
| 194 |
+
<div className="flex justify-end gap-3 pt-4">
|
| 195 |
+
<button
|
| 196 |
+
onClick={() => setShowModal(false)}
|
| 197 |
+
className="px-4 py-2.5 border border-white/10 text-slate-400 hover:text-white rounded-lg transition-colors"
|
| 198 |
+
>
|
| 199 |
+
Отмена
|
| 200 |
+
</button>
|
| 201 |
+
<button
|
| 202 |
+
onClick={handleCreate}
|
| 203 |
+
className="px-4 py-2.5 bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg font-medium transition-colors"
|
| 204 |
+
>
|
| 205 |
+
Создать
|
| 206 |
+
</button>
|
| 207 |
</div>
|
| 208 |
</div>
|
| 209 |
</div>
|
frontend/components/admin/LandingTab.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
|
| 2 |
import { useState, useEffect } from 'react'
|
| 3 |
-
import { X, Save } from 'lucide-react'
|
| 4 |
import { useToast } from '@/contexts/ToastContext'
|
| 5 |
|
| 6 |
export default function LandingTab() {
|
|
@@ -48,22 +48,39 @@ export default function LandingTab() {
|
|
| 48 |
}
|
| 49 |
}
|
| 50 |
|
| 51 |
-
if (!landingConfig) return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
return (
|
| 54 |
-
<div className="bg-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
<div className="space-y-8">
|
| 57 |
{/* Pricing Editor */}
|
| 58 |
<div>
|
| 59 |
-
<
|
|
|
|
|
|
|
|
|
|
| 60 |
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
| 61 |
{Object.entries(landingConfig.pricing || {}).map(([key, plan]: [string, any]) => (
|
| 62 |
-
<div key={key} className="p-
|
| 63 |
-
<h4 className="font-bold capitalize mb-
|
| 64 |
-
<div className="space-y-
|
| 65 |
<div>
|
| 66 |
-
<label className="text-xs text-slate-
|
| 67 |
<input
|
| 68 |
type="number"
|
| 69 |
value={plan.price}
|
|
@@ -72,11 +89,11 @@ export default function LandingTab() {
|
|
| 72 |
newConfig.pricing[key].price = parseInt(e.target.value)
|
| 73 |
setLandingConfig(newConfig)
|
| 74 |
}}
|
| 75 |
-
className="w-full px-
|
| 76 |
/>
|
| 77 |
</div>
|
| 78 |
<div>
|
| 79 |
-
<label className="text-xs text-slate-
|
| 80 |
<textarea
|
| 81 |
value={plan.features.join(', ')}
|
| 82 |
onChange={(e) => {
|
|
@@ -84,7 +101,7 @@ export default function LandingTab() {
|
|
| 84 |
newConfig.pricing[key].features = e.target.value.split(',').map((s: string) => s.trim())
|
| 85 |
setLandingConfig(newConfig)
|
| 86 |
}}
|
| 87 |
-
className="w-full px-
|
| 88 |
rows={3}
|
| 89 |
/>
|
| 90 |
</div>
|
|
@@ -96,10 +113,13 @@ export default function LandingTab() {
|
|
| 96 |
|
| 97 |
{/* Companies Editor */}
|
| 98 |
<div>
|
| 99 |
-
<
|
|
|
|
|
|
|
|
|
|
| 100 |
<div className="space-y-4">
|
| 101 |
{landingConfig.companies?.map((company: any, index: number) => (
|
| 102 |
-
<div key={index} className="flex gap-4 items-center p-4 border rounded-xl">
|
| 103 |
<input
|
| 104 |
type="text"
|
| 105 |
value={company.name}
|
|
@@ -109,7 +129,7 @@ export default function LandingTab() {
|
|
| 109 |
setLandingConfig(newConfig)
|
| 110 |
}}
|
| 111 |
placeholder="Название"
|
| 112 |
-
className="flex-1 px-3 py-2 border rounded"
|
| 113 |
/>
|
| 114 |
<input
|
| 115 |
type="text"
|
|
@@ -120,7 +140,7 @@ export default function LandingTab() {
|
|
| 120 |
setLandingConfig(newConfig)
|
| 121 |
}}
|
| 122 |
placeholder="URL Логотипа"
|
| 123 |
-
className="flex-1 px-3 py-2 border rounded"
|
| 124 |
/>
|
| 125 |
<button
|
| 126 |
onClick={() => {
|
|
@@ -128,7 +148,7 @@ export default function LandingTab() {
|
|
| 128 |
newConfig.companies.splice(index, 1)
|
| 129 |
setLandingConfig(newConfig)
|
| 130 |
}}
|
| 131 |
-
className="text-red-
|
| 132 |
>
|
| 133 |
<X className="w-5 h-5" />
|
| 134 |
</button>
|
|
@@ -141,18 +161,19 @@ export default function LandingTab() {
|
|
| 141 |
newConfig.companies.push({ name: '', logo: '' })
|
| 142 |
setLandingConfig(newConfig)
|
| 143 |
}}
|
| 144 |
-
className="px-4 py-
|
| 145 |
>
|
| 146 |
+ Добавить компанию
|
| 147 |
</button>
|
| 148 |
</div>
|
| 149 |
</div>
|
| 150 |
|
| 151 |
-
|
|
|
|
| 152 |
<button
|
| 153 |
onClick={saveConfig}
|
| 154 |
disabled={savingConfig}
|
| 155 |
-
className="flex items-center gap-2 px-8 py-3 bg-indigo-600 hover:bg-indigo-
|
| 156 |
>
|
| 157 |
<Save className="w-5 h-5" />
|
| 158 |
{savingConfig ? 'Сохранение...' : 'Сохранить изменения'}
|
|
|
|
| 1 |
|
| 2 |
import { useState, useEffect } from 'react'
|
| 3 |
+
import { X, Save, Settings, DollarSign, Building } from 'lucide-react'
|
| 4 |
import { useToast } from '@/contexts/ToastContext'
|
| 5 |
|
| 6 |
export default function LandingTab() {
|
|
|
|
| 48 |
}
|
| 49 |
}
|
| 50 |
|
| 51 |
+
if (!landingConfig) return (
|
| 52 |
+
<div className="flex items-center justify-center p-12">
|
| 53 |
+
<div className="w-8 h-8 rounded-full border-2 border-indigo-500 border-t-transparent animate-spin"></div>
|
| 54 |
+
</div>
|
| 55 |
+
)
|
| 56 |
|
| 57 |
return (
|
| 58 |
+
<div className="bg-slate-900/50 backdrop-blur-sm rounded-2xl border border-white/10 p-8">
|
| 59 |
+
{/* Header */}
|
| 60 |
+
<div className="flex items-center gap-3 mb-8">
|
| 61 |
+
<div className="p-2 bg-indigo-500/20 rounded-lg">
|
| 62 |
+
<Settings className="w-5 h-5 text-indigo-400" />
|
| 63 |
+
</div>
|
| 64 |
+
<div>
|
| 65 |
+
<h2 className="text-xl font-bold text-white">Настройки Лендинга</h2>
|
| 66 |
+
<p className="text-sm text-slate-400">Управление контентом главной страницы</p>
|
| 67 |
+
</div>
|
| 68 |
+
</div>
|
| 69 |
+
|
| 70 |
<div className="space-y-8">
|
| 71 |
{/* Pricing Editor */}
|
| 72 |
<div>
|
| 73 |
+
<div className="flex items-center gap-2 mb-4">
|
| 74 |
+
<DollarSign className="w-5 h-5 text-emerald-400" />
|
| 75 |
+
<h3 className="text-lg font-semibold text-white">Тарифы</h3>
|
| 76 |
+
</div>
|
| 77 |
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
| 78 |
{Object.entries(landingConfig.pricing || {}).map(([key, plan]: [string, any]) => (
|
| 79 |
+
<div key={key} className="p-5 border border-white/10 rounded-xl bg-slate-800/50">
|
| 80 |
+
<h4 className="font-bold capitalize mb-4 text-white">{key}</h4>
|
| 81 |
+
<div className="space-y-4">
|
| 82 |
<div>
|
| 83 |
+
<label className="text-xs text-slate-400 mb-1 block">Цена ($)</label>
|
| 84 |
<input
|
| 85 |
type="number"
|
| 86 |
value={plan.price}
|
|
|
|
| 89 |
newConfig.pricing[key].price = parseInt(e.target.value)
|
| 90 |
setLandingConfig(newConfig)
|
| 91 |
}}
|
| 92 |
+
className="w-full px-3 py-2 bg-slate-900 border border-white/10 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50"
|
| 93 |
/>
|
| 94 |
</div>
|
| 95 |
<div>
|
| 96 |
+
<label className="text-xs text-slate-400 mb-1 block">Фичи (через запятую)</label>
|
| 97 |
<textarea
|
| 98 |
value={plan.features.join(', ')}
|
| 99 |
onChange={(e) => {
|
|
|
|
| 101 |
newConfig.pricing[key].features = e.target.value.split(',').map((s: string) => s.trim())
|
| 102 |
setLandingConfig(newConfig)
|
| 103 |
}}
|
| 104 |
+
className="w-full px-3 py-2 bg-slate-900 border border-white/10 rounded-lg text-white text-sm resize-none focus:outline-none focus:ring-2 focus:ring-indigo-500/50"
|
| 105 |
rows={3}
|
| 106 |
/>
|
| 107 |
</div>
|
|
|
|
| 113 |
|
| 114 |
{/* Companies Editor */}
|
| 115 |
<div>
|
| 116 |
+
<div className="flex items-center gap-2 mb-4">
|
| 117 |
+
<Building className="w-5 h-5 text-blue-400" />
|
| 118 |
+
<h3 className="text-lg font-semibold text-white">Компании (Trusted By)</h3>
|
| 119 |
+
</div>
|
| 120 |
<div className="space-y-4">
|
| 121 |
{landingConfig.companies?.map((company: any, index: number) => (
|
| 122 |
+
<div key={index} className="flex gap-4 items-center p-4 border border-white/10 rounded-xl bg-slate-800/50">
|
| 123 |
<input
|
| 124 |
type="text"
|
| 125 |
value={company.name}
|
|
|
|
| 129 |
setLandingConfig(newConfig)
|
| 130 |
}}
|
| 131 |
placeholder="Название"
|
| 132 |
+
className="flex-1 px-3 py-2 bg-slate-900 border border-white/10 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50"
|
| 133 |
/>
|
| 134 |
<input
|
| 135 |
type="text"
|
|
|
|
| 140 |
setLandingConfig(newConfig)
|
| 141 |
}}
|
| 142 |
placeholder="URL Логотипа"
|
| 143 |
+
className="flex-1 px-3 py-2 bg-slate-900 border border-white/10 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50"
|
| 144 |
/>
|
| 145 |
<button
|
| 146 |
onClick={() => {
|
|
|
|
| 148 |
newConfig.companies.splice(index, 1)
|
| 149 |
setLandingConfig(newConfig)
|
| 150 |
}}
|
| 151 |
+
className="text-red-400 hover:bg-red-500/20 p-2 rounded-lg transition-colors"
|
| 152 |
>
|
| 153 |
<X className="w-5 h-5" />
|
| 154 |
</button>
|
|
|
|
| 161 |
newConfig.companies.push({ name: '', logo: '' })
|
| 162 |
setLandingConfig(newConfig)
|
| 163 |
}}
|
| 164 |
+
className="px-4 py-3 border-2 border-dashed border-white/20 rounded-xl text-slate-400 hover:border-indigo-500/50 hover:text-indigo-400 transition-colors w-full"
|
| 165 |
>
|
| 166 |
+ Добавить компанию
|
| 167 |
</button>
|
| 168 |
</div>
|
| 169 |
</div>
|
| 170 |
|
| 171 |
+
{/* Save Button */}
|
| 172 |
+
<div className="pt-6 border-t border-white/10 flex justify-end">
|
| 173 |
<button
|
| 174 |
onClick={saveConfig}
|
| 175 |
disabled={savingConfig}
|
| 176 |
+
className="flex items-center gap-2 px-8 py-3 bg-indigo-600 hover:bg-indigo-500 text-white font-bold rounded-xl transition-colors disabled:opacity-50"
|
| 177 |
>
|
| 178 |
<Save className="w-5 h-5" />
|
| 179 |
{savingConfig ? 'Сохранение...' : 'Сохранить изменения'}
|
frontend/components/admin/PartnersTab.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
|
| 2 |
import { useState, useEffect } from 'react'
|
| 3 |
-
import { Search, Briefcase, CheckCircle, ShieldOff, DollarSign, Edit, Users, ChevronDown, ChevronRight, Ban } from 'lucide-react'
|
| 4 |
import { useToast } from '@/contexts/ToastContext'
|
| 5 |
|
| 6 |
interface Partner {
|
|
@@ -100,108 +100,116 @@ export default function PartnersTab() {
|
|
| 100 |
|
| 101 |
const getStatusBadge = (status: string) => {
|
| 102 |
switch (status) {
|
| 103 |
-
case 'ACTIVE': return <span className="bg-emerald-
|
| 104 |
-
case 'PENDING': return <span className="bg-amber-
|
| 105 |
-
case 'BANNED': return <span className="bg-red-
|
| 106 |
-
default: return <span className="bg-slate-
|
| 107 |
}
|
| 108 |
}
|
| 109 |
|
| 110 |
-
if (loading) return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
return (
|
| 113 |
<div className="space-y-6">
|
| 114 |
-
{/* Info Card */}
|
| 115 |
-
<div className="bg-gradient-to-r from-amber-
|
| 116 |
-
<div className="p-2 bg-amber-
|
| 117 |
<DollarSign className="w-5 h-5" />
|
| 118 |
</div>
|
| 119 |
<div>
|
| 120 |
-
<h3 className="font-bold text-
|
| 121 |
-
<p className="text-xs text-
|
| 122 |
Здесь управляются партнеры, которые приводят клиентов. Партнеры получают комиссию с оплат приведенных ими клиентов.
|
| 123 |
-
Вы можете активировать новых партнеров, менять их ставку комиссии или блокировать за нарушения.
|
| 124 |
</p>
|
| 125 |
</div>
|
| 126 |
</div>
|
| 127 |
|
| 128 |
{/* Search */}
|
| 129 |
-
<div className="bg-
|
| 130 |
<div className="relative">
|
| 131 |
-
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-slate-
|
| 132 |
<input
|
| 133 |
type="text"
|
| 134 |
value={searchQuery}
|
| 135 |
onChange={(e) => setSearchQuery(e.target.value)}
|
| 136 |
placeholder="Поиск партнеров (компания, email)..."
|
| 137 |
-
className="w-full pl-10 pr-4 py-2 border rounded-lg focus:ring-2 focus:ring-indigo-500
|
| 138 |
/>
|
| 139 |
</div>
|
| 140 |
</div>
|
| 141 |
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
</tr>
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
</div>
|
| 163 |
-
</td>
|
| 164 |
-
<td className="px-6 py-4">
|
| 165 |
-
{getStatusBadge(partner.status)}
|
| 166 |
-
</td>
|
| 167 |
-
<td className="px-6 py-4">
|
| 168 |
-
<div className="flex items-center gap-1">
|
| 169 |
-
<Users className="w-4 h-4 text-slate-400" />
|
| 170 |
-
<span className="font-bold">{partner.tenants_count}</span>
|
| 171 |
-
</div>
|
| 172 |
-
</td>
|
| 173 |
-
<td className="px-6 py-4">
|
| 174 |
-
<div className="space-y-1">
|
| 175 |
-
<div className="text-sm font-semibold text-emerald-600">${partner.balance_usd.toFixed(2)}</div>
|
| 176 |
-
<div className="text-xs text-slate-400">Всего: ${partner.total_earned.toFixed(2)}</div>
|
| 177 |
-
</div>
|
| 178 |
-
</td>
|
| 179 |
-
<td className="px-6 py-4">
|
| 180 |
-
<div className="flex items-center gap-2">
|
| 181 |
-
{partner.status === 'PENDING' && (
|
| 182 |
-
<button
|
| 183 |
-
onClick={() => handleActivate(partner.id)}
|
| 184 |
-
className="px-3 py-1 bg-emerald-600 text-white rounded-lg text-xs font-bold hover:bg-emerald-700"
|
| 185 |
-
>
|
| 186 |
-
Активировать
|
| 187 |
-
</button>
|
| 188 |
-
)}
|
| 189 |
-
{partner.status === 'ACTIVE' && (
|
| 190 |
-
<button
|
| 191 |
-
onClick={() => handleBan(partner.id)}
|
| 192 |
-
className="p-2 text-red-500 hover:bg-red-50 rounded-lg"
|
| 193 |
-
title="Заблокировать"
|
| 194 |
-
>
|
| 195 |
-
<Ban className="w-4 h-4" />
|
| 196 |
-
</button>
|
| 197 |
-
)}
|
| 198 |
-
</div>
|
| 199 |
-
</td>
|
| 200 |
-
</tr>
|
| 201 |
-
))}
|
| 202 |
-
</tbody>
|
| 203 |
-
</table>
|
| 204 |
-
</div>
|
| 205 |
</div>
|
| 206 |
</div>
|
| 207 |
)
|
|
|
|
| 1 |
|
| 2 |
import { useState, useEffect } from 'react'
|
| 3 |
+
import { Search, Briefcase, CheckCircle, ShieldOff, DollarSign, Edit, Users, ChevronDown, ChevronRight, Ban, X } from 'lucide-react'
|
| 4 |
import { useToast } from '@/contexts/ToastContext'
|
| 5 |
|
| 6 |
interface Partner {
|
|
|
|
| 100 |
|
| 101 |
const getStatusBadge = (status: string) => {
|
| 102 |
switch (status) {
|
| 103 |
+
case 'ACTIVE': return <span className="bg-emerald-500/20 text-emerald-400 px-2.5 py-1 rounded-lg text-xs font-bold">АКТИВЕН</span>
|
| 104 |
+
case 'PENDING': return <span className="bg-amber-500/20 text-amber-400 px-2.5 py-1 rounded-lg text-xs font-bold">ОЖИДАЕТ</span>
|
| 105 |
+
case 'BANNED': return <span className="bg-red-500/20 text-red-400 px-2.5 py-1 rounded-lg text-xs font-bold">БАН</span>
|
| 106 |
+
default: return <span className="bg-slate-700/50 text-slate-400 px-2.5 py-1 rounded-lg text-xs font-bold">{status}</span>
|
| 107 |
}
|
| 108 |
}
|
| 109 |
|
| 110 |
+
if (loading) return (
|
| 111 |
+
<div className="flex items-center justify-center p-12">
|
| 112 |
+
<div className="w-8 h-8 rounded-full border-2 border-indigo-500 border-t-transparent animate-spin"></div>
|
| 113 |
+
</div>
|
| 114 |
+
)
|
| 115 |
|
| 116 |
return (
|
| 117 |
<div className="space-y-6">
|
| 118 |
+
{/* Info Card - Aurora Style */}
|
| 119 |
+
<div className="bg-gradient-to-r from-amber-500/10 to-orange-500/10 border border-amber-500/20 p-4 rounded-xl flex items-start gap-3">
|
| 120 |
+
<div className="p-2 bg-amber-500/20 rounded-lg text-amber-400">
|
| 121 |
<DollarSign className="w-5 h-5" />
|
| 122 |
</div>
|
| 123 |
<div>
|
| 124 |
+
<h3 className="font-bold text-white text-sm">Партнерская Программа</h3>
|
| 125 |
+
<p className="text-xs text-slate-400 mt-1 leading-relaxed">
|
| 126 |
Здесь управляются партнеры, которые приводят клиентов. Партнеры получают комиссию с оплат приведенных ими клиентов.
|
|
|
|
| 127 |
</p>
|
| 128 |
</div>
|
| 129 |
</div>
|
| 130 |
|
| 131 |
{/* Search */}
|
| 132 |
+
<div className="bg-slate-900/50 backdrop-blur-sm rounded-2xl border border-white/10 p-4">
|
| 133 |
<div className="relative">
|
| 134 |
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-slate-500 w-5 h-5" />
|
| 135 |
<input
|
| 136 |
type="text"
|
| 137 |
value={searchQuery}
|
| 138 |
onChange={(e) => setSearchQuery(e.target.value)}
|
| 139 |
placeholder="Поиск партнеров (компания, email)..."
|
| 140 |
+
className="w-full pl-10 pr-4 py-2.5 bg-slate-800/50 border border-white/10 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50"
|
| 141 |
/>
|
| 142 |
</div>
|
| 143 |
</div>
|
| 144 |
|
| 145 |
+
{/* Table */}
|
| 146 |
+
<div className="bg-slate-900/50 backdrop-blur-sm rounded-2xl border border-white/10 overflow-hidden">
|
| 147 |
+
<table className="w-full">
|
| 148 |
+
<thead className="border-b border-white/10">
|
| 149 |
+
<tr>
|
| 150 |
+
<th className="px-6 py-4 text-left text-xs font-bold text-slate-400 uppercase tracking-wider">Партнер</th>
|
| 151 |
+
<th className="px-6 py-4 text-left text-xs font-bold text-slate-400 uppercase tracking-wider">Статус</th>
|
| 152 |
+
<th className="px-6 py-4 text-left text-xs font-bold text-slate-400 uppercase tracking-wider">Рефералы</th>
|
| 153 |
+
<th className="px-6 py-4 text-left text-xs font-bold text-slate-400 uppercase tracking-wider">Баланс / Заработано</th>
|
| 154 |
+
<th className="px-6 py-4 text-left text-xs font-bold text-slate-400 uppercase tracking-wider">Действия</th>
|
| 155 |
+
</tr>
|
| 156 |
+
</thead>
|
| 157 |
+
<tbody className="divide-y divide-white/5">
|
| 158 |
+
{filteredPartners.map((partner) => (
|
| 159 |
+
<tr key={partner.id} className="hover:bg-white/5 transition-colors">
|
| 160 |
+
<td className="px-6 py-4">
|
| 161 |
+
<div>
|
| 162 |
+
<p className="font-bold text-white">{partner.company_name}</p>
|
| 163 |
+
<p className="text-xs text-slate-500">{partner.contact_email}</p>
|
| 164 |
+
<p className="text-xs text-indigo-400 font-mono mt-1">Ref: {partner.referral_code}</p>
|
| 165 |
+
</div>
|
| 166 |
+
</td>
|
| 167 |
+
<td className="px-6 py-4">
|
| 168 |
+
{getStatusBadge(partner.status)}
|
| 169 |
+
</td>
|
| 170 |
+
<td className="px-6 py-4">
|
| 171 |
+
<div className="flex items-center gap-1.5">
|
| 172 |
+
<Users className="w-4 h-4 text-slate-500" />
|
| 173 |
+
<span className="font-bold text-white">{partner.tenants_count}</span>
|
| 174 |
+
</div>
|
| 175 |
+
</td>
|
| 176 |
+
<td className="px-6 py-4">
|
| 177 |
+
<div className="space-y-1">
|
| 178 |
+
<div className="text-sm font-semibold text-emerald-400">${partner.balance_usd.toFixed(2)}</div>
|
| 179 |
+
<div className="text-xs text-slate-500">Всего: ${partner.total_earned.toFixed(2)}</div>
|
| 180 |
+
</div>
|
| 181 |
+
</td>
|
| 182 |
+
<td className="px-6 py-4">
|
| 183 |
+
<div className="flex items-center gap-2">
|
| 184 |
+
{partner.status === 'PENDING' && (
|
| 185 |
+
<button
|
| 186 |
+
onClick={() => handleActivate(partner.id)}
|
| 187 |
+
className="px-3 py-1.5 bg-emerald-600 hover:bg-emerald-500 text-white rounded-lg text-xs font-bold transition-colors"
|
| 188 |
+
>
|
| 189 |
+
Активировать
|
| 190 |
+
</button>
|
| 191 |
+
)}
|
| 192 |
+
{partner.status === 'ACTIVE' && (
|
| 193 |
+
<button
|
| 194 |
+
onClick={() => handleBan(partner.id)}
|
| 195 |
+
className="p-2 text-red-400 hover:bg-red-500/20 rounded-lg transition-colors"
|
| 196 |
+
title="Заблокировать"
|
| 197 |
+
>
|
| 198 |
+
<Ban className="w-4 h-4" />
|
| 199 |
+
</button>
|
| 200 |
+
)}
|
| 201 |
+
</div>
|
| 202 |
+
</td>
|
| 203 |
</tr>
|
| 204 |
+
))}
|
| 205 |
+
</tbody>
|
| 206 |
+
</table>
|
| 207 |
+
|
| 208 |
+
{filteredPartners.length === 0 && (
|
| 209 |
+
<div className="p-8 text-center text-slate-500">
|
| 210 |
+
Партнеры не найдены
|
| 211 |
+
</div>
|
| 212 |
+
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
</div>
|
| 214 |
</div>
|
| 215 |
)
|
frontend/components/admin/TenantsTab.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
import { useState, useEffect } from 'react'
|
| 3 |
import {
|
| 4 |
Users, Check, Zap, DollarSign, Search, Filter, Activity,
|
| 5 |
-
Rocket, TrendingUp, Crown, Edit, Ban, Play, Shield, Briefcase
|
| 6 |
} from 'lucide-react'
|
| 7 |
import { useToast } from '@/contexts/ToastContext'
|
| 8 |
|
|
@@ -94,8 +94,6 @@ export default function TenantsTab() {
|
|
| 94 |
|
| 95 |
const handleSuspend = async (tenantId: string) => {
|
| 96 |
if (!confirm("Приостановить доступ клиента?")) return
|
| 97 |
-
// Reuse existing logic or API
|
| 98 |
-
// Assuming API is same as page.tsx
|
| 99 |
try {
|
| 100 |
const res = await fetch(`/api/v1/admin/tenants/${tenantId}/suspend`, {
|
| 101 |
method: 'POST',
|
|
@@ -133,15 +131,15 @@ export default function TenantsTab() {
|
|
| 133 |
// --- Render Helpers ---
|
| 134 |
const getPlanBadge = (plan: string) => {
|
| 135 |
const badges: any = {
|
| 136 |
-
trial: { icon: Zap, color: 'bg-slate-
|
| 137 |
-
start: { icon: Rocket, color: 'bg-blue-
|
| 138 |
-
growth: { icon: TrendingUp, color: 'bg-indigo-
|
| 139 |
-
unlimited: { icon: Crown, color: 'bg-purple-
|
| 140 |
}
|
| 141 |
const badge = badges[plan] || badges.trial
|
| 142 |
const Icon = badge.icon
|
| 143 |
return (
|
| 144 |
-
<span className={`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold border
|
| 145 |
<Icon className="w-4 h-4" />
|
| 146 |
{badge.label}
|
| 147 |
</span>
|
|
@@ -151,95 +149,168 @@ export default function TenantsTab() {
|
|
| 151 |
const getStatusBadge = (status: string) => {
|
| 152 |
const safeStatus = (status || 'unknown').toLowerCase()
|
| 153 |
const colors: any = {
|
| 154 |
-
active: 'bg-emerald-
|
| 155 |
-
trial: 'bg-amber-
|
| 156 |
-
expired: 'bg-red-
|
| 157 |
-
suspended: 'bg-orange-
|
| 158 |
}
|
| 159 |
-
return <span className={`px-2 py-1 rounded-lg text-xs font-bold ${colors[safeStatus] || 'bg-slate-
|
| 160 |
}
|
| 161 |
|
| 162 |
return (
|
| 163 |
<div className="space-y-6">
|
| 164 |
-
{/* Info Card */}
|
| 165 |
-
<div className="bg-gradient-to-r from-emerald-
|
| 166 |
-
<div className="p-2 bg-emerald-
|
| 167 |
<Briefcase className="w-5 h-5" />
|
| 168 |
</div>
|
| 169 |
<div>
|
| 170 |
-
<h3 className="font-bold text-
|
| 171 |
-
<p className="text-xs text-
|
| 172 |
Здесь управляются подписки клиентов. Каждый Tenant — это отдельная компания или инстанс, в котором работают пользователи.
|
| 173 |
-
Вы можете менять тарифный план, продлевать подписку или блокировать доступ всему пространству.
|
| 174 |
</p>
|
| 175 |
</div>
|
| 176 |
</div>
|
| 177 |
|
| 178 |
{/* Filters */}
|
| 179 |
-
<div className="bg-
|
| 180 |
<div className="md:col-span-2">
|
| 181 |
<input
|
| 182 |
value={searchQuery}
|
| 183 |
onChange={e => setSearchQuery(e.target.value)}
|
| 184 |
-
className="w-full border rounded px-
|
| 185 |
-
placeholder="Поиск..."
|
| 186 |
/>
|
| 187 |
</div>
|
| 188 |
-
<button
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
</div>
|
| 190 |
|
| 191 |
{/* Table */}
|
| 192 |
-
<div className="bg-
|
| 193 |
<table className="w-full">
|
| 194 |
-
<thead className="
|
| 195 |
<tr>
|
| 196 |
-
<th className="px-6 py-
|
| 197 |
-
<th className="px-6 py-
|
| 198 |
-
<th className="px-6 py-
|
| 199 |
-
<th className="px-6 py-
|
| 200 |
</tr>
|
| 201 |
</thead>
|
| 202 |
-
<tbody>
|
| 203 |
{tenants.map(t => (
|
| 204 |
-
<tr key={t.id} className="hover:bg-
|
| 205 |
<td className="px-6 py-4">
|
| 206 |
-
<div className="font-bold">{t.business_name}</div>
|
| 207 |
<div className="text-xs text-slate-500">{t.email}</div>
|
| 208 |
</td>
|
| 209 |
<td className="px-6 py-4">{getPlanBadge(t.subscription_plan)}</td>
|
| 210 |
<td className="px-6 py-4">{getStatusBadge(t.subscription_status)}</td>
|
| 211 |
<td className="px-6 py-4 flex gap-2">
|
| 212 |
-
<button
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
{t.is_active ?
|
| 214 |
-
<button
|
| 215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
}
|
| 217 |
</td>
|
| 218 |
</tr>
|
| 219 |
))}
|
| 220 |
</tbody>
|
| 221 |
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
</div>
|
| 223 |
|
| 224 |
-
{/* Modal
|
| 225 |
{showEditModal && (
|
| 226 |
-
<div className="fixed inset-0 bg-black/
|
| 227 |
-
<div className="bg-white p-6 rounded-
|
| 228 |
-
<
|
| 229 |
-
|
| 230 |
-
<
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
</div>
|
| 244 |
</div>
|
| 245 |
</div>
|
|
|
|
| 2 |
import { useState, useEffect } from 'react'
|
| 3 |
import {
|
| 4 |
Users, Check, Zap, DollarSign, Search, Filter, Activity,
|
| 5 |
+
Rocket, TrendingUp, Crown, Edit, Ban, Play, Shield, Briefcase, X
|
| 6 |
} from 'lucide-react'
|
| 7 |
import { useToast } from '@/contexts/ToastContext'
|
| 8 |
|
|
|
|
| 94 |
|
| 95 |
const handleSuspend = async (tenantId: string) => {
|
| 96 |
if (!confirm("Приостановить доступ клиента?")) return
|
|
|
|
|
|
|
| 97 |
try {
|
| 98 |
const res = await fetch(`/api/v1/admin/tenants/${tenantId}/suspend`, {
|
| 99 |
method: 'POST',
|
|
|
|
| 131 |
// --- Render Helpers ---
|
| 132 |
const getPlanBadge = (plan: string) => {
|
| 133 |
const badges: any = {
|
| 134 |
+
trial: { icon: Zap, color: 'bg-slate-700/50 text-slate-300 border-slate-600', label: 'TRIAL' },
|
| 135 |
+
start: { icon: Rocket, color: 'bg-blue-500/20 text-blue-400 border-blue-500/30', label: 'START $99' },
|
| 136 |
+
growth: { icon: TrendingUp, color: 'bg-indigo-500/20 text-indigo-400 border-indigo-500/30', label: 'GROWTH $199' },
|
| 137 |
+
unlimited: { icon: Crown, color: 'bg-purple-500/20 text-purple-400 border-purple-500/30', label: 'UNLIMITED $500' }
|
| 138 |
}
|
| 139 |
const badge = badges[plan] || badges.trial
|
| 140 |
const Icon = badge.icon
|
| 141 |
return (
|
| 142 |
+
<span className={`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold border ${badge.color}`}>
|
| 143 |
<Icon className="w-4 h-4" />
|
| 144 |
{badge.label}
|
| 145 |
</span>
|
|
|
|
| 149 |
const getStatusBadge = (status: string) => {
|
| 150 |
const safeStatus = (status || 'unknown').toLowerCase()
|
| 151 |
const colors: any = {
|
| 152 |
+
active: 'bg-emerald-500/20 text-emerald-400',
|
| 153 |
+
trial: 'bg-amber-500/20 text-amber-400',
|
| 154 |
+
expired: 'bg-red-500/20 text-red-400',
|
| 155 |
+
suspended: 'bg-orange-500/20 text-orange-400'
|
| 156 |
}
|
| 157 |
+
return <span className={`px-2 py-1 rounded-lg text-xs font-bold ${colors[safeStatus] || 'bg-slate-700/50 text-slate-400'}`}>{safeStatus.toUpperCase()}</span>
|
| 158 |
}
|
| 159 |
|
| 160 |
return (
|
| 161 |
<div className="space-y-6">
|
| 162 |
+
{/* Info Card - Aurora Style */}
|
| 163 |
+
<div className="bg-gradient-to-r from-emerald-500/10 to-teal-500/10 border border-emerald-500/20 p-4 rounded-xl flex items-start gap-3">
|
| 164 |
+
<div className="p-2 bg-emerald-500/20 rounded-lg text-emerald-400">
|
| 165 |
<Briefcase className="w-5 h-5" />
|
| 166 |
</div>
|
| 167 |
<div>
|
| 168 |
+
<h3 className="font-bold text-white text-sm">Рабочие Пространства (Tenants)</h3>
|
| 169 |
+
<p className="text-xs text-slate-400 mt-1 leading-relaxed">
|
| 170 |
Здесь управляются подписки клиентов. Каждый Tenant — это отдельная компания или инстанс, в котором работают пользователи.
|
|
|
|
| 171 |
</p>
|
| 172 |
</div>
|
| 173 |
</div>
|
| 174 |
|
| 175 |
{/* Filters */}
|
| 176 |
+
<div className="bg-slate-900/50 backdrop-blur-sm rounded-2xl border border-white/10 p-6 grid grid-cols-1 md:grid-cols-4 gap-4">
|
| 177 |
<div className="md:col-span-2">
|
| 178 |
<input
|
| 179 |
value={searchQuery}
|
| 180 |
onChange={e => setSearchQuery(e.target.value)}
|
| 181 |
+
className="w-full bg-slate-800/50 border border-white/10 rounded-lg px-4 py-2.5 text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50"
|
| 182 |
+
placeholder="Поиск по названию или email..."
|
| 183 |
/>
|
| 184 |
</div>
|
| 185 |
+
<button
|
| 186 |
+
onClick={loadData}
|
| 187 |
+
className="px-4 py-2.5 bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg font-medium transition-colors"
|
| 188 |
+
>
|
| 189 |
+
Применить фильтр
|
| 190 |
+
</button>
|
| 191 |
</div>
|
| 192 |
|
| 193 |
{/* Table */}
|
| 194 |
+
<div className="bg-slate-900/50 backdrop-blur-sm rounded-2xl border border-white/10 overflow-hidden">
|
| 195 |
<table className="w-full">
|
| 196 |
+
<thead className="border-b border-white/10">
|
| 197 |
<tr>
|
| 198 |
+
<th className="px-6 py-4 text-left font-bold text-slate-400 text-xs uppercase tracking-wider">Клиент</th>
|
| 199 |
+
<th className="px-6 py-4 text-left font-bold text-slate-400 text-xs uppercase tracking-wider">План</th>
|
| 200 |
+
<th className="px-6 py-4 text-left font-bold text-slate-400 text-xs uppercase tracking-wider">Статус</th>
|
| 201 |
+
<th className="px-6 py-4 text-left font-bold text-slate-400 text-xs uppercase tracking-wider">Действия</th>
|
| 202 |
</tr>
|
| 203 |
</thead>
|
| 204 |
+
<tbody className="divide-y divide-white/5">
|
| 205 |
{tenants.map(t => (
|
| 206 |
+
<tr key={t.id} className="hover:bg-white/5 transition-colors">
|
| 207 |
<td className="px-6 py-4">
|
| 208 |
+
<div className="font-bold text-white">{t.business_name}</div>
|
| 209 |
<div className="text-xs text-slate-500">{t.email}</div>
|
| 210 |
</td>
|
| 211 |
<td className="px-6 py-4">{getPlanBadge(t.subscription_plan)}</td>
|
| 212 |
<td className="px-6 py-4">{getStatusBadge(t.subscription_status)}</td>
|
| 213 |
<td className="px-6 py-4 flex gap-2">
|
| 214 |
+
<button
|
| 215 |
+
onClick={() => openEditModal(t)}
|
| 216 |
+
className="p-2 text-indigo-400 hover:bg-indigo-500/20 rounded-lg transition-colors"
|
| 217 |
+
>
|
| 218 |
+
<Edit className="w-4 h-4" />
|
| 219 |
+
</button>
|
| 220 |
{t.is_active ?
|
| 221 |
+
<button
|
| 222 |
+
onClick={() => handleSuspend(t.id)}
|
| 223 |
+
className="p-2 text-red-400 hover:bg-red-500/20 rounded-lg transition-colors"
|
| 224 |
+
>
|
| 225 |
+
<Ban className="w-4 h-4" />
|
| 226 |
+
</button> :
|
| 227 |
+
<button
|
| 228 |
+
onClick={() => handleActivate(t.id)}
|
| 229 |
+
className="p-2 text-emerald-400 hover:bg-emerald-500/20 rounded-lg transition-colors"
|
| 230 |
+
>
|
| 231 |
+
<Play className="w-4 h-4" />
|
| 232 |
+
</button>
|
| 233 |
}
|
| 234 |
</td>
|
| 235 |
</tr>
|
| 236 |
))}
|
| 237 |
</tbody>
|
| 238 |
</table>
|
| 239 |
+
|
| 240 |
+
{tenants.length === 0 && !loading && (
|
| 241 |
+
<div className="p-8 text-center text-slate-500">
|
| 242 |
+
Нет данных для отображения
|
| 243 |
+
</div>
|
| 244 |
+
)}
|
| 245 |
</div>
|
| 246 |
|
| 247 |
+
{/* Modal - Aurora Dark Style */}
|
| 248 |
{showEditModal && (
|
| 249 |
+
<div className="fixed inset-0 bg-black/70 backdrop-blur-sm flex items-center justify-center z-50">
|
| 250 |
+
<div className="bg-slate-900 border border-white/10 p-6 rounded-2xl w-96 shadow-2xl">
|
| 251 |
+
<div className="flex items-center justify-between mb-6">
|
| 252 |
+
<h3 className="font-bold text-white text-lg">Изменить подписку</h3>
|
| 253 |
+
<button
|
| 254 |
+
onClick={() => setShowEditModal(false)}
|
| 255 |
+
className="p-1 text-slate-400 hover:text-white transition-colors"
|
| 256 |
+
>
|
| 257 |
+
<X className="w-5 h-5" />
|
| 258 |
+
</button>
|
| 259 |
+
</div>
|
| 260 |
+
|
| 261 |
+
<div className="space-y-4">
|
| 262 |
+
<div>
|
| 263 |
+
<label className="block text-sm font-medium text-slate-400 mb-2">Тарифный план</label>
|
| 264 |
+
<select
|
| 265 |
+
value={editPlan}
|
| 266 |
+
onChange={e => setEditPlan(e.target.value)}
|
| 267 |
+
className="w-full bg-slate-800 border border-white/10 p-3 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50"
|
| 268 |
+
>
|
| 269 |
+
<option value="trial">Trial</option>
|
| 270 |
+
<option value="start">Start</option>
|
| 271 |
+
<option value="growth">Growth</option>
|
| 272 |
+
<option value="unlimited">Unlimited</option>
|
| 273 |
+
</select>
|
| 274 |
+
</div>
|
| 275 |
+
|
| 276 |
+
<div>
|
| 277 |
+
<label className="block text-sm font-medium text-slate-400 mb-2">Статус</label>
|
| 278 |
+
<select
|
| 279 |
+
value={editStatus}
|
| 280 |
+
onChange={e => setEditStatus(e.target.value)}
|
| 281 |
+
className="w-full bg-slate-800 border border-white/10 p-3 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50"
|
| 282 |
+
>
|
| 283 |
+
<option value="active">Active</option>
|
| 284 |
+
<option value="expired">Expired</option>
|
| 285 |
+
<option value="suspended">Suspended</option>
|
| 286 |
+
</select>
|
| 287 |
+
</div>
|
| 288 |
+
|
| 289 |
+
<div>
|
| 290 |
+
<label className="block text-sm font-medium text-slate-400 mb-2">Продлить на (дней)</label>
|
| 291 |
+
<input
|
| 292 |
+
type="number"
|
| 293 |
+
value={daysToAdd}
|
| 294 |
+
onChange={e => setDaysToAdd(Number(e.target.value))}
|
| 295 |
+
className="w-full bg-slate-800 border border-white/10 p-3 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50"
|
| 296 |
+
/>
|
| 297 |
+
</div>
|
| 298 |
+
</div>
|
| 299 |
+
|
| 300 |
+
<div className="flex justify-end gap-3 mt-6">
|
| 301 |
+
<button
|
| 302 |
+
onClick={() => setShowEditModal(false)}
|
| 303 |
+
className="px-4 py-2.5 border border-white/10 text-slate-400 hover:text-white rounded-lg transition-colors"
|
| 304 |
+
>
|
| 305 |
+
Отмена
|
| 306 |
+
</button>
|
| 307 |
+
<button
|
| 308 |
+
onClick={handleUpdateSubscription}
|
| 309 |
+
disabled={updating}
|
| 310 |
+
className="px-4 py-2.5 bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg font-medium transition-colors disabled:opacity-50"
|
| 311 |
+
>
|
| 312 |
+
{updating ? 'Сохранение...' : 'Сохранить'}
|
| 313 |
+
</button>
|
| 314 |
</div>
|
| 315 |
</div>
|
| 316 |
</div>
|
frontend/components/admin/UserDetailsModal.tsx
CHANGED
|
@@ -60,15 +60,15 @@ export default function UserDetailsModal({ user, isOpen, onClose, onUpdate }: Us
|
|
| 60 |
body: JSON.stringify({ role, is_active: isActive, is_verified: isVerified })
|
| 61 |
})
|
| 62 |
if (res.ok) {
|
| 63 |
-
toast.success('
|
| 64 |
onUpdate()
|
| 65 |
}
|
| 66 |
-
} catch (e) { toast.error('
|
| 67 |
finally { setIsLoading(false) }
|
| 68 |
}
|
| 69 |
|
| 70 |
const handleCreatePartner = async () => {
|
| 71 |
-
if (!partnerName) return toast.error('
|
| 72 |
setIsLoading(true)
|
| 73 |
try {
|
| 74 |
const res = await fetch(`/api/v1/admin/users/${user.id}/partner`, {
|
|
@@ -80,19 +80,19 @@ export default function UserDetailsModal({ user, isOpen, onClose, onUpdate }: Us
|
|
| 80 |
body: JSON.stringify({ company_name: partnerName })
|
| 81 |
})
|
| 82 |
if (res.ok) {
|
| 83 |
-
toast.success('
|
| 84 |
onUpdate()
|
| 85 |
onClose()
|
| 86 |
} else {
|
| 87 |
const err = await res.json()
|
| 88 |
-
toast.error('
|
| 89 |
}
|
| 90 |
-
} catch (e) { toast.error('
|
| 91 |
finally { setIsLoading(false) }
|
| 92 |
}
|
| 93 |
|
| 94 |
const handleDeleteUser = async () => {
|
| 95 |
-
if (!confirm(`
|
| 96 |
setIsLoading(true)
|
| 97 |
try {
|
| 98 |
const res = await fetch(`/api/v1/admin/users/${user.id}`, {
|
|
@@ -100,48 +100,48 @@ export default function UserDetailsModal({ user, isOpen, onClose, onUpdate }: Us
|
|
| 100 |
headers: { 'Authorization': `Bearer ${localStorage.getItem('auth_token')}` }
|
| 101 |
})
|
| 102 |
if (res.ok) {
|
| 103 |
-
toast.success('
|
| 104 |
onUpdate()
|
| 105 |
onClose()
|
| 106 |
} else {
|
| 107 |
const err = await res.json()
|
| 108 |
-
toast.error('
|
| 109 |
}
|
| 110 |
-
} catch (e) { toast.error('
|
| 111 |
finally { setIsLoading(false) }
|
| 112 |
}
|
| 113 |
|
| 114 |
return (
|
| 115 |
<div className="fixed inset-0 bg-black/70 backdrop-blur-sm z-50 flex items-center justify-center p-4">
|
| 116 |
-
<div className="bg-white rounded-2xl w-full max-w-2xl shadow-2xl overflow-hidden flex flex-col max-h-[90vh]">
|
| 117 |
{/* Header */}
|
| 118 |
-
<div className="p-6 border-b flex justify-between items-start bg-slate-50">
|
| 119 |
<div className="flex gap-4">
|
| 120 |
-
<div className="w-12 h-12 bg-indigo-600 rounded-full flex items-center justify-center text-white text-xl font-bold shadow-lg shadow-indigo-
|
| 121 |
{user.full_name?.[0] || user.email[0].toUpperCase()}
|
| 122 |
</div>
|
| 123 |
<div>
|
| 124 |
-
<h2 className="text-xl font-bold text-
|
| 125 |
-
<p className="text-slate-
|
| 126 |
<div className="flex gap-2 mt-2">
|
| 127 |
-
<span className="px-2 py-0.5 bg-slate-
|
| 128 |
-
{user.partner_status && <span className="px-2 py-0.5 bg-amber-
|
| 129 |
</div>
|
| 130 |
</div>
|
| 131 |
</div>
|
| 132 |
-
<button onClick={onClose} className="p-2 hover:bg-
|
| 133 |
</div>
|
| 134 |
|
| 135 |
{/* Tabs */}
|
| 136 |
-
<div className="flex border-b">
|
| 137 |
-
<button onClick={() => setActiveTab('profile')} className={`flex-1 py-3 text-sm font-bold flex items-center justify-center gap-2 ${activeTab === 'profile' ? 'border-b-2 border-indigo-
|
| 138 |
-
<UserIcon className="w-4 h-4" />
|
| 139 |
</button>
|
| 140 |
-
<button onClick={() => setActiveTab('partner')} className={`flex-1 py-3 text-sm font-bold flex items-center justify-center gap-2 ${activeTab === 'partner' ? 'border-b-2 border-amber-500 text-amber-
|
| 141 |
-
<DollarSign className="w-4 h-4" />
|
| 142 |
</button>
|
| 143 |
-
<button onClick={() => setActiveTab('danger')} className={`flex-1 py-3 text-sm font-bold flex items-center justify-center gap-2 ${activeTab === 'danger' ? 'border-b-2 border-red-500 text-red-
|
| 144 |
-
<AlertTriangle className="w-4 h-4" />
|
| 145 |
</button>
|
| 146 |
</div>
|
| 147 |
|
|
@@ -151,37 +151,37 @@ export default function UserDetailsModal({ user, isOpen, onClose, onUpdate }: Us
|
|
| 151 |
<div className="space-y-6">
|
| 152 |
<div className="grid grid-cols-2 gap-4">
|
| 153 |
<div>
|
| 154 |
-
<label className="text-xs font-bold text-slate-400 uppercase">
|
| 155 |
-
<select value={role} onChange={e => setRole(e.target.value)} className="w-full mt-1 p-2 border rounded-lg bg-slate-50">
|
| 156 |
<option value="OWNER">Owner</option>
|
| 157 |
<option value="MANAGER">Manager</option>
|
| 158 |
<option value="admin">Super Admin</option>
|
| 159 |
</select>
|
| 160 |
</div>
|
| 161 |
<div>
|
| 162 |
-
<label className="text-xs font-bold text-slate-400 uppercase">
|
| 163 |
<div className="mt-2 flex items-center gap-2">
|
| 164 |
-
<button onClick={() => setIsActive(!isActive)} className={`w-12 h-6 rounded-full p-1 transition-colors ${isActive ? 'bg-emerald-500' : 'bg-slate-
|
| 165 |
<div className={`w-4 h-4 bg-white rounded-full shadow transition-transform ${isActive ? 'translate-x-6' : ''}`} />
|
| 166 |
</button>
|
| 167 |
-
<span className="text-sm font-medium">{isActive ? '
|
| 168 |
</div>
|
| 169 |
</div>
|
| 170 |
</div>
|
| 171 |
|
| 172 |
-
<div className="p-4 bg-indigo-
|
| 173 |
<label className="flex items-center gap-3 cursor-pointer">
|
| 174 |
-
<div className={`w-5 h-5 rounded border flex items-center justify-center ${isVerified ? 'bg-indigo-600 border-indigo-600' : 'bg-
|
| 175 |
{isVerified && <Check className="w-3 h-3 text-white" />}
|
| 176 |
</div>
|
| 177 |
-
<span className="font-medium text-
|
| 178 |
</label>
|
| 179 |
-
<p className="text-xs text-indigo-
|
| 180 |
</div>
|
| 181 |
|
| 182 |
<div className="flex justify-end">
|
| 183 |
-
<button onClick={handleSaveProfile} disabled={isLoading} className="px-6 py-2 bg-indigo-600 text-white rounded-lg font-bold
|
| 184 |
-
{isLoading ? '
|
| 185 |
</button>
|
| 186 |
</div>
|
| 187 |
</div>
|
|
@@ -191,31 +191,31 @@ export default function UserDetailsModal({ user, isOpen, onClose, onUpdate }: Us
|
|
| 191 |
<div className="space-y-6">
|
| 192 |
{user.partner_status ? (
|
| 193 |
<div className="text-center py-8">
|
| 194 |
-
<div className="w-16 h-16 bg-amber-
|
| 195 |
<Check className="w-8 h-8" />
|
| 196 |
</div>
|
| 197 |
-
<h3 className="text-lg font-bold text-
|
| 198 |
-
<p className="text-slate-
|
| 199 |
-
<p className="text-sm text-amber-
|
| 200 |
</div>
|
| 201 |
) : (
|
| 202 |
<div className="space-y-4">
|
| 203 |
-
<div className="bg-amber-
|
| 204 |
-
<h3 className="font-bold text-
|
| 205 |
-
<p className="text-sm text-
|
| 206 |
-
|
| 207 |
</p>
|
| 208 |
-
<label className="text-xs font-bold text-
|
| 209 |
<input
|
| 210 |
value={partnerName}
|
| 211 |
onChange={e => setPartnerName(e.target.value)}
|
| 212 |
-
className="w-full mt-1 p-2 border border-amber-
|
| 213 |
-
placeholder="
|
| 214 |
/>
|
| 215 |
</div>
|
| 216 |
<div className="flex justify-end">
|
| 217 |
-
<button onClick={handleCreatePartner} disabled={isLoading} className="px-6 py-2 bg-amber-500 text-white rounded-lg font-bold
|
| 218 |
-
{isLoading ? '
|
| 219 |
</button>
|
| 220 |
</div>
|
| 221 |
</div>
|
|
@@ -225,32 +225,32 @@ export default function UserDetailsModal({ user, isOpen, onClose, onUpdate }: Us
|
|
| 225 |
|
| 226 |
{activeTab === 'danger' && (
|
| 227 |
<div className="space-y-6">
|
| 228 |
-
<div className="bg-red-
|
| 229 |
<div className="flex items-start gap-4">
|
| 230 |
-
<div className="bg-red-
|
| 231 |
<AlertTriangle className="w-6 h-6" />
|
| 232 |
</div>
|
| 233 |
<div>
|
| 234 |
-
<h3 className="text-red-
|
| 235 |
-
<p className="text-
|
| 236 |
-
|
| 237 |
<br />
|
| 238 |
-
|
| 239 |
<ul className="list-disc ml-5 mt-1 space-y-1 opacity-80">
|
| 240 |
-
<li>
|
| 241 |
-
<li>
|
| 242 |
-
<li>
|
| 243 |
</ul>
|
| 244 |
<br />
|
| 245 |
-
|
| 246 |
</p>
|
| 247 |
</div>
|
| 248 |
</div>
|
| 249 |
|
| 250 |
<div className="mt-8 flex justify-end">
|
| 251 |
-
<button onClick={handleDeleteUser} disabled={isLoading} className="flex items-center gap-2 px-6 py-3 bg-red-600 text-white rounded-xl font-bold
|
| 252 |
<Trash className="w-4 h-4" />
|
| 253 |
-
{isLoading ? '
|
| 254 |
</button>
|
| 255 |
</div>
|
| 256 |
</div>
|
|
|
|
| 60 |
body: JSON.stringify({ role, is_active: isActive, is_verified: isVerified })
|
| 61 |
})
|
| 62 |
if (res.ok) {
|
| 63 |
+
toast.success('Сохранено', 'Профиль обновлен')
|
| 64 |
onUpdate()
|
| 65 |
}
|
| 66 |
+
} catch (e) { toast.error('Ошибка', 'Не удалось сохранить') }
|
| 67 |
finally { setIsLoading(false) }
|
| 68 |
}
|
| 69 |
|
| 70 |
const handleCreatePartner = async () => {
|
| 71 |
+
if (!partnerName) return toast.error('Ошибка', 'Название компании обязательно')
|
| 72 |
setIsLoading(true)
|
| 73 |
try {
|
| 74 |
const res = await fetch(`/api/v1/admin/users/${user.id}/partner`, {
|
|
|
|
| 80 |
body: JSON.stringify({ company_name: partnerName })
|
| 81 |
})
|
| 82 |
if (res.ok) {
|
| 83 |
+
toast.success('Успех', 'Партнерский профиль создан')
|
| 84 |
onUpdate()
|
| 85 |
onClose()
|
| 86 |
} else {
|
| 87 |
const err = await res.json()
|
| 88 |
+
toast.error('Ошибка', err.detail || 'Ошибка')
|
| 89 |
}
|
| 90 |
+
} catch (e) { toast.error('Ошибка', 'Ошибка сети') }
|
| 91 |
finally { setIsLoading(false) }
|
| 92 |
}
|
| 93 |
|
| 94 |
const handleDeleteUser = async () => {
|
| 95 |
+
if (!confirm(`ВЫ УВЕРЕНЫ? Это удалит ${user.email} и все связанные данные.`)) return
|
| 96 |
setIsLoading(true)
|
| 97 |
try {
|
| 98 |
const res = await fetch(`/api/v1/admin/users/${user.id}`, {
|
|
|
|
| 100 |
headers: { 'Authorization': `Bearer ${localStorage.getItem('auth_token')}` }
|
| 101 |
})
|
| 102 |
if (res.ok) {
|
| 103 |
+
toast.success('Удалено', 'Пользователь удален навсегда')
|
| 104 |
onUpdate()
|
| 105 |
onClose()
|
| 106 |
} else {
|
| 107 |
const err = await res.json()
|
| 108 |
+
toast.error('Ошибка', err.detail || 'Не удалось удалить')
|
| 109 |
}
|
| 110 |
+
} catch (e) { toast.error('Ошибка', 'Ошибка сети') }
|
| 111 |
finally { setIsLoading(false) }
|
| 112 |
}
|
| 113 |
|
| 114 |
return (
|
| 115 |
<div className="fixed inset-0 bg-black/70 backdrop-blur-sm z-50 flex items-center justify-center p-4">
|
| 116 |
+
<div className="bg-slate-900 border border-white/10 rounded-2xl w-full max-w-2xl shadow-2xl overflow-hidden flex flex-col max-h-[90vh]">
|
| 117 |
{/* Header */}
|
| 118 |
+
<div className="p-6 border-b border-white/10 flex justify-between items-start bg-slate-800/50">
|
| 119 |
<div className="flex gap-4">
|
| 120 |
+
<div className="w-12 h-12 bg-indigo-600 rounded-full flex items-center justify-center text-white text-xl font-bold shadow-lg shadow-indigo-500/20">
|
| 121 |
{user.full_name?.[0] || user.email[0].toUpperCase()}
|
| 122 |
</div>
|
| 123 |
<div>
|
| 124 |
+
<h2 className="text-xl font-bold text-white">{user.full_name || 'Без имени'}</h2>
|
| 125 |
+
<p className="text-slate-400 font-mono text-sm">{user.email}</p>
|
| 126 |
<div className="flex gap-2 mt-2">
|
| 127 |
+
<span className="px-2 py-0.5 bg-slate-700/50 text-slate-300 rounded text-[10px] font-bold uppercase">{user.role}</span>
|
| 128 |
+
{user.partner_status && <span className="px-2 py-0.5 bg-amber-500/20 text-amber-400 rounded text-[10px] font-bold border border-amber-500/30">ПАРТНЕР</span>}
|
| 129 |
</div>
|
| 130 |
</div>
|
| 131 |
</div>
|
| 132 |
+
<button onClick={onClose} className="p-2 hover:bg-white/10 rounded-full transition-colors"><X className="w-5 h-5 text-slate-400" /></button>
|
| 133 |
</div>
|
| 134 |
|
| 135 |
{/* Tabs */}
|
| 136 |
+
<div className="flex border-b border-white/10">
|
| 137 |
+
<button onClick={() => setActiveTab('profile')} className={`flex-1 py-3 text-sm font-bold flex items-center justify-center gap-2 transition-colors ${activeTab === 'profile' ? 'border-b-2 border-indigo-500 text-indigo-400 bg-indigo-500/10' : 'text-slate-500 hover:text-white hover:bg-white/5'}`}>
|
| 138 |
+
<UserIcon className="w-4 h-4" /> Профиль
|
| 139 |
</button>
|
| 140 |
+
<button onClick={() => setActiveTab('partner')} className={`flex-1 py-3 text-sm font-bold flex items-center justify-center gap-2 transition-colors ${activeTab === 'partner' ? 'border-b-2 border-amber-500 text-amber-400 bg-amber-500/10' : 'text-slate-500 hover:text-white hover:bg-white/5'}`}>
|
| 141 |
+
<DollarSign className="w-4 h-4" /> Партнер
|
| 142 |
</button>
|
| 143 |
+
<button onClick={() => setActiveTab('danger')} className={`flex-1 py-3 text-sm font-bold flex items-center justify-center gap-2 transition-colors ${activeTab === 'danger' ? 'border-b-2 border-red-500 text-red-400 bg-red-500/10' : 'text-slate-500 hover:text-white hover:bg-white/5'}`}>
|
| 144 |
+
<AlertTriangle className="w-4 h-4" /> Опасная зона
|
| 145 |
</button>
|
| 146 |
</div>
|
| 147 |
|
|
|
|
| 151 |
<div className="space-y-6">
|
| 152 |
<div className="grid grid-cols-2 gap-4">
|
| 153 |
<div>
|
| 154 |
+
<label className="text-xs font-bold text-slate-400 uppercase">Роль</label>
|
| 155 |
+
<select value={role} onChange={e => setRole(e.target.value)} className="w-full mt-1 p-2.5 border border-white/10 rounded-lg bg-slate-800 text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50">
|
| 156 |
<option value="OWNER">Owner</option>
|
| 157 |
<option value="MANAGER">Manager</option>
|
| 158 |
<option value="admin">Super Admin</option>
|
| 159 |
</select>
|
| 160 |
</div>
|
| 161 |
<div>
|
| 162 |
+
<label className="text-xs font-bold text-slate-400 uppercase">Статус</label>
|
| 163 |
<div className="mt-2 flex items-center gap-2">
|
| 164 |
+
<button onClick={() => setIsActive(!isActive)} className={`w-12 h-6 rounded-full p-1 transition-colors ${isActive ? 'bg-emerald-500' : 'bg-slate-600'}`}>
|
| 165 |
<div className={`w-4 h-4 bg-white rounded-full shadow transition-transform ${isActive ? 'translate-x-6' : ''}`} />
|
| 166 |
</button>
|
| 167 |
+
<span className="text-sm font-medium text-slate-300">{isActive ? 'Активен' : 'Заблокирован'}</span>
|
| 168 |
</div>
|
| 169 |
</div>
|
| 170 |
</div>
|
| 171 |
|
| 172 |
+
<div className="p-4 bg-indigo-500/10 rounded-xl border border-indigo-500/20">
|
| 173 |
<label className="flex items-center gap-3 cursor-pointer">
|
| 174 |
+
<div className={`w-5 h-5 rounded border flex items-center justify-center transition-colors ${isVerified ? 'bg-indigo-600 border-indigo-600' : 'bg-slate-800 border-slate-600'}`} onClick={() => setIsVerified(!isVerified)}>
|
| 175 |
{isVerified && <Check className="w-3 h-3 text-white" />}
|
| 176 |
</div>
|
| 177 |
+
<span className="font-medium text-white">Email подтвержден вручную</span>
|
| 178 |
</label>
|
| 179 |
+
<p className="text-xs text-indigo-400 mt-2 ml-8">Отметьте, если пользователь не может подтвердить email самостоятельно.</p>
|
| 180 |
</div>
|
| 181 |
|
| 182 |
<div className="flex justify-end">
|
| 183 |
+
<button onClick={handleSaveProfile} disabled={isLoading} className="px-6 py-2.5 bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg font-bold transition-colors disabled:opacity-50">
|
| 184 |
+
{isLoading ? 'Сохранение...' : 'Сохранить изменения'}
|
| 185 |
</button>
|
| 186 |
</div>
|
| 187 |
</div>
|
|
|
|
| 191 |
<div className="space-y-6">
|
| 192 |
{user.partner_status ? (
|
| 193 |
<div className="text-center py-8">
|
| 194 |
+
<div className="w-16 h-16 bg-amber-500/20 rounded-full flex items-center justify-center mx-auto mb-4 text-amber-400">
|
| 195 |
<Check className="w-8 h-8" />
|
| 196 |
</div>
|
| 197 |
+
<h3 className="text-lg font-bold text-white">Уже партнер</h3>
|
| 198 |
+
<p className="text-slate-400 mb-4">Реферальный код: <span className="font-mono text-white bg-slate-800 px-2 py-1 rounded">{user.referral_code}</span></p>
|
| 199 |
+
<p className="text-sm text-amber-400 font-medium">Детальные настройки в разделе «Партнеры».</p>
|
| 200 |
</div>
|
| 201 |
) : (
|
| 202 |
<div className="space-y-4">
|
| 203 |
+
<div className="bg-amber-500/10 p-4 rounded-xl border border-amber-500/20">
|
| 204 |
+
<h3 className="font-bold text-white mb-2">Назначить партнером</h3>
|
| 205 |
+
<p className="text-sm text-slate-400 mb-4">
|
| 206 |
+
Это создаст партнерский профиль для пользователя. Он получит доступ к партнерской панели.
|
| 207 |
</p>
|
| 208 |
+
<label className="text-xs font-bold text-slate-400 uppercase">Название компании</label>
|
| 209 |
<input
|
| 210 |
value={partnerName}
|
| 211 |
onChange={e => setPartnerName(e.target.value)}
|
| 212 |
+
className="w-full mt-1 p-2.5 border border-amber-500/20 rounded-lg bg-slate-800 text-white focus:outline-none focus:ring-2 focus:ring-amber-500/50"
|
| 213 |
+
placeholder="Название агентства..."
|
| 214 |
/>
|
| 215 |
</div>
|
| 216 |
<div className="flex justify-end">
|
| 217 |
+
<button onClick={handleCreatePartner} disabled={isLoading} className="px-6 py-2.5 bg-amber-500 hover:bg-amber-400 text-white rounded-lg font-bold transition-colors disabled:opacity-50">
|
| 218 |
+
{isLoading ? 'Создание...' : 'Создать партнера'}
|
| 219 |
</button>
|
| 220 |
</div>
|
| 221 |
</div>
|
|
|
|
| 225 |
|
| 226 |
{activeTab === 'danger' && (
|
| 227 |
<div className="space-y-6">
|
| 228 |
+
<div className="bg-red-500/10 p-6 rounded-xl border border-red-500/20">
|
| 229 |
<div className="flex items-start gap-4">
|
| 230 |
+
<div className="bg-red-500/20 p-2 rounded-lg text-red-400">
|
| 231 |
<AlertTriangle className="w-6 h-6" />
|
| 232 |
</div>
|
| 233 |
<div>
|
| 234 |
+
<h3 className="text-red-400 font-bold text-lg">Опасная зона</h3>
|
| 235 |
+
<p className="text-slate-400 mt-2 text-sm leading-relaxed">
|
| 236 |
+
Удаление пользователя <strong className="text-white">необратимо</strong>.
|
| 237 |
<br />
|
| 238 |
+
Будут удалены:
|
| 239 |
<ul className="list-disc ml-5 mt-1 space-y-1 opacity-80">
|
| 240 |
+
<li>Партнерский профиль</li>
|
| 241 |
+
<li>Назначения менеджера</li>
|
| 242 |
+
<li>Данные авторизации</li>
|
| 243 |
</ul>
|
| 244 |
<br />
|
| 245 |
+
Если пользователь владеет Tenant, сам Tenant <strong className="text-white">НЕ</strong> будет удален для сохранения данных.
|
| 246 |
</p>
|
| 247 |
</div>
|
| 248 |
</div>
|
| 249 |
|
| 250 |
<div className="mt-8 flex justify-end">
|
| 251 |
+
<button onClick={handleDeleteUser} disabled={isLoading} className="flex items-center gap-2 px-6 py-3 bg-red-600 hover:bg-red-500 text-white rounded-xl font-bold transition-colors shadow-lg shadow-red-500/20 disabled:opacity-50">
|
| 252 |
<Trash className="w-4 h-4" />
|
| 253 |
+
{isLoading ? 'Удаление...' : 'УДАЛИТЬ НАВСЕГДА'}
|
| 254 |
</button>
|
| 255 |
</div>
|
| 256 |
</div>
|