Spaces:
Sleeping
Sleeping
File size: 10,010 Bytes
b8b3edf | 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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
import React, { useState } from 'react';
import {
ShieldCheck,
Search,
Building2,
Globe,
AlertCircle,
CheckCircle2,
Loader2,
Terminal,
ArrowRight,
Info,
Key,
MapPin,
ShieldAlert,
Zap
} from 'lucide-react';
const Validations: React.FC = () => {
const [routingNumber, setRoutingNumber] = useState('');
const [basicToken, setBasicToken] = useState('');
const [loading, setLoading] = useState(false);
const [result, setResult] = useState<any>(null);
const [error, setError] = useState<string | null>(null);
const handleValidate = async (e: React.FormEvent) => {
e.preventDefault();
if (!routingNumber || !basicToken) {
setError("Routing number and Basic Token are required.");
return;
}
setLoading(true);
setError(null);
setResult(null);
try {
const response = await fetch(`https://try.readme.io/https://app.moderntreasury.com/api/validations/routing_numbers?routing_number=${routingNumber}&routing_number_type=aba`, {
method: "GET",
headers: {
"accept": "application/json",
"accept-language": "en-US,en;q=0.9",
"authorization": `Basic ${basicToken}`,
"cache-control": "no-cache",
"pragma": "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "cross-site",
"x-readme-api-explorer": "5.590.0"
},
mode: "cors",
credentials: "include"
});
if (!response.ok) {
const errData = await response.json().catch(() => ({}));
throw new Error(errData?.errors?.[0]?.message || `HTTP ${response.status}: API Handshake Failed`);
}
const data = await response.json();
setResult(data);
} catch (err: any) {
setError(err.message || "Network Error: Failed to synchronize with validation node.");
} finally {
setLoading(false);
}
};
return (
<div className="max-w-5xl mx-auto space-y-10 animate-in slide-in-from-bottom-6 duration-700">
<div className="text-center space-y-4">
<div className="w-20 h-20 bg-blue-600/10 text-blue-500 rounded-3xl flex items-center justify-center mx-auto shadow-2xl">
<ShieldCheck size={40} />
</div>
<h2 className="text-4xl font-black text-white italic tracking-tighter uppercase">Registry <span className="text-blue-500 not-italic">Validator</span></h2>
<p className="text-zinc-500 text-sm max-w-md mx-auto font-medium">Modern Treasury Bridge: Live Routing Integrity Screening</p>
</div>
<div className="bg-zinc-950 border border-zinc-900 rounded-[3rem] p-12 shadow-2xl relative overflow-hidden group">
<div className="absolute top-0 right-0 p-10 opacity-5 group-hover:opacity-10 transition-opacity">
<Terminal size={140} />
</div>
<form onSubmit={handleValidate} className="relative z-10 space-y-6">
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="space-y-2">
<label className="text-[10px] font-black text-zinc-600 uppercase tracking-widest ml-1">ABA Routing Number</label>
<div className="relative">
<Search className="absolute left-6 top-1/2 -translate-y-1/2 text-zinc-600" size={18} />
<input
value={routingNumber}
onChange={e => setRoutingNumber(e.target.value)}
placeholder="e.g. 021000021"
className="w-full bg-black border-2 border-zinc-900 focus:border-blue-500/50 rounded-2xl py-5 pl-16 pr-6 text-white text-sm outline-none transition-all placeholder:text-zinc-800 font-bold"
/>
</div>
</div>
<div className="space-y-2">
<label className="text-[10px] font-black text-zinc-600 uppercase tracking-widest ml-1">Basic Auth Token</label>
<div className="relative">
<Key className="absolute left-6 top-1/2 -translate-y-1/2 text-zinc-600" size={18} />
<input
type="password"
value={basicToken}
onChange={e => setBasicToken(e.target.value)}
placeholder="Basic {token}"
className="w-full bg-black border-2 border-zinc-900 focus:border-blue-500/50 rounded-2xl py-5 pl-16 pr-6 text-white text-sm outline-none transition-all placeholder:text-zinc-800 font-mono"
/>
</div>
</div>
</div>
<button
disabled={loading || !routingNumber || !basicToken}
className="w-full py-6 bg-blue-600 hover:bg-blue-500 disabled:bg-zinc-900 disabled:text-zinc-700 text-white rounded-2xl font-black text-xs uppercase tracking-[0.3em] transition-all flex items-center justify-center gap-3 shadow-xl shadow-blue-900/30"
>
{loading ? <Loader2 className="animate-spin" size={20} /> : <Zap size={20} />}
<span>{loading ? 'Performing Handshake...' : 'Synchronize Validator'}</span>
</button>
</form>
</div>
{error && (
<div className="p-8 bg-rose-600/10 border border-rose-500/20 rounded-[2rem] flex items-center gap-6 animate-in zoom-in-95">
<ShieldAlert className="text-rose-500 shrink-0" size={32} />
<div>
<h4 className="text-rose-500 font-black uppercase text-xs tracking-widest mb-1">Handshake Interrupted</h4>
<p className="text-zinc-400 text-sm font-medium">{error}</p>
</div>
</div>
)}
{result && (
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8 animate-in slide-in-from-top-6 duration-700">
<div className="lg:col-span-1 bg-zinc-950 border border-zinc-900 rounded-[3rem] p-10 space-y-8 shadow-2xl relative overflow-hidden">
<div className="absolute top-0 right-0 p-8 opacity-5">
<Building2 size={80} />
</div>
<div className="flex items-center gap-4">
<div className="w-12 h-12 bg-emerald-500/10 text-emerald-500 rounded-2xl flex items-center justify-center">
<CheckCircle2 size={24} />
</div>
<div>
<h3 className="text-white font-black text-lg uppercase italic tracking-tighter">Verified Node</h3>
<p className="text-[10px] text-zinc-500 font-black uppercase tracking-widest">{result.routing_number}</p>
</div>
</div>
<div className="space-y-6">
<div className="p-6 bg-black rounded-2xl border border-zinc-900">
<p className="text-[10px] font-black text-zinc-600 uppercase tracking-widest mb-2">Legal Entity</p>
<p className="text-white font-bold text-sm uppercase leading-relaxed">{result.bank_name}</p>
</div>
<div className="p-6 bg-black rounded-2xl border border-zinc-900">
<p className="text-[10px] font-black text-zinc-600 uppercase tracking-widest mb-2">Node Type</p>
<p className="text-blue-500 font-black uppercase text-sm mono">{result.routing_number_type}</p>
</div>
</div>
</div>
<div className="lg:col-span-2 bg-zinc-950 border border-zinc-900 rounded-[3rem] p-10 space-y-8 shadow-2xl relative overflow-hidden group">
<div className="absolute top-0 right-0 p-10 opacity-5 group-hover:scale-110 transition-transform duration-1000">
<MapPin size={120} className="text-blue-500" />
</div>
<div className="flex items-center gap-4">
<div className="p-3 bg-blue-600/10 text-blue-500 rounded-xl">
<Globe size={24} />
</div>
<h3 className="text-white font-black text-lg uppercase italic tracking-tighter">Geospatial Metadata</h3>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
<div className="space-y-6">
<div className="p-6 bg-black rounded-2xl border border-zinc-900">
<p className="text-[10px] font-black text-zinc-600 uppercase tracking-widest mb-3">Host Address</p>
<p className="text-zinc-200 text-sm font-medium leading-relaxed">
{result.bank_address?.line1}<br />
{result.bank_address?.locality}, {result.bank_address?.region} {result.bank_address?.postal_code}<br />
{result.bank_address?.country}
</p>
</div>
</div>
<div className="space-y-6">
<div className="p-6 bg-black rounded-2xl border border-zinc-900">
<p className="text-[10px] font-black text-zinc-600 uppercase tracking-widest mb-3">Supported Protocols</p>
<div className="flex flex-wrap gap-2">
{result.supported_payment_types?.map((t: string) => (
<span key={t} className="px-3 py-1 bg-blue-500/10 border border-blue-500/20 rounded-full text-[9px] font-black uppercase text-blue-500">
{t} Optimized
</span>
))}
</div>
</div>
<div className="p-6 bg-black rounded-2xl border border-zinc-900">
<p className="text-[10px] font-black text-zinc-600 uppercase tracking-widest mb-2">Sanctions Status</p>
<div className="flex items-center gap-2">
<CheckCircle2 size={12} className="text-emerald-500" />
<span className="text-emerald-500 font-black uppercase text-[10px]">Zero Deviations</span>
</div>
</div>
</div>
</div>
</div>
</div>
)}
</div>
);
};
export default Validations;
|