Commit ab52f075 authored by tom's avatar tom

fix merge

parent 7d7bf1fe
...@@ -46,5 +46,5 @@ export interface TransactionsResponse { ...@@ -46,5 +46,5 @@ export interface TransactionsResponse {
block_number: number; block_number: number;
index: number; index: number;
items_count: number; items_count: number;
}; } | null;
} }
...@@ -25,6 +25,7 @@ type Props = { ...@@ -25,6 +25,7 @@ type Props = {
} }
const TxsContent = ({ const TxsContent = ({
queryName,
showDescription, showDescription,
stateFilter, stateFilter,
apiPath, apiPath,
...@@ -66,7 +67,7 @@ const TxsContent = ({ ...@@ -66,7 +67,7 @@ const TxsContent = ({
onNextPageClick, onNextPageClick,
hasPagination, hasPagination,
resetPage, resetPage,
} = useQueryWithPages({ filter: stateFilter }, apiPath); } = useQueryWithPages(apiPath, queryName, stateFilter && { filter: stateFilter });
// } = useQueryWithPages({ ...filters, filter: stateFilter, apiPath }); // } = useQueryWithPages({ ...filters, filter: stateFilter, apiPath });
const isMobile = useIsMobile(false); const isMobile = useIsMobile(false);
...@@ -124,7 +125,7 @@ const TxsContent = ({ ...@@ -124,7 +125,7 @@ const TxsContent = ({
{ hasPagination ? ( { hasPagination ? (
<Pagination <Pagination
currentPage={ page } currentPage={ page }
hasNextPage={ data?.next_page_params !== undefined && Object.keys(data?.next_page_params).length > 0 } hasNextPage={ data?.next_page_params !== undefined && Object.keys(data?.next_page_params || {}).length > 0 }
onNextPageClick={ onNextPageClick } onNextPageClick={ onNextPageClick }
onPrevPageClick={ onPrevPageClick } onPrevPageClick={ onPrevPageClick }
/> />
......
import React from 'react'; import React from 'react';
import { QueryKeys } from 'types/client/queries';
import TxsContent from './TxsContent'; import TxsContent from './TxsContent';
type Props = { type Props = {
...@@ -9,6 +11,7 @@ type Props = { ...@@ -9,6 +11,7 @@ type Props = {
const TxsTab = ({ tab }: Props) => { const TxsTab = ({ tab }: Props) => {
return ( return (
<TxsContent <TxsContent
queryName={ QueryKeys.transactions }
showDescription={ tab === 'validated' } showDescription={ tab === 'validated' }
stateFilter={ tab } stateFilter={ tab }
apiPath="/api/transactions" apiPath="/api/transactions"
......
...@@ -6,13 +6,13 @@ import { animateScroll } from 'react-scroll'; ...@@ -6,13 +6,13 @@ import { animateScroll } from 'react-scroll';
import type { TransactionsResponse } from 'types/api/transaction'; import type { TransactionsResponse } from 'types/api/transaction';
import type { TTxsFilters } from 'types/api/txsFilters'; import type { TTxsFilters } from 'types/api/txsFilters';
import { QueryKeys } from 'types/client/queries'; import type { QueryKeys } from 'types/client/queries';
import useFetch from 'lib/hooks/useFetch'; import useFetch from 'lib/hooks/useFetch';
const PAGINATION_FIELDS = [ 'block_number', 'index', 'items_count' ]; const PAGINATION_FIELDS = [ 'block_number', 'index', 'items_count' ];
export default function useQueryWithPages(filters: TTxsFilters, apiPath: string) { export default function useQueryWithPages(apiPath: string, queryName: QueryKeys, filters?: TTxsFilters) {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const router = useRouter(); const router = useRouter();
const [ page, setPage ] = React.useState(1); const [ page, setPage ] = React.useState(1);
...@@ -21,7 +21,7 @@ export default function useQueryWithPages(filters: TTxsFilters, apiPath: string) ...@@ -21,7 +21,7 @@ export default function useQueryWithPages(filters: TTxsFilters, apiPath: string)
const fetch = useFetch(); const fetch = useFetch();
const { data, isLoading, isError } = useQuery<unknown, unknown, TransactionsResponse>( const { data, isLoading, isError } = useQuery<unknown, unknown, TransactionsResponse>(
[ QueryKeys.transactions, { page, filters } ], [ queryName, { page, filters } ],
async() => { async() => {
const params: Array<string> = []; const params: Array<string> = [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment