import { useState, type FormEvent } from 'react';
import { Hash, Lock, Users, Pin, Send, Plus } from 'lucide-react';
import { useCommunicationsStore } from '../services/communicationsService';
import { Button } from '@omnichannel/ui';
interface ChannelsViewProps {
onCreateChannelModal: () => void;
}
export function ChannelsView({ onCreateChannelModal }: ChannelsViewProps) {
const {
channels,
activeChannelId,
sendChannelMessage,
toggleChannelReaction,
} = useCommunicationsStore();
const [currentChannelId, setCurrentChannelId] = useState(activeChannelId);
const [inputText, setInputText] = useState('');
const [showMembers, setShowMembers] = useState(false);
const activeChannel = channels.find((c) => c.id === currentChannelId) || channels[0];
const handleSend = (e: FormEvent) => {
e.preventDefault();
if (!inputText.trim()) return;
sendChannelMessage(activeChannel.id, inputText);
setInputText('');
};
return (
{/* Channels directory list */}
{/* Main channel conversation area */}
{/* Channel Header */}
{activeChannel.isPrivate ? : }
{activeChannel.name}
{activeChannel.isPrivate && (
Закрытый
)}
{activeChannel.topic}
{/* Pinned announcement banner */}
{activeChannel.pinnedMessage && (
Закреплено:
{activeChannel.pinnedMessage}
)}
{/* Message feed */}
{activeChannel.messages.map((msg) => (
{msg.senderName[0]}
{msg.senderName}
{msg.timestamp}
{msg.text}
{/* Reactions */}
{msg.reactions &&
Object.entries(msg.reactions).map(([emoji, count]) => (
))}
))}
{/* Input bar */}
{/* Members drawer/sidebar */}
{showMembers && (
)}
);
}