import { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X, Search } from 'lucide-react'; import { useChatStore } from '../stores/chatStore'; import { useAuthStore } from '../stores/authStore'; import { useLang } from '../lib/i18n'; import Avatar from './Avatar'; interface ForwardModalProps { onClose: () => void; onForward: (chatId: string) => void; } export default function ForwardModal({ onClose, onForward }: ForwardModalProps) { const { chats } = useChatStore(); const { user } = useAuthStore(); const { t } = useLang(); const [search, setSearch] = useState(''); const filteredChats = chats .filter((chat) => { const otherMember = chat.members.find((m) => m.userId !== user?.id); const chatName = chat.type === 'personal' ? otherMember?.user.displayName || otherMember?.user.username || t('favorites') : chat.name || t('group'); const finalName = chat.type === 'favorites' ? t('favorites') : chatName; return finalName.toLowerCase().includes(search.toLowerCase()); }) .sort((a, b) => { if (a.type === 'favorites') return -1; if (b.type === 'favorites') return 1; return 0; }); return (

{t('forwardMessage')}

setSearch(e.target.value)} className="w-full bg-black/20 border border-white/10 rounded-xl py-2.5 pl-10 pr-4 text-white placeholder-zinc-500 focus:outline-none focus:border-knot-500 transition-colors" />
{filteredChats.map((chat) => { const otherMember = chat.members.find((m) => m.userId !== user?.id); const chatName = chat.type === 'favorites' ? t('favorites') : chat.type === 'personal' ? otherMember?.user.displayName || otherMember?.user.username || t('chat') : chat.name || t('group'); const chatAvatar = chat.type === 'personal' ? otherMember?.user.avatar : chat.avatar; return ( ); })} {filteredChats.length === 0 && (

{t('nothingFound')}

)}
); }