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|
|
|
|
|
|
|
|
|
|
|
| 119 |
<div id="root"></div>
|
| 120 |
</body>
|
| 121 |
</html>
|
| 122 |
+
<!DOCTYPE html>
|
| 123 |
+
<html lang="en">
|
| 124 |
+
<head>
|
| 125 |
+
<meta charset="UTF-8" />
|
| 126 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 127 |
+
<title>Sovereign AI Banking Nexus</title>
|
| 128 |
+
|
| 129 |
+
<!-- TailwindCSS -->
|
| 130 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 131 |
+
|
| 132 |
+
<!-- Font Awesome -->
|
| 133 |
+
<link
|
| 134 |
+
rel="stylesheet"
|
| 135 |
+
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"/>
|
| 136 |
+
|
| 137 |
+
<!-- Plaid Link -->
|
| 138 |
+
<script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script>
|
| 139 |
+
|
| 140 |
+
<!-- Importmap for React + libraries -->
|
| 141 |
+
<script type="importmap">
|
| 142 |
+
{
|
| 143 |
+
"imports": {
|
| 144 |
+
"react": "https://aistudiocdn.com/react@^19.1.1",
|
| 145 |
+
"react-dom": "https://aistudiocdn.com/react-dom@^19.1.1/",
|
| 146 |
+
"@auth0/auth0-react": "https://aistudiocdn.com/@auth0/auth0-react@^2.2.4",
|
| 147 |
+
"recharts": "https://aistudiocdn.com/recharts@^3.2.0"
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
</script>
|
| 151 |
+
|
| 152 |
+
<style>
|
| 153 |
+
body { margin: 0; font-family: system-ui, sans-serif; background-color: #111827; color: #f9fafb; }
|
| 154 |
+
#root { display: flex; justify-content: center; align-items: flex-start; padding: 2rem; min-height: 100vh; }
|
| 155 |
+
.card { background: #1f2937; padding: 1.5rem; border-radius: 0.5rem; box-shadow: 0 2px 10px rgba(0,0,0,0.5); width: 100%; max-width: 600px; }
|
| 156 |
+
button { background-color: #3b82f6; color: white; padding: 0.5rem 1rem; border-radius: 0.375rem; cursor: pointer; border: none; margin-top: 0.5rem; }
|
| 157 |
+
button:hover { background-color: #2563eb; }
|
| 158 |
+
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
|
| 159 |
+
th, td { border: 1px solid #374151; padding: 0.5rem; text-align: left; }
|
| 160 |
+
th { background-color: #111827; }
|
| 161 |
+
</style>
|
| 162 |
+
</head>
|
| 163 |
+
<body>
|
| 164 |
+
<div id="root"></div>
|
| 165 |
+
|
| 166 |
+
<script type="module">
|
| 167 |
+
import React from 'react';
|
| 168 |
+
import ReactDOM from 'react-dom/client';
|
| 169 |
+
import { Auth0Provider, useAuth0 } from "@auth0/auth0-react";
|
| 170 |
+
import { LineChart, Line, XAxis, YAxis, Tooltip, CartesianGrid } from 'recharts';
|
| 171 |
+
|
| 172 |
+
// Failsafe fetch for transactions
|
| 173 |
+
async function fetchTransactions(token) {
|
| 174 |
+
try {
|
| 175 |
+
const res = await fetch('https://ce47fe80-dabc-4ad0-b0e7-cf285695b8b8.mock.pstmn.io/transactions', {
|
| 176 |
+
headers: { Authorization: `Bearer ${token}` }
|
| 177 |
+
});
|
| 178 |
+
if (!res.ok) throw new Error('Fetch failed');
|
| 179 |
+
return await res.json();
|
| 180 |
+
} catch (e) {
|
| 181 |
+
// fallback transactions
|
| 182 |
+
return {
|
| 183 |
+
data: [
|
| 184 |
+
{ id: 'txn_001', amount: 125.5, description: 'Fallback Coffee', status: 'posted', date: '2025-12-01' },
|
| 185 |
+
{ id: 'txn_002', amount: 2200, description: 'Fallback Payroll', status: 'pending', date: '2025-12-03' }
|
| 186 |
+
]
|
| 187 |
+
};
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
function TransactionsTable({ transactions }) {
|
| 192 |
+
return (
|
| 193 |
+
<table>
|
| 194 |
+
<thead>
|
| 195 |
+
<tr>
|
| 196 |
+
<th>ID</th>
|
| 197 |
+
<th>Description</th>
|
| 198 |
+
<th>Amount</th>
|
| 199 |
+
<th>Status</th>
|
| 200 |
+
<th>Date</th>
|
| 201 |
+
</tr>
|
| 202 |
+
</thead>
|
| 203 |
+
<tbody>
|
| 204 |
+
{transactions.map(txn => (
|
| 205 |
+
<tr key={txn.id}>
|
| 206 |
+
<td>{txn.id}</td>
|
| 207 |
+
<td>{txn.description}</td>
|
| 208 |
+
<td>${txn.amount}</td>
|
| 209 |
+
<td>{txn.status}</td>
|
| 210 |
+
<td>{txn.date || '-'}</td>
|
| 211 |
+
</tr>
|
| 212 |
+
))}
|
| 213 |
+
</tbody>
|
| 214 |
+
</table>
|
| 215 |
+
);
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
function TransactionsChart({ transactions }) {
|
| 219 |
+
const chartData = transactions.map(txn => ({ date: txn.date || txn.id, amount: txn.amount }));
|
| 220 |
+
return (
|
| 221 |
+
<LineChart width={550} height={250} data={chartData} margin={{ top: 5, right: 20, bottom: 5, left: 0 }}>
|
| 222 |
+
<XAxis dataKey="date" stroke="#f9fafb" />
|
| 223 |
+
<YAxis stroke="#f9fafb" />
|
| 224 |
+
<Tooltip />
|
| 225 |
+
<CartesianGrid stroke="#374151" strokeDasharray="5 5" />
|
| 226 |
+
<Line type="monotone" dataKey="amount" stroke="#3b82f6" />
|
| 227 |
+
</LineChart>
|
| 228 |
+
);
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
function App() {
|
| 232 |
+
const { loginWithRedirect, logout, isAuthenticated, getAccessTokenSilently } = useAuth0();
|
| 233 |
+
const [transactions, setTransactions] = React.useState([]);
|
| 234 |
+
|
| 235 |
+
React.useEffect(() => {
|
| 236 |
+
if (isAuthenticated) {
|
| 237 |
+
getAccessTokenSilently()
|
| 238 |
+
.then(token => fetchTransactions(token))
|
| 239 |
+
.then(data => setTransactions(data.data || []));
|
| 240 |
+
}
|
| 241 |
+
}, [isAuthenticated]);
|
| 242 |
+
|
| 243 |
+
return (
|
| 244 |
+
<div className="card">
|
| 245 |
+
<h1 className="text-2xl mb-4">Sovereign AI Banking Nexus</h1>
|
| 246 |
+
|
| 247 |
+
{!isAuthenticated ? (
|
| 248 |
+
<button onClick={() => loginWithRedirect()}>Login</button>
|
| 249 |
+
) : (
|
| 250 |
+
<>
|
| 251 |
+
<button onClick={() => logout({ returnTo: window.location.origin })}>Logout</button>
|
| 252 |
+
<h2 className="text-xl mt-4 mb-2">Transactions:</h2>
|
| 253 |
+
<TransactionsTable transactions={transactions} />
|
| 254 |
+
<h2 className="text-xl mt-4 mb-2">Transaction Chart:</h2>
|
| 255 |
+
<TransactionsChart transactions={transactions} />
|
| 256 |
+
<button onClick={() => alert('Plaid Link would open here')}>Connect Bank (Plaid)</button>
|
| 257 |
+
</>
|
| 258 |
+
)}
|
| 259 |
+
</div>
|
| 260 |
+
);
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
const domain = "citibankdemobusinessinc.us.auth0.com";
|
| 264 |
+
const clientId = "rsBLCcuq5MVA9Dj84NEVdDqpOFePLsjI";
|
| 265 |
+
|
| 266 |
+
ReactDOM.createRoot(document.getElementById('root')).render(
|
| 267 |
+
<Auth0Provider
|
| 268 |
+
domain={domain}
|
| 269 |
+
clientId={clientId}
|
| 270 |
+
authorizationParams={{ redirect_uri: window.location.origin }}
|
| 271 |
+
>
|
| 272 |
+
<App />
|
| 273 |
+
</Auth0Provider>
|
| 274 |
+
);
|
| 275 |
+
</script>
|
| 276 |
+
</body>
|
| 277 |
+
</html>
|