Compare commits
1 Commits
main
...
chore/down
| Author | SHA1 | Date | |
|---|---|---|---|
| 48ace06ebe |
@ -12,14 +12,6 @@ import { DebounceInput } from "react-debounce-input";
|
|||||||
|
|
||||||
const PageSize = 30;
|
const PageSize = 30;
|
||||||
|
|
||||||
type Transaction = {
|
|
||||||
id: number;
|
|
||||||
date: string;
|
|
||||||
description: string;
|
|
||||||
value: number;
|
|
||||||
category: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
async function loader(page = 0, category: string | undefined = "") {
|
async function loader(page = 0, category: string | undefined = "") {
|
||||||
const url = new URL("http://localhost:9000/transactions");
|
const url = new URL("http://localhost:9000/transactions");
|
||||||
url.search = new URLSearchParams({
|
url.search = new URLSearchParams({
|
||||||
@ -28,14 +20,17 @@ async function loader(page = 0, category: string | undefined = "") {
|
|||||||
...(category !== "" && { category: category }),
|
...(category !== "" && { category: category }),
|
||||||
}).toString();
|
}).toString();
|
||||||
|
|
||||||
return await fetch(url).then(async (response) => {
|
return await fetch(url).then((response) => response.json());
|
||||||
return {
|
|
||||||
transactions: (await response.json()) as Transaction[],
|
|
||||||
totalCount: response.headers.get("x-total-count"),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Transaction = {
|
||||||
|
id: number;
|
||||||
|
date: string;
|
||||||
|
description: string;
|
||||||
|
value: number;
|
||||||
|
category: string;
|
||||||
|
};
|
||||||
|
|
||||||
const columnHelper = createColumnHelper<Transaction>();
|
const columnHelper = createColumnHelper<Transaction>();
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
@ -75,11 +70,12 @@ export default function Transactions() {
|
|||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
columns,
|
columns,
|
||||||
data: data?.transactions ?? [],
|
data,
|
||||||
getCoreRowModel: getCoreRowModel(),
|
getCoreRowModel: getCoreRowModel(),
|
||||||
manualPagination: true,
|
manualPagination: true,
|
||||||
manualFiltering: true,
|
manualFiltering: true,
|
||||||
rowCount: data?.totalCount ? +data.totalCount : undefined,
|
// rowCount: , // TODO: get this from the server
|
||||||
|
pageCount: -1,
|
||||||
onPaginationChange: setPagination,
|
onPaginationChange: setPagination,
|
||||||
onColumnFiltersChange: setColumnFilters,
|
onColumnFiltersChange: setColumnFilters,
|
||||||
state: {
|
state: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user