-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: query param base impl * feat: moving fetching logic to context * feat: using page before rendering if is diff from default * chore: changing number upon change of page with state update * chore: upon going back update url with queryParam
- Loading branch information
Showing
12 changed files
with
9,805 additions
and
6,782 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
require("@rushstack/eslint-patch/modern-module-resolution"); | ||
|
||
module.exports = { | ||
extends: "@chainsafe" | ||
extends: "@chainsafe" , | ||
rules: { | ||
"@typescript-eslint/explicit-function-return-type": "off", | ||
}, | ||
"overrides": [ | ||
{ | ||
// enable the rule specifically for TypeScript files | ||
"files": ["*.ts"], | ||
"rules": { | ||
"@typescript-eslint/explicit-function-return-type": "error", | ||
}, | ||
}, | ||
], | ||
} |
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
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,48 @@ | ||
import { useEffect } from "react" | ||
import { Actions, ExplorerContextState, Routes } from "../types" | ||
import { sanitizeTransferData } from "../utils/Helpers" | ||
|
||
export function useGetTransferData(routes: Routes, dispatcher: React.Dispatch<Actions>, state: ExplorerContextState, page: number): void { | ||
const pageToUse = page !== 0 && page !== state.queryParams.page ? page : state.queryParams.page | ||
|
||
const fetchTransfers = async (): Promise<void> => { | ||
dispatcher({ | ||
type: "loading_transfers", | ||
}) | ||
|
||
try { | ||
const transfers = await routes.transfers(`${pageToUse}`, `${state.queryParams.limit}`) | ||
const sanitizedTransfers = sanitizeTransferData(transfers) | ||
|
||
dispatcher({ | ||
type: "fetch_transfers", | ||
payload: sanitizedTransfers, | ||
}) | ||
|
||
dispatcher({ | ||
type: "loading_done", | ||
}) | ||
} catch (e) { | ||
dispatcher({ | ||
type: "fetch_transfer_error", | ||
payload: "Error fetching all the transfers", | ||
}) | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
void fetchTransfers() | ||
}, [state.queryParams]) | ||
|
||
useEffect(() => { | ||
if (pageToUse !== state.queryParams.page) { | ||
dispatcher({ | ||
type: "set_query_params", | ||
payload: { | ||
page: pageToUse, | ||
limit: state.queryParams.limit, | ||
}, | ||
}) | ||
} | ||
}, [page]) | ||
} |
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
Oops, something went wrong.