/** * SettingsPanel — extracted from AIChatPanel.renderSettingsPanel() * Settings panel with three tabs: AI, People, Widget. */ import React from 'react'; import { Bot, User, Users, Loader2, Save, Trash2, Settings, Inbox, AlertCircle, } from 'lucide-react'; import { cn } from '@/shared/utils/cn'; import { ContextSettingsSection } from '../components/AIChatPanel/components/ChatPanels/ContextSettingsSection'; import type { ContextSettings } from '../components/AIChatPanel/types'; import type { AIAgent, ChatMessage } from '../types'; type PanelTab = 'none' | 'contacts' | 'ai-agents' | 'tasks' | 'settings' | 'inbox'; type SettingsTab = 'ai' | 'people' | 'widget'; type VoiceMode = 'webSpeech' | 'whisper'; interface ChatPartner { type: string; id: number; name: string; avatarUrl?: string; email?: string; icon?: string | null; participants?: Array<{ id: number; name: string; type: 'user' | 'agent' }>; } interface TasksSourceConfig { tableId: number; tableName: string; tableIcon?: string; displayColumn?: string; descriptionColumn?: string; statusColumn?: string; priorityColumn?: string; statusDictTableId?: number; priorityDictTableId?: number; } interface FilesSourceConfig { tableId: number; tableName: string; tableIcon?: string; projectId?: number; } interface InboxConversation { id: number; title: string | null; type: string; unread_count: number; updated_at: string; participants: Array<{ user_id: number; name: string }>; } interface TableColumn { column_name: string; display_name?: string; config?: string; } interface TasksSourceInlineSelectorProps { defaultSpaceId: number | null; onSelect: (config: TasksSourceConfig) => void; onCancel: () => void; showHeader?: boolean; } interface FilesSourceInlineSelectorProps { defaultSpaceId: number | null; onSelect: (config: FilesSourceConfig) => void; onCancel: () => void; showHeader?: boolean; } export interface SettingsPanelProps { settingsTab: SettingsTab; setSettingsTab: (tab: SettingsTab) => void; // AI tab currentAgent: AIAgent | null; agents: AIAgent[]; handleAgentSelect: (agent: AIAgent) => void; chatOperatorId: number | null; setChatOperatorId: (id: number | null) => void; chatModelId: string; setChatModelId: (id: string) => void; chatSystemPrompt: string; setChatSystemPrompt: (prompt: string) => void; operators: Array<{ id: number; name: string }>; models: Array<{ id: number; name: string; model_id?: string }>; isAdminOrOwner: boolean; saveAgentSettings: () => void; isSavingAgentSettings: boolean; messages: ChatMessage[]; clearMessages: () => void; contextSettings: ContextSettings; handleContextSettingsChange: (settings: ContextSettings) => void; saveContextSettings: () => void; isSavingContextSettings: boolean; // People tab chatPartner: ChatPartner | null; totalUnreadCount: number; inboxConversations: InboxConversation[]; setChatMode: (mode: 'ai' | 'people') => void; setActivePanel: (panel: PanelTab) => void; refetchInbox: () => void; // Widget tab tasksSource: TasksSourceConfig | undefined; updateTasksSource: (config: TasksSourceConfig | undefined) => void; tasksTableColumns: TableColumn[]; filesSource: FilesSourceConfig | undefined; updateFilesSource: (config: FilesSourceConfig | undefined) => void; effectiveSpaceId: number | null; defaultAgentId: number | null; saveDefaultAgent: (agentId: number | null) => void; isSavingDefaultAgent: boolean; quickEmojis: string[]; setQuickEmojis: React.Dispatch>; saveQuickEmojis: (emojis: string[]) => void; isSavingEmojis: boolean; DEFAULT_QUICK_EMOJIS: string[]; voiceMode: VoiceMode; setVoiceMode: (mode: VoiceMode) => void; webSpeechAvailable: boolean; voiceError: string | null; TasksSourceInlineSelector: React.ComponentType; FilesSourceInlineSelector: React.ComponentType; } export function SettingsPanel({ settingsTab, setSettingsTab, // AI tab currentAgent, agents, handleAgentSelect, chatOperatorId, setChatOperatorId, chatModelId, setChatModelId, chatSystemPrompt, setChatSystemPrompt, operators, models, isAdminOrOwner, saveAgentSettings, isSavingAgentSettings, messages, clearMessages, contextSettings, handleContextSettingsChange, saveContextSettings, isSavingContextSettings, // People tab chatPartner, totalUnreadCount, inboxConversations, setChatMode, setActivePanel, refetchInbox, // Widget tab tasksSource, updateTasksSource, tasksTableColumns, filesSource, updateFilesSource, effectiveSpaceId, defaultAgentId, saveDefaultAgent, isSavingDefaultAgent, quickEmojis, setQuickEmojis, saveQuickEmojis, isSavingEmojis, DEFAULT_QUICK_EMOJIS, voiceMode, setVoiceMode, webSpeechAvailable, voiceError, TasksSourceInlineSelector, FilesSourceInlineSelector, }: SettingsPanelProps) { return (
{/* Settings Tabs: AI | People | Widget */}
{/* AI Settings Tab */} {settingsTab === 'ai' && (
{currentAgent?.icon || '🤖'}
AI Агент
{currentAgent && ( <>