Spaces:
Running
Running
Upload components/JsonUploadModal.js with huggingface_hub
Browse files12 unmodified lines1314151617181959 unmodified lines7980818283848586878889909192939495969798991001011021031041051061071082 unmodified lines1111121131141151161176 unmodified lines12412512612712812913013113213313413513613713813914014114214314412 unmodified linesreturn { valid: false, error: 'JSON must be an array of rules' }}// Validate each rule has required fieldsfor (let i = 0; i < parsed.length; i++) {const rule = parsed[i]if (!rule.rule || !rule.condition || !rule.action) {59 unmodified linesif (!isOpen) return nullreturn (<div className="fixed inset-0 bg-black/70 backdrop-blur-sm z-50 flex items-center justify-center p-4"><div className="card w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col"><div className="p-4 border-b border-dark-700 flex items-center justify-between"><div className="flex items-center space-x-2"><FileJson className="w-5 h-5 text-primary-400" /><h2 className="text-lg font-semibold text-white">Add JSON Rules</h2></div><buttononClick={onClose}className="text-dark-400 hover:text-white transition-colors"><X className="w-5 h-5" /></button></div><div className="flex-1 overflow-y-auto p-4 space-y-4"><div className="bg-dark-900/50 border border-dark-700 rounded-lg p-4"><h3 className="text-sm font-medium text-white mb-2">JSON Format</h3><p className="text-xs text-dark-400 mb-3">Paste your JSON array of trading rules. Each rule must include: rule, condition, action, confidence, and description.</p><buttononClick={loadExample}className="text-xs text-primary-400 hover:text-primary-300 transition-colors">Load Example →</button>2 unmodified lines<textareavalue={jsonText}onChange={(e) => setJsonText(e.target.value)}className="w-full h-64 bg-dark-900 border border-dark-700 rounded-lg text-white font-mono text-xs p-4 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent resize-none"placeholder='[{"rule": "Your Rule Name",6 unmodified lines/>{error && (<div className="flex items-center space-x-2 text-danger bg-danger/10 border border-danger/30 rounded-lg p-3"><AlertCircle className="w-4 h-4 flex-shrink-0" /><span className="text-sm">{error}</span></div>)}{success && (<div className="flex items-center space-x-2 text-success bg-success/10 border border-success/30 rounded-lg p-3"><CheckCircle className="w-4 h-4 flex-shrink-0" /><span className="text-sm">Rules added successfully!</span></div>)}</div><div className="p-4 border-t border-dark-700 flex justify-end space-x-3"><buttononClick={onClose}className="btn-secondary"12 unmodified lines13141516171859 unmodified lines787980818283848586878889909192939495969798991001011021031041051061072 unmodified lines1101111121131141151166 unmodified lines12312412512612712812913013113213313413513613713813914014114214312 unmodified linesreturn { valid: false, error: 'JSON must be an array of rules' }}for (let i = 0; i < parsed.length; i++) {const rule = parsed[i]if (!rule.rule || !rule.condition || !rule.action) {59 unmodified linesif (!isOpen) return nullreturn (<div className="fixed inset-0 bg-black/80 backdrop-blur-sm z-50 flex items-center justify-center p-4"><div className="card w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col animate-in fade-in zoom-in duration-200"><div className="p-6 border-b border-white/5 flex items-center justify-between bg-dark-900/50"><div className="flex items-center space-x-2"><FileJson className="w-5 h-5 text-primary-400" /><h2 className="text-lg font-semibold text-white">Add Custom Rules</h2></div><buttononClick={onClose}className="text-dark-400 hover:text-white transition-colors p-2 hover:bg-white/5 rounded-lg"><X className="w-5 h-5" /></button></div><div className="flex-1 overflow-y-auto p-6 space-y-4"><div className="bg-dark-900/50 border border-white/5 rounded-xl p-4"><h3 className="text-sm font-medium text-white mb-2">JSON Format</h3><p className="text-xs text-dark-400 mb-3">Paste your JSON array of trading rules. Each rule must include: rule, condition, action, confidence, and description.</p><buttononClick={loadExample}className="text-xs text-primary-400 hover:text-primary-300 transition-colors font-medium">Load Example →</button>2 unmodified lines<textareavalue={jsonText}onChange={(e) => setJsonText(e.target.value)}className="w-full h-64 bg-dark-900 border border-white/10 rounded-xl text-white font-mono text-xs p-4 focus:outline-none focus:ring-2 focus:ring-primary-500/50 focus:border-transparent resize-none"placeholder='[{"rule": "Your Rule Name",6 unmodified lines/>{error && (<div className="flex items-center space-x-2 text-danger bg-danger/10 border border-danger/20 rounded-lg p-3"><AlertCircle className="w-4 h-4 flex-shrink-0" /><span className="text-sm">{error}</span></div>)}{success && (<div className="flex items-center space-x-2 text-success bg-success/10 border border-success/20 rounded-lg p-3"><CheckCircle className="w-4 h-4 flex-shrink-0" /><span className="text-sm">Rules added successfully!</span></div>)}</div><div className="p-6 border-t border-white/5 bg-dark-900/50 flex justify-end space-x-3"><buttononClick={onClose}className="btn-secondary"
components/JsonUploadModal.js+12-13