import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { useContentPolicy } from '@/providers/ContentPolicyProvider' import { Plus, X } from 'lucide-react' import { useState } from 'react' import { useTranslation } from 'react-i18next' import SettingItem from './SettingItem' export default function MutedWords() { const { t } = useTranslation() const { mutedWords, setMutedWords } = useContentPolicy() const [newMutedWord, setNewMutedWord] = useState('') const handleAddMutedWord = () => { const word = newMutedWord.trim().toLowerCase() if (word && !mutedWords.includes(word)) { setMutedWords([...mutedWords, word]) setNewMutedWord('') } } const handleRemoveMutedWord = (word: string) => { setMutedWords(mutedWords.filter((w) => w !== word)) } const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { e.preventDefault() handleAddMutedWord() } } return (
setNewMutedWord(e.target.value)} onKeyDown={handleKeyDown} className="flex-1" />
{mutedWords.length > 0 && (
{mutedWords.map((word) => (
{word}
))}
)}
) }