-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from MoralisWeb3/moralis-scan-ep07
Moralis scan ep07
- Loading branch information
Showing
5 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { createContext, useContext } from 'react' | ||
import { usePagination } from '../hooks/pagination'; | ||
|
||
export const ResultContext = createContext({results: []}); | ||
export const useResultContext = () => useContext(ResultContext); | ||
|
||
export default function Paginator({methodName, userAddress, options, children}) { | ||
const { | ||
// pageSize, | ||
// setPageSize, | ||
totalPages, | ||
setCurrPage, | ||
currPage, | ||
nextPage, | ||
prevPage, | ||
results, | ||
numResults, | ||
} = usePagination(methodName, userAddress, options); | ||
|
||
return ( | ||
<div> | ||
<div className="d-flex justify-content-between align-items-start mb-2"> | ||
<span>A total of {numResults} transactions found</span> | ||
<div> | ||
<button className="btn btn-info ms-1" onClick={() => setCurrPage(1)}> | ||
First | ||
</button> | ||
<button className="btn btn-info ms-1" onClick={prevPage}> | ||
{"<"} | ||
</button> | ||
<span className="btn btn-info ms-1"> | ||
Page {currPage} of {totalPages} | ||
</span> | ||
<button className="btn btn-info ms-1" onClick={nextPage}> | ||
{">"} | ||
</button> | ||
<button | ||
className="btn btn-info ms-1" | ||
onClick={() => setCurrPage(totalPages)} | ||
> | ||
Last | ||
</button> | ||
</div> | ||
</div> | ||
<ResultContext.Provider value={{ results }}> | ||
{children} | ||
</ResultContext.Provider> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
import { useParams } from 'react-router'; | ||
import { processTransaction } from '../queries/transactions'; | ||
import Paginator from './Paginator'; | ||
import TransResults from './TransResults'; | ||
|
||
export default function Transactions() { | ||
const {address } = useParams(); | ||
if (!address) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div> | ||
<Paginator | ||
userAddress={address} | ||
methodName="getTransactions" | ||
options={{ postProcess: processTransaction }} | ||
> | ||
<TransResults /> | ||
</Paginator> | ||
</div> | ||
); | ||
} |