This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): Display receipts on Block Details page (#643)
Resolves #590; Resolves #316; Resolves #303; Resolves #544 ### Test Plan: - [x] All components are unit-tested - [x] Update tests in existing componets - [x] Manually check page loading
- Loading branch information
1 parent
7bb87ac
commit b471409
Showing
33 changed files
with
1,703 additions
and
254 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from "react"; | ||
|
||
import ReceiptsApi, { Receipt } from "../../libraries/explorer-wamp/receipts"; | ||
|
||
import Receipts from "../receipts/Receipts"; | ||
import Placeholder from "../utils/Placeholder"; | ||
import PaginationSpinner from "../utils/PaginationSpinner"; | ||
|
||
interface Props { | ||
blockHash: string; | ||
} | ||
|
||
interface State { | ||
receipts: Receipt[]; | ||
loading: boolean; | ||
} | ||
|
||
class ReceiptsInBlock extends React.Component<Props, State> { | ||
state = { | ||
receipts: [], | ||
loading: true, | ||
}; | ||
componentDidMount() { | ||
this.fetchReceiptsList(this.props.blockHash); | ||
} | ||
|
||
componentDidUpdate(prevProps: any) { | ||
if (prevProps.blockHash !== this.props.blockHash) { | ||
this.fetchReceiptsList(this.props.blockHash); | ||
} | ||
} | ||
|
||
fetchReceiptsList = (blockHash: string): void => { | ||
if (blockHash) { | ||
new ReceiptsApi().queryReceiptsList(blockHash).then((receipts) => { | ||
this.setState({ receipts, loading: false }); | ||
}); | ||
} | ||
}; | ||
render() { | ||
const { receipts, loading } = this.state; | ||
|
||
return ( | ||
<> | ||
{loading ? ( | ||
<PaginationSpinner hidden={false} /> | ||
) : receipts.length > 0 ? ( | ||
<Receipts receipts={receipts} /> | ||
) : ( | ||
<Placeholder>{"There are no receipts in this block"}</Placeholder> | ||
)} | ||
</> | ||
); | ||
} | ||
} | ||
|
||
export default ReceiptsInBlock; |
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.