Spaces:
Running
Running
File size: 9,219 Bytes
f96cf82 49d62f8 577bf58 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 f96cf82 49d62f8 4b12a41 577bf58 f96cf82 577bf58 f96cf82 577bf58 f96cf82 577bf58 f96cf82 577bf58 4b12a41 f96cf82 577bf58 f96cf82 577bf58 f96cf82 577bf58 f96cf82 577bf58 f96cf82 577bf58 4b12a41 f96cf82 4b12a41 | 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | import React, { useState } from 'react';
const Scanner = ({
pairs,
selectedPair,
onSelectPair,
filter,
onFilterChange,
marketStatus,
onExecuteTrade,
executingTrade
}) => {
const filteredPairs = pairs.filter(pair => {
if (filter === 'all') return true;
return pair.signal === filter;
});
return (
<div className="flex-1 flex flex-col bg-gray-900 h-full overflow-hidden">
<div className="h-16 border-b border-gray-700 flex items-center justify-between px-6 bg-gray-800/50 backdrop-blur-sm sticky top-0 z-30">
<div className="flex items-center gap-3">
<h2 className="text-xl font-semibold text-gray-100">Market Scanner</h2>
<span className="px-2 py-0.5 text-xs font-medium bg-green-500/10 text-green-400 border border-green-500/20 rounded-full animate-pulse">
{marketStatus}
</span>
</div>
<div className="flex items-center gap-4">
<div className="flex items-center gap-2 bg-gray-900 p-1.5 rounded-lg border border-gray-700">
<span className="text-sm text-gray-400 px-1">Filter:</span>
<select
value={filter}
onChange={onFilterChange}
className="bg-transparent border-none text-gray-200 text-sm focus:ring-0 cursor-pointer"
>
<option value="all">All Signals</option>
<option value="bullish">Bullish Only</option>
<option value="bearish">Bearish Only</option>
<option value="neutral">Neutral</option>
</select>
</div>
<div className="text-xs text-gray-500 hidden sm:block">
{filteredPairs.length} Assets Detected
</div>
</div>
</div>
<div className="flex-1 overflow-auto p-6">
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
{filteredPairs.map((pair) => (
<div
key={pair.id}
onClick={() => onSelectPair(pair.id)}
className={`group relative p-5 rounded-xl border transition-all duration-300 cursor-pointer hover:shadow-xl hover:-translate-y-1 ${
selectedPair === pair.id
? 'bg-gray-800 border-blue-500 shadow-lg shadow-blue-500/20'
: 'bg-gray-800 border-gray-700 hover:border-gray-600 hover:bg-gray-750'
}`}
>
{/* Card Header */}
<div className="flex items-start justify-between mb-4">
<div className="flex items-center gap-3">
<div className={`w-12 h-12 rounded-xl flex items-center justify-center font-bold text-lg ${
pair.signal === 'bullish' ? 'bg-green-500/20 text-green-400' :
pair.signal === 'bearish' ? 'bg-red-500/20 text-red-400' :
'bg-gray-700/50 text-gray-400'
}`}>
{pair.symbol}
</div>
<div>
<h3 className="font-semibold text-gray-200">{pair.name}</h3>
<p className="text-xs text-gray-500">{pair.asset_class}</p>
</div>
</div>
<div className="text-right">
<div className="text-lg font-bold text-gray-200">{pair.price}</div>
<div className={`text-xs font-medium ${
pair.change >= 0
? 'text-green-400'
: 'text-red-400'
}`}>
{pair.change >= 0 ? '+' : ''}{pair.change}%
</div>
</div>
</div>
{/* Stats Grid */}
<div className="space-y-3">
<div className="flex items-center justify-between text-sm">
<span className="text-gray-500 flex items-center gap-1">
<i className="fa-solid fa-arrow-trend-up"></i> Trend
</span>
<span className={`px-2.5 py-1 rounded text-xs font-bold ${
pair.trend === 'bullish'
? 'bg-green-500/10 text-green-400 border border-green-500/20'
: pair.trend === 'bearish'
? 'bg-red-500/10 text-red-400 border border-red-500/20'
: 'bg-gray-700/50 text-gray-400 border border-gray-600'
}`}>
{pair.trend.toUpperCase()}
</span>
</div>
<div className="flex items-center justify-between text-sm">
<span className="text-gray-500 flex items-center gap-1">
<i className="fa-solid fa-star"></i> Signal
</span>
<div className="flex items-center gap-0.5">
{[1, 2, 3, 4, 5].map((star) => (
<i
key={star}
className={`fa-solid fa-star ${
star <= pair.confidence / 20
? 'text-yellow-400 drop-shadow-sm'
: 'text-gray-700'
}`}
/>
))}
</div>
</div>
<div className="flex items-center justify-between text-sm">
<span className="text-gray-500 flex items-center gap-1">
<i className="fa-solid fa-chart-pie"></i> Phase
</span>
<span className={`px-2.5 py-1 rounded text-xs font-bold ${
pair.phase === 'accumulation'
? 'bg-blue-500/10 text-blue-400 border border-blue-500/20'
: pair.phase === 'markup'
? 'bg-green-500/10 text-green-400 border border-green-500/20'
: pair.phase === 'distribution'
? 'bg-purple-500/10 text-purple-400 border border-purple-500/20'
: pair.phase === 'depreciation'
? 'bg-red-500/10 text-red-400 border border-red-500/20'
: 'bg-gray-700/50 text-gray-400 border border-gray-600'
}`}>
{pair.phase.toUpperCase()}
</span>
</div>
<div className="pt-3 border-t border-gray-700/50">
<div className="flex items-center justify-between">
<span className="text-xs text-gray-500 flex items-center gap-1">
<i className="fa-solid fa-robot"></i> AI Prediction
</span>
<div className={`flex items-center gap-2 px-3 py-1 rounded-lg font-bold text-sm ${
pair.signal === 'bullish'
? 'bg-green-500/20 text-green-400 border border-green-500/30'
: pair.signal === 'bearish'
? 'bg-red-500/20 text-red-400 border border-red-500/30'
: 'bg-gray-700/50 text-gray-400 border border-gray-600'
}`}>
<i className={`fa-solid ${pair.signal === 'bullish' ? 'fa-arrow-up' : pair.signal === 'bearish' ? 'fa-arrow-down' : 'fa-minus'}`}></i>
{pair.signal.toUpperCase()}
</div>
</div>
</div>
</div>
<div className="mt-5 flex items-center justify-between pt-3 border-t border-gray-700">
<span className="text-[10px] text-gray-600">Updated: {pair.lastUpdate}</span>
<button
onClick={(e) => {
e.stopPropagation();
onExecuteTrade(pair.id);
disabled={executingTrade}
className={`px-4 py-2 text-xs font-bold rounded-lg transition-all shadow-lg ${
executingTrade
? 'bg-gray-600 text-gray-300 cursor-wait'
: pair.signal === 'bullish'
? 'bg-gradient-to-r from-green-600 to-green-700 hover:from-green-700 hover:to-green-800 text-white shadow-green-900/30'
: pair.signal === 'bearish'
? 'bg-gradient-to-r from-red-600 to-red-700 hover:from-red-700 hover:to-red-800 text-white shadow-red-900/30'
: 'bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 text-white shadow-blue-900/30'
}`}
>
{executingTrade ? 'Analyzing...' : `Trade ${pair.signal.toUpperCase()}`}
</button>
</div>
</div>
))}
</div>
{filteredPairs.length === 0 && (
<div className="flex flex-col items-center justify-center h-full text-gray-500">
<i className="fa-solid fa-magnifying-glass text-6xl mb-4 opacity-10"></i>
<p className="text-lg">No assets found matching your criteria</p>
</div>
)}
</div>
</div>
);
};
export default Scanner; |