added basic table

This commit is contained in:
2025-04-03 14:49:31 +02:00
parent a7d33e7f68
commit 35e289b830
4 changed files with 50 additions and 1 deletions

2
.env Normal file
View File

@@ -0,0 +1,2 @@
REACT_APP_API_URL=http://localhost:2500
API_URL=http://localhost:2500

View File

@@ -1,9 +1,53 @@
import type { Route } from "./+types/home";
import { useEffect, useState } from "react";
import "../../config.json";
const API_URL = process.env.API_URL;
type transaction = { id: number; tier: number; type: string; cost: number };
export function meta({}: Route.MetaArgs) {
return [{ title: "Albion Online Transaction Tracker" }];
}
export default function Home() {
return <></>;
return (
<>
<TransactionTable />
</>
);
}
function TransactionTable() {
const [transactions, setTransactions] = useState<transaction[]>([]);
useEffect(() => {
fetch(`${API_URL}/transactions`)
.then((response) => response.json())
.then((data) => {console.log(data); setTransactions(data);});
}, [API_URL]);
return (
<>
<table>
<thead>
<tr>
<th>Timestamp</th>
<th>Tier</th>
<th>Type</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
{transactions.map((transaction) => (
<tr key={transaction.id}>
<td></td>
<td>{transaction.tier}</td>
<td>{transaction.type}</td>
<td>{transaction.cost}</td>
</tr>
))}
</tbody>
</table>
</>
);
}

3
config.json Normal file
View File

@@ -0,0 +1,3 @@
{
"API_URL": "http://localhost:2500"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB