'use client' import { useState } from 'react' import { DndContext, closestCenter, type DragEndEvent } from '@dnd-kit/core' import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable' import KeywordRow from './KeywordRow' import { useKeywords, useAddKeyword, useReorderKeywords } from '@/hooks/useKeywords' export default function KeywordsTable() { const { data: keywords, isLoading } = useKeywords() const addKw = useAddKeyword() const reorder = useReorderKeywords() const [newTerm, setNewTerm] = useState('') const [newWeight, setNewWeight] = useState('1') const [batchText, setBatchText] = useState('') const [showBatch, setShowBatch] = useState(false) const handleDragEnd = ({ active, over }: DragEndEvent) => { if (!over || active.id === over.id || !keywords) return const ids = keywords.map((k) => k.id) const from = ids.indexOf(Number(active.id)) const to = ids.indexOf(Number(over.id)) const newOrder = [...ids] newOrder.splice(to, 0, newOrder.splice(from, 1)[0]) reorder.mutate(newOrder) } const handleBatchImport = () => { const lines = batchText.split('\n').map((l) => l.trim()).filter(Boolean) lines.forEach((line) => { const [term, weight] = line.split(':') addKw.mutate({ term: term.trim(), weight: parseFloat(weight || '1') }) }) setBatchText('') setShowBatch(false) } if (isLoading) return (
{Array.from({ length: 4 }).map((_, i) => (
))}
) return (
{/* Add new */}

Each target is a search label sent to auction sites. Set an AI Description on each target to filter lot titles semantically.

setNewTerm(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && newTerm.trim() && (addKw.mutate({ term: newTerm, weight: parseFloat(newWeight) }), setNewTerm(''), setNewWeight('1'))} placeholder="Search term…" className="g-input h-9 flex-1 min-w-44 text-sm" /> setNewWeight(e.target.value)} type="number" step="0.1" placeholder="Weight" className="g-input h-9 w-24 text-sm font-mono" />
{showBatch && (

One target per line. Format: laptop:2