import React from "react";
import { Icon } from "component/common";
class UriIndicator extends React.PureComponent {
componentWillMount() {
this.resolve(this.props);
}
componentWillReceiveProps(nextProps) {
this.resolve(nextProps);
}
resolve(props) {
const { isResolvingUri, resolveUri, claim, uri } = props;
if (!isResolvingUri && claim === undefined && uri) {
resolveUri(uri);
}
}
render() {
const { claim, uri, isResolvingUri } = this.props;
if (isResolvingUri) {
return Validating...;
}
if (!claim) {
return Unused;
}
const {
channel_name: channelName,
has_signature: hasSignature,
signature_is_valid: signatureIsValid,
} = claim;
if (!hasSignature || !channelName) {
return Anonymous;
}
let icon, modifier;
if (signatureIsValid) {
modifier = "valid";
} else {
icon = "icon-times-circle";
modifier = "invalid";
}
return (
{channelName} {" "}
{!signatureIsValid
?
: ""}
);
}
}
export default UriIndicator;