"use client" import { useState } from "react" import { Button } from "@/components/ui/button" import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { Input } from "@/components/ui/input" import { Search, Plus, Trash2 } from "lucide-react" import type { ContentLibrary } from "@/types/group-sync" // 模拟数据 const mockContentLibraries: ContentLibrary[] = [ { id: "1", name: "测试11", targets: [{ id: "t1", avatar: "/placeholder.svg?height=40&width=40" }], }, { id: "2", name: "测试166666", targets: [ { id: "t2", avatar: "/placeholder.svg?height=40&width=40" }, { id: "t3", avatar: "/placeholder.svg?height=40&width=40" }, { id: "t4", avatar: "/placeholder.svg?height=40&width=40" }, ], }, { id: "3", name: "产品介绍", targets: [ { id: "t5", avatar: "/placeholder.svg?height=40&width=40" }, { id: "t6", avatar: "/placeholder.svg?height=40&width=40" }, ], }, ] interface ContentSelectorProps { selectedLibraries: ContentLibrary[] onLibrariesChange: (libraries: ContentLibrary[]) => void onPrevious: () => void onNext: () => void onSave: () => void onCancel: () => void } export function ContentSelector({ selectedLibraries = [], onLibrariesChange, onPrevious, onNext, onSave, onCancel, }: ContentSelectorProps) { const [isDialogOpen, setIsDialogOpen] = useState(false) const [searchTerm, setSearchTerm] = useState("") const handleAddLibrary = (library: ContentLibrary) => { if (!selectedLibraries.some((l) => l.id === library.id)) { onLibrariesChange([...selectedLibraries, library]) } setIsDialogOpen(false) } const handleRemoveLibrary = (libraryId: string) => { onLibrariesChange(selectedLibraries.filter((library) => library.id !== libraryId)) } const filteredLibraries = mockContentLibraries.filter((library) => library.name.toLowerCase().includes(searchTerm.toLowerCase()), ) return (
* 选择内容库:
{selectedLibraries.length > 0 ? ( 序号 内容库名称 采集对象 操作 {selectedLibraries.map((library, index) => ( {index + 1} {library.name}
{library.targets.map((target) => (
Target
))}
))}
) : (
请点击"选择内容库"按钮添加内容库
)}
选择内容库
setSearchTerm(e.target.value)} />
序号 内容库名称 采集对象 操作 {filteredLibraries.map((library, index) => ( {index + 1} {library.name}
{library.targets.map((target) => (
Target
))}
))}
) }