Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nil-amrutlal committed Oct 19, 2023
1 parent c94594f commit f9ebfca
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,8 @@ export const ExtendedTransactionsTable = (

const [currentPage, setCurrentPage] = useState<number>(1);

useEffect(() => {
refetchTransactions();
setCurrentPage(1);
}, [itemsPerPage]);

// Set items per page and page in URL when they change
useEffect(() => {
if (
urlItemsPerPage !== itemsPerPage.toString() ||
urlPage !== currentPage.toString()
) {
router.push({
pathname: router.pathname,
query: { page: currentPage, items: itemsPerPage },
});
}
}, [currentPage, itemsPerPage, router]);

const refetchTransactions = () => {
fetchMore({
const refetchTransactions = async () => {
await fetchMore({
variables: {
first: itemsPerPage,
last: null,
Expand All @@ -80,6 +62,30 @@ export const ExtendedTransactionsTable = (
});
};

useEffect(() => {
const fetchData = async () => {
await refetchTransactions();
setCurrentPage(1);
};
fetchData();
}, [itemsPerPage]);

// Set items per page and page in URL when they change
useEffect(() => {
const updateUrl = async () => {
if (
urlItemsPerPage !== itemsPerPage.toString() ||
urlPage !== currentPage.toString()
) {
await router.push({
pathname: router.pathname,
query: { page: currentPage, items: itemsPerPage },
});
}
};
updateUrl();
}, [currentPage, itemsPerPage, router, urlItemsPerPage, urlPage]);

return (
<>
<Box marginBottom="$3">
Expand All @@ -102,9 +108,9 @@ export const ExtendedTransactionsTable = (
</div>
<Button
variant="compact"
onClick={() => {
onClick={async () => {
setCurrentPage(currentPage + 1);
fetchMore({
await fetchMore({
variables: {
first: itemsPerPage,
last: null,
Expand All @@ -124,9 +130,9 @@ export const ExtendedTransactionsTable = (
</Button>
<Button
variant="compact"
onClick={() => {
onClick={async () => {
setCurrentPage(currentPage - 1);
fetchMore({
await fetchMore({
variables: {
first: null,
last: itemsPerPage,
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/graph/src/graph/Query/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Prisma } from '@prisma/client';
import type { Prisma } from '@prisma/client';
import { prismaClient } from '../../db/prismaClient';
import { builder } from '../builder';

Expand Down

0 comments on commit f9ebfca

Please sign in to comment.