|
| 1 | +import { ISSUER_FEATURE_BLOCK_TYPE, METADATA_FEATURE_BLOCK_TYPE, SENDER_FEATURE_BLOCK_TYPE, serializeMessage, TAG_FEATURE_BLOCK_TYPE } from "@iota/iota.js"; |
| 2 | +import { Converter } from "@iota/util.js"; |
| 3 | +import React, { Component, ReactNode } from "react"; |
| 4 | +import { NameHelper } from "../../../utils/nameHelper"; |
| 5 | +import Address from "./Address"; |
| 6 | +import { FeatureBlockProps } from "./FeatureBlockProps"; |
| 7 | + |
| 8 | +/** |
| 9 | + * Component which will display an Feature Block. |
| 10 | + */ |
| 11 | +class FeatureBlock extends Component<FeatureBlockProps> { |
| 12 | + /** |
| 13 | + * Create a new instance of Feature Block. |
| 14 | + * @param props The props. |
| 15 | + */ |
| 16 | + constructor(props: FeatureBlockProps) { |
| 17 | + super(props); |
| 18 | + } |
| 19 | + |
| 20 | + /** |
| 21 | + * Render the component. |
| 22 | + * @returns The node to render. |
| 23 | + */ |
| 24 | + public render(): ReactNode { |
| 25 | + return ( |
| 26 | + <div className="feature-block"> |
| 27 | + <h3>{NameHelper.getFeatureBlockTypeName(this.props.featureBlock.type)}</h3> |
| 28 | + |
| 29 | + {this.props.featureBlock.type === SENDER_FEATURE_BLOCK_TYPE && ( |
| 30 | + <React.Fragment> |
| 31 | + <div className="card--label"> |
| 32 | + Address |
| 33 | + </div> |
| 34 | + <Address |
| 35 | + address={this.props.featureBlock.address} |
| 36 | + /> |
| 37 | + </React.Fragment> |
| 38 | + )} |
| 39 | + {this.props.featureBlock.type === ISSUER_FEATURE_BLOCK_TYPE && ( |
| 40 | + <React.Fragment> |
| 41 | + <div className="card--label"> |
| 42 | + Address |
| 43 | + </div> |
| 44 | + <Address |
| 45 | + address={this.props.featureBlock.address} |
| 46 | + /> |
| 47 | + </React.Fragment> |
| 48 | + )} |
| 49 | + {this.props.featureBlock.type === METADATA_FEATURE_BLOCK_TYPE && ( |
| 50 | + <React.Fragment> |
| 51 | + <div className="card--label"> |
| 52 | + Data: |
| 53 | + </div> |
| 54 | + <div className="card--value row"> |
| 55 | + {this.props.featureBlock.data} |
| 56 | + </div> |
| 57 | + </React.Fragment> |
| 58 | + )} |
| 59 | + {this.props.featureBlock.type === TAG_FEATURE_BLOCK_TYPE && ( |
| 60 | + <React.Fragment> |
| 61 | + <div className="card--label"> |
| 62 | + Tag: |
| 63 | + </div> |
| 64 | + <div className="card--value row"> |
| 65 | + {this.props.featureBlock.tag} |
| 66 | + </div> |
| 67 | + </React.Fragment> |
| 68 | + )} |
| 69 | + </div> |
| 70 | + ); |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +export default FeatureBlock; |
0 commit comments