Spaces:
Running
Running
axeronis commited on
Commit ·
297f9bf
1
Parent(s): f9d8a0f
fix: add notification_settings to TenantResponse + show bot name in Channels
Browse files- backend/app/api/tenants.py +4 -0
- frontend/app/channels/page.tsx +12 -2
backend/app/api/tenants.py
CHANGED
|
@@ -36,6 +36,7 @@ class TenantResponse(BaseModel):
|
|
| 36 |
banned_words: Optional[list]
|
| 37 |
|
| 38 |
booking_settings: Optional[Dict[str, Any]]
|
|
|
|
| 39 |
manager_monthly_salary: int = 1000
|
| 40 |
tokens_balance: int
|
| 41 |
is_active: bool
|
|
@@ -144,6 +145,7 @@ async def get_my_tenant(
|
|
| 144 |
|
| 145 |
banned_words=getattr(tenant, 'banned_words', []),
|
| 146 |
booking_settings=tenant.booking_settings,
|
|
|
|
| 147 |
tokens_balance=tenant.tokens_balance,
|
| 148 |
is_active=tenant.is_active,
|
| 149 |
manager_monthly_salary=tenant.manager_monthly_salary,
|
|
@@ -265,6 +267,7 @@ async def update_my_tenant(
|
|
| 265 |
custom_instructions=(tenant.ai_settings or {}).get("custom_instructions"),
|
| 266 |
banned_words=(tenant.ai_settings or {}).get("banned_words"),
|
| 267 |
booking_settings=tenant.booking_settings,
|
|
|
|
| 268 |
tokens_balance=tenant.tokens_balance,
|
| 269 |
is_active=tenant.is_active,
|
| 270 |
manager_monthly_salary=tenant.manager_monthly_salary,
|
|
@@ -369,6 +372,7 @@ async def get_tenant(
|
|
| 369 |
|
| 370 |
banned_words=getattr(tenant, 'banned_words', []),
|
| 371 |
booking_settings=tenant.booking_settings,
|
|
|
|
| 372 |
tokens_balance=tenant.tokens_balance,
|
| 373 |
is_active=tenant.is_active,
|
| 374 |
referred_by=referred_by
|
|
|
|
| 36 |
banned_words: Optional[list]
|
| 37 |
|
| 38 |
booking_settings: Optional[Dict[str, Any]]
|
| 39 |
+
notification_settings: Optional[Dict[str, Any]] = None # Added for notifications
|
| 40 |
manager_monthly_salary: int = 1000
|
| 41 |
tokens_balance: int
|
| 42 |
is_active: bool
|
|
|
|
| 145 |
|
| 146 |
banned_words=getattr(tenant, 'banned_words', []),
|
| 147 |
booking_settings=tenant.booking_settings,
|
| 148 |
+
notification_settings=tenant.notification_settings,
|
| 149 |
tokens_balance=tenant.tokens_balance,
|
| 150 |
is_active=tenant.is_active,
|
| 151 |
manager_monthly_salary=tenant.manager_monthly_salary,
|
|
|
|
| 267 |
custom_instructions=(tenant.ai_settings or {}).get("custom_instructions"),
|
| 268 |
banned_words=(tenant.ai_settings or {}).get("banned_words"),
|
| 269 |
booking_settings=tenant.booking_settings,
|
| 270 |
+
notification_settings=tenant.notification_settings,
|
| 271 |
tokens_balance=tenant.tokens_balance,
|
| 272 |
is_active=tenant.is_active,
|
| 273 |
manager_monthly_salary=tenant.manager_monthly_salary,
|
|
|
|
| 372 |
|
| 373 |
banned_words=getattr(tenant, 'banned_words', []),
|
| 374 |
booking_settings=tenant.booking_settings,
|
| 375 |
+
notification_settings=tenant.notification_settings,
|
| 376 |
tokens_balance=tenant.tokens_balance,
|
| 377 |
is_active=tenant.is_active,
|
| 378 |
referred_by=referred_by
|
frontend/app/channels/page.tsx
CHANGED
|
@@ -131,6 +131,7 @@ export default function ChannelsPage() {
|
|
| 131 |
gradient="from-[#229ED9] to-[#0F4C75]"
|
| 132 |
isConnected={telegramStatus?.connected}
|
| 133 |
statusText={telegramStatus?.connected ? 'Активно' : 'Не подключен'}
|
|
|
|
| 134 |
stats={{
|
| 135 |
users: telegramStatus?.connected ? 45 : 0,
|
| 136 |
messages: 0,
|
|
@@ -232,9 +233,10 @@ interface ChannelCardProps {
|
|
| 232 |
onConfigure: () => void
|
| 233 |
onDisconnect: () => void
|
| 234 |
isComingSoon?: boolean
|
|
|
|
| 235 |
}
|
| 236 |
|
| 237 |
-
function ChannelCard({ title, icon, gradient, isConnected, statusText, stats, onConfigure, onDisconnect, isComingSoon }: ChannelCardProps) {
|
| 238 |
return (
|
| 239 |
<div className={cn(
|
| 240 |
"relative rounded-[32px] overflow-hidden min-h-[500px] flex flex-col p-8 border border-white/5 will-change-transform",
|
|
@@ -253,7 +255,7 @@ function ChannelCard({ title, icon, gradient, isConnected, statusText, stats, on
|
|
| 253 |
<h2 className="text-3xl font-bold text-white mb-2">{title}</h2>
|
| 254 |
|
| 255 |
<div className={cn(
|
| 256 |
-
"px-4 py-1.5 rounded-full flex items-center gap-2 mb-
|
| 257 |
isConnected ? "bg-emerald-500/20 text-emerald-200 border border-emerald-500/30"
|
| 258 |
: isComingSoon ? "bg-pink-500/20 text-pink-200 border border-pink-500/30"
|
| 259 |
: "bg-white/10 text-white/60 border border-white/10"
|
|
@@ -262,6 +264,14 @@ function ChannelCard({ title, icon, gradient, isConnected, statusText, stats, on
|
|
| 262 |
<span className="text-sm font-medium">{statusText}</span>
|
| 263 |
</div>
|
| 264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
{!isComingSoon && (
|
| 266 |
<button
|
| 267 |
onClick={isConnected ? onDisconnect : onConfigure}
|
|
|
|
| 131 |
gradient="from-[#229ED9] to-[#0F4C75]"
|
| 132 |
isConnected={telegramStatus?.connected}
|
| 133 |
statusText={telegramStatus?.connected ? 'Активно' : 'Не подключен'}
|
| 134 |
+
botInfo={telegramStatus?.bot_info}
|
| 135 |
stats={{
|
| 136 |
users: telegramStatus?.connected ? 45 : 0,
|
| 137 |
messages: 0,
|
|
|
|
| 233 |
onConfigure: () => void
|
| 234 |
onDisconnect: () => void
|
| 235 |
isComingSoon?: boolean
|
| 236 |
+
botInfo?: { username?: string; first_name?: string } | null
|
| 237 |
}
|
| 238 |
|
| 239 |
+
function ChannelCard({ title, icon, gradient, isConnected, statusText, stats, onConfigure, onDisconnect, isComingSoon, botInfo }: ChannelCardProps) {
|
| 240 |
return (
|
| 241 |
<div className={cn(
|
| 242 |
"relative rounded-[32px] overflow-hidden min-h-[500px] flex flex-col p-8 border border-white/5 will-change-transform",
|
|
|
|
| 255 |
<h2 className="text-3xl font-bold text-white mb-2">{title}</h2>
|
| 256 |
|
| 257 |
<div className={cn(
|
| 258 |
+
"px-4 py-1.5 rounded-full flex items-center gap-2 mb-2",
|
| 259 |
isConnected ? "bg-emerald-500/20 text-emerald-200 border border-emerald-500/30"
|
| 260 |
: isComingSoon ? "bg-pink-500/20 text-pink-200 border border-pink-500/30"
|
| 261 |
: "bg-white/10 text-white/60 border border-white/10"
|
|
|
|
| 264 |
<span className="text-sm font-medium">{statusText}</span>
|
| 265 |
</div>
|
| 266 |
|
| 267 |
+
{/* Connected Bot Name */}
|
| 268 |
+
{isConnected && botInfo?.username && (
|
| 269 |
+
<div className="mb-6 text-center">
|
| 270 |
+
<span className="text-white/70 text-sm">@{botInfo.username}</span>
|
| 271 |
+
</div>
|
| 272 |
+
)}
|
| 273 |
+
{!botInfo?.username && <div className="mb-6" />}
|
| 274 |
+
|
| 275 |
{!isComingSoon && (
|
| 276 |
<button
|
| 277 |
onClick={isConnected ? onDisconnect : onConfigure}
|