import React from 'react'; import NavBar from 'containers/NavBar'; import ChannelClaimsDisplay from 'components/ChannelClaimsDisplay'; import request from 'utils/request'; class ShowChannel extends React.Component { constructor (props) { super(props); this.state = { error: null, }; this.getAndStoreChannelData = this.getAndStoreChannelData.bind(this); } componentDidMount () { const channelName = this.props.channelName; const channelClaimId = this.props.channelClaimId || 'none'; this.getAndStoreChannelData(channelName, channelClaimId); } getAndStoreChannelData (channelName, channelClaimId) { const url = `/api/channel-data/${channelName}/${channelClaimId}`; const that = this; return request(url) .then(({ success, message, data }) => { console.log('api/channel-data response:', data); if (!success) { return that.setState({error: message}); } that.setState({ channelName : data.channelName, longChannelClaimId : data.longChannelClaimId, shortChannelClaimId: data.shortChannelClaimId, }); }) .catch((error) => { that.setState({error: error.message}); }); } render () { return (
{this.state.error ? (

{this.state.error}

) : (

channel name: {this.props.channelName}

full channel id: {this.state.longChannelClaimId ? this.state.longChannelClaimId : 'loading...'}

short channel id: {this.state.shortChannelClaimId ? this.state.shortChannelClaimId : 'loading...'}

{ (this.state.channelName && this.state.longChannelClaimId) && }
)}
); } }; // required props // channelName // channelClaimId export default ShowChannel;