|
| 1 | +import { useSearchParams, Link } from 'react-router'; |
| 2 | +import { ArrowLeft } from 'lucide-react'; |
| 3 | + |
| 4 | +interface KeyStats { |
| 5 | + id: string; |
| 6 | + name: string; |
| 7 | + price: string; |
| 8 | + volume: string; |
| 9 | + holders: string; |
| 10 | + supply: string; |
| 11 | + change24h: string; |
| 12 | +} |
| 13 | + |
| 14 | +const DEMO_KEYS: KeyStats[] = [ |
| 15 | + { |
| 16 | + id: '1', |
| 17 | + name: 'Creator Alpha', |
| 18 | + price: '1.25 XLM', |
| 19 | + volume: '5,000 XLM', |
| 20 | + holders: '150', |
| 21 | + supply: '10,000', |
| 22 | + change24h: '+5.2%', |
| 23 | + }, |
| 24 | + { |
| 25 | + id: '2', |
| 26 | + name: 'Creator Beta', |
| 27 | + price: '0.85 XLM', |
| 28 | + volume: '3,200 XLM', |
| 29 | + holders: '89', |
| 30 | + supply: '8,000', |
| 31 | + change24h: '-2.1%', |
| 32 | + }, |
| 33 | + { |
| 34 | + id: '3', |
| 35 | + name: 'Creator Gamma', |
| 36 | + price: '2.10 XLM', |
| 37 | + volume: '8,500 XLM', |
| 38 | + holders: '312', |
| 39 | + supply: '15,000', |
| 40 | + change24h: '+12.8%', |
| 41 | + }, |
| 42 | +]; |
| 43 | + |
| 44 | +export default function ComparePage() { |
| 45 | + const [searchParams] = useSearchParams(); |
| 46 | + const keyIds = searchParams.get('keys')?.split(',') ?? []; |
| 47 | + |
| 48 | + const keysToShow = keyIds |
| 49 | + .map(id => DEMO_KEYS.find(k => k.id === id)) |
| 50 | + .filter((k): k is KeyStats => k != null); |
| 51 | + |
| 52 | + if (keysToShow.length === 0) { |
| 53 | + return ( |
| 54 | + <div className="min-h-screen bg-black text-white"> |
| 55 | + <div className="mx-auto max-w-5xl px-6 py-12"> |
| 56 | + <Link |
| 57 | + to="/" |
| 58 | + className="mb-8 inline-flex items-center gap-2 text-sm text-white/60 hover:text-white/90" |
| 59 | + > |
| 60 | + <ArrowLeft className="size-4" /> |
| 61 | + Back to Marketplace |
| 62 | + </Link> |
| 63 | + <h1 className="font-grotesque text-3xl font-black">Compare Keys</h1> |
| 64 | + <p className="mt-4 text-white/60"> |
| 65 | + No keys selected for comparison. Go back to the marketplace and add |
| 66 | + keys to compare. |
| 67 | + </p> |
| 68 | + </div> |
| 69 | + </div> |
| 70 | + ); |
| 71 | + } |
| 72 | + |
| 73 | + return ( |
| 74 | + <div className="min-h-screen bg-black text-white"> |
| 75 | + <div className="mx-auto max-w-5xl px-6 py-12"> |
| 76 | + <Link |
| 77 | + to="/" |
| 78 | + className="mb-8 inline-flex items-center gap-2 text-sm text-white/60 hover:text-white/90" |
| 79 | + > |
| 80 | + <ArrowLeft className="size-4" /> |
| 81 | + Back to Marketplace |
| 82 | + </Link> |
| 83 | + <h1 className="font-grotesque text-3xl font-black">Compare Keys</h1> |
| 84 | + <p className="mt-2 text-white/60"> |
| 85 | + Comparing {keysToShow.length} creator {keysToShow.length === 1 ? 'key' : 'keys'} |
| 86 | + </p> |
| 87 | + |
| 88 | + <div className="mt-8 overflow-x-auto"> |
| 89 | + <table className="w-full border-collapse"> |
| 90 | + <thead> |
| 91 | + <tr> |
| 92 | + <th className="border-b border-white/10 py-4 pr-8 text-left text-sm font-medium text-white/50"> |
| 93 | + Stat |
| 94 | + </th> |
| 95 | + {keysToShow.map(key => ( |
| 96 | + <th |
| 97 | + key={key.id} |
| 98 | + className="border-b border-white/10 py-4 px-4 text-left text-sm font-medium text-white" |
| 99 | + > |
| 100 | + {key.name} |
| 101 | + </th> |
| 102 | + ))} |
| 103 | + </tr> |
| 104 | + </thead> |
| 105 | + <tbody> |
| 106 | + <tr className="border-b border-white/5"> |
| 107 | + <td className="py-4 pr-8 text-sm text-white/50">Price</td> |
| 108 | + {keysToShow.map(key => ( |
| 109 | + <td key={key.id} className="py-4 px-4 text-sm font-medium"> |
| 110 | + {key.price} |
| 111 | + </td> |
| 112 | + ))} |
| 113 | + </tr> |
| 114 | + <tr className="border-b border-white/5"> |
| 115 | + <td className="py-4 pr-8 text-sm text-white/50">Volume</td> |
| 116 | + {keysToShow.map(key => ( |
| 117 | + <td key={key.id} className="py-4 px-4 text-sm"> |
| 118 | + {key.volume} |
| 119 | + </td> |
| 120 | + ))} |
| 121 | + </tr> |
| 122 | + <tr className="border-b border-white/5"> |
| 123 | + <td className="py-4 pr-8 text-sm text-white/50">Holders</td> |
| 124 | + {keysToShow.map(key => ( |
| 125 | + <td key={key.id} className="py-4 px-4 text-sm"> |
| 126 | + {key.holders} |
| 127 | + </td> |
| 128 | + ))} |
| 129 | + </tr> |
| 130 | + <tr className="border-b border-white/5"> |
| 131 | + <td className="py-4 pr-8 text-sm text-white/50">Supply</td> |
| 132 | + {keysToShow.map(key => ( |
| 133 | + <td key={key.id} className="py-4 px-4 text-sm"> |
| 134 | + {key.supply} |
| 135 | + </td> |
| 136 | + ))} |
| 137 | + </tr> |
| 138 | + <tr> |
| 139 | + <td className="py-4 pr-8 text-sm text-white/50">24h Change</td> |
| 140 | + {keysToShow.map(key => ( |
| 141 | + <td |
| 142 | + key={key.id} |
| 143 | + className={`py-4 px-4 text-sm font-medium ${ |
| 144 | + key.change24h.startsWith('+') |
| 145 | + ? 'text-emerald-400' |
| 146 | + : key.change24h.startsWith('-') |
| 147 | + ? 'text-red-400' |
| 148 | + : '' |
| 149 | + }`} |
| 150 | + > |
| 151 | + {key.change24h} |
| 152 | + </td> |
| 153 | + ))} |
| 154 | + </tr> |
| 155 | + </tbody> |
| 156 | + </table> |
| 157 | + </div> |
| 158 | + </div> |
| 159 | + </div> |
| 160 | + ); |
| 161 | +} |
0 commit comments