From ac2db590d0159c08bc5e89fbf1d9070190e6f3b8 Mon Sep 17 00:00:00 2001 From: ochenstarik Date: Sat, 12 Sep 2026 19:30:15 +0700 Subject: [PATCH] feat(communications): separate user accounts from bot channels --- .../communications/CommunicationsModule.tsx | 16 ++++++-- .../components/CommunicationsHeader.tsx | 4 +- .../communications/components/EmailView.tsx | 14 +++++-- .../components/MessengersView.tsx | 4 +- .../communications/components/Modals.tsx | 40 +++++++++++-------- .../components/SettingsView.tsx | 25 +++++++++++- 6 files changed, 76 insertions(+), 27 deletions(-) diff --git a/src/features/communications/CommunicationsModule.tsx b/src/features/communications/CommunicationsModule.tsx index 7e209be..8a7089d 100644 --- a/src/features/communications/CommunicationsModule.tsx +++ b/src/features/communications/CommunicationsModule.tsx @@ -23,6 +23,14 @@ export function CommunicationsModule() { const [isCreateChannelOpen, setIsCreateChannelOpen] = useState(false); const [isAddContactOpen, setIsAddContactOpen] = useState(false); const [isConnectChannelOpen, setIsConnectChannelOpen] = useState(false); + const [connectMode, setConnectMode] = useState<'messenger' | 'email'>('messenger'); + const [showChannelsTab, setShowChannelsTab] = useState(() => localStorage.getItem('krona-show-bot-channels') === 'true'); + + const updateChannelsVisibility = (enabled: boolean) => { + setShowChannelsTab(enabled); + localStorage.setItem('krona-show-bot-channels', String(enabled)); + if (!enabled && currentTab === 'channels') handleTabChange('settings'); + }; // Sync tab with URL search param const urlTab = searchParams.get('tab') as CommunicationTab | null; @@ -45,6 +53,7 @@ export function CommunicationsModule() { unreadChats={48} unreadEmails={10} unreadChannels={4} + showChannelsTab={showChannelsTab} /> @@ -52,12 +61,12 @@ export function CommunicationsModule() {
{currentTab === 'messengers' && ( setIsConnectChannelOpen(true)} + onOpenConnectModal={() => { setConnectMode('messenger'); setIsConnectChannelOpen(true); }} onOpenAddContactModal={() => setIsAddContactOpen(true)} /> )} {currentTab === 'email' && ( - setIsComposeEmailOpen(true)} /> + setIsComposeEmailOpen(true)} onAddMailbox={() => { setConnectMode('email'); setIsConnectChannelOpen(true); }} /> )} {currentTab === 'channels' && ( setIsCreateChannelOpen(true)} /> @@ -65,7 +74,7 @@ export function CommunicationsModule() { {currentTab === 'contacts' && ( setIsAddContactOpen(true)} /> )} - {currentTab === 'settings' && } + {currentTab === 'settings' && }
{/* Modals */} @@ -84,6 +93,7 @@ export function CommunicationsModule() { setIsConnectChannelOpen(false)} + mode={connectMode} /> ); diff --git a/src/features/communications/components/CommunicationsHeader.tsx b/src/features/communications/components/CommunicationsHeader.tsx index fa51ecd..890394b 100644 --- a/src/features/communications/components/CommunicationsHeader.tsx +++ b/src/features/communications/components/CommunicationsHeader.tsx @@ -9,6 +9,7 @@ interface CommunicationsHeaderProps { unreadChats: number; unreadEmails: number; unreadChannels: number; + showChannelsTab: boolean; } export function CommunicationsHeader({ @@ -17,6 +18,7 @@ export function CommunicationsHeader({ unreadChats, unreadEmails, unreadChannels, + showChannelsTab, }: CommunicationsHeaderProps) { const tabItems = [ { @@ -47,7 +49,7 @@ export function CommunicationsHeader({ label: 'Настройки', icon: , }, - ]; + ].filter((item) => item.id !== 'channels' || showChannelsTab); return (
diff --git a/src/features/communications/components/EmailView.tsx b/src/features/communications/components/EmailView.tsx index 81260fc..b1178d2 100644 --- a/src/features/communications/components/EmailView.tsx +++ b/src/features/communications/components/EmailView.tsx @@ -9,9 +9,10 @@ import { useToast } from '../../../shared/ui'; interface EmailViewProps { onComposeEmail: () => void; + onAddMailbox: () => void; } -export function EmailView({ onComposeEmail }: EmailViewProps) { +export function EmailView({ onComposeEmail, onAddMailbox }: EmailViewProps) { const { showToast } = useToast(); const { mailboxes, @@ -56,9 +57,14 @@ export function EmailView({ onComposeEmail }: EmailViewProps) { {/* Mailbox Selector */}
- - Почтовые ящики - +
+ + Почтовые ящики + + +
{mailboxes.map((mb) => ( diff --git a/src/features/communications/components/Modals.tsx b/src/features/communications/components/Modals.tsx index dccbe80..98b7c46 100644 --- a/src/features/communications/components/Modals.tsx +++ b/src/features/communications/components/Modals.tsx @@ -295,57 +295,65 @@ export function AddContactModal({ isOpen, onClose }: { isOpen: boolean; onClose: ); } -export function ConnectChannelModal({ isOpen, onClose }: { isOpen: boolean; onClose: () => void }) { +export function ConnectChannelModal({ isOpen, onClose, mode = 'messenger' }: { isOpen: boolean; onClose: () => void; mode?: 'messenger' | 'email' }) { const { showToast } = useToast(); const [platform, setPlatform] = useState('telegram'); const [identifier, setIdentifier] = useState(''); + const [useVpn, setUseVpn] = useState(false); const handleSubmit = (e: FormEvent) => { e.preventDefault(); showToast({ - title: 'Интеграция подключена', - message: `Канал ${platform.toUpperCase()} (${identifier || 'bot'}) успешно привязан`, + title: mode === 'email' ? 'Почта подключена' : 'Мессенджер подключен', + message: `${mode === 'email' ? 'Ящик' : platform.toUpperCase()} (${identifier}) успешно подключен${useVpn && mode === 'messenger' ? ' через VPN' : ''}`, type: 'success', }); onClose(); }; return ( - +
setIdentifier(e.target.value)} - placeholder="bot123456789:ABCDefgh..." + placeholder={mode === 'email' ? 'name@company.ru' : '+7 900 000-00-00 или @username'} required />
-
- При подключении автоматически генерируется Webhook URL для приема сообщений в реальном времени. -
+ {mode === 'messenger' && }
+
+ {/* 1. Connected Messengers & Connectors */}