Spaces:
Running
Running
File size: 3,375 Bytes
ce55237 d8c1c6e ce55237 d8c1c6e ce55237 d8c1c6e ce55237 d8c1c6e ce55237 81ad5a3 d8c1c6e ce55237 81ad5a3 ce55237 81ad5a3 ce55237 81ad5a3 d8c1c6e ce55237 d8c1c6e 81ad5a3 ce55237 81ad5a3 ce55237 81ad5a3 d8c1c6e ce55237 d8c1c6e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | import { BookOpen, Upload, Trash2, FileJson, Plus } from 'lucide-react'
export default function KnowledgePanel({ rules, onUpload, onRemoveRule, customRulesCount, onOpenModal }) {
return (
<div className="card flex flex-col h-full">
<div className="card-header">
<div className="flex items-center space-x-2">
<BookOpen className="w-5 h-5 text-primary-400" />
<h2 className="font-semibold text-white text-sm">Knowledge Base</h2>
</div>
<span className="text-xs bg-dark-900 text-dark-400 px-2 py-1 rounded-md border border-white/5">
{rules.length} Rules
</span>
</div>
<div className="p-4 border-b border-white/5 bg-dark-900/20">
<button
onClick={onOpenModal}
className="w-full flex items-center justify-center space-x-2 py-2.5 border border-dashed border-dark-600 rounded-xl text-dark-400 hover:text-white hover:border-primary-500 hover:bg-primary-500/5 transition-all group"
>
<Plus className="w-4 h-4 group-hover:scale-110 transition-transform" />
<span className="text-sm font-medium">Add Custom Rule</span>
</button>
{customRulesCount > 0 && (
<button
onClick={() => onRemoveRule('all')}
className="w-full mt-2 flex items-center justify-center space-x-2 text-xs text-danger/70 hover:text-danger hover:bg-danger/10 py-2 rounded-lg transition-colors"
>
<Trash2 className="w-3 h-3" />
<span>Clear All Custom Rules</span>
</button>
)}
</div>
<div className="flex-1 overflow-y-auto p-4 space-y-3">
{rules.map((rule) => (
<div key={rule.id} className="group bg-dark-900/40 border border-white/5 rounded-xl p-3 hover:border-white/10 hover:bg-dark-800/60 transition-all">
<div className="flex justify-between items-start mb-2">
<div className="flex items-center space-x-2">
{rule.isCustom && <FileJson className="w-3 h-3 text-primary-400" />}
<h3 className="text-sm font-medium text-white">{rule.rule}</h3>
</div>
<div className="flex items-center space-x-2">
<span className={`text-[10px] font-bold px-2 py-0.5 rounded-full uppercase tracking-wider ${
rule.action === 'LONG' ? 'bg-success/10 text-success' :
rule.action === 'SHORT' ? 'bg-danger/10 text-danger' :
'bg-primary-500/10 text-primary-400'
}`}>
{rule.action}
</span>
{rule.isCustom && (
<button
onClick={() => onRemoveRule(rule.id)}
className="text-dark-500 hover:text-danger transition-colors opacity-0 group-hover:opacity-100"
>
<Trash2 className="w-3 h-3" />
</button>
)}
</div>
</div>
<div className="text-xs text-dark-400 font-mono bg-dark-950/50 p-2 rounded border border-white/5 mb-2 truncate">
IF {rule.condition}
</div>
<p className="text-xs text-dark-500 leading-relaxed">
{rule.description}
</p>
</div>
))}
</div>
</div>
)
} |