added basic table
This commit is contained in:
2
.env
Normal file
2
.env
Normal file
@@ -0,0 +1,2 @@
|
||||
REACT_APP_API_URL=http://localhost:2500
|
||||
API_URL=http://localhost:2500
|
||||
@@ -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
3
config.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"API_URL": "http://localhost:2500"
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB |
Reference in New Issue
Block a user