Adding content to proposals

This commit is contained in:
Richard Ramos 2018-05-22 11:11:53 -04:00
parent 5f8377f23f
commit ea171fb030
4 changed files with 53 additions and 9 deletions

View File

@ -22,7 +22,20 @@ class ProposalContainer extends React.Component {
fetchProposals(cb){
// TODO: populate proposals
cb([1, 2, 3]);
let proposalList = [
{
topic: "0x68747470733a2f2f69646561732e7374617475732e696d2f69646561732f3038382d646170702d657870657269656e6365",
txHash: "0x1234566",
approved: true
},
{
topic: "0x68747470733a2f2f69646561732e7374617475732e696d2f69646561732f3039302d6272616e63682d706572662d7374617473",
txHash: "0x1234566",
approved: true
}
]
cb(proposalList);
}
render(){

View File

@ -1,13 +1,43 @@
import React from 'react';
import $ from 'jquery';
import {Button} from 'react-bootstrap';
const Proposal = props => <div>
{ props.data.topic }
class Proposal extends React.Component {
BUILD SOME AWESOME STUFF
This is a random text related to the previous title
Votes: 10 / 500
[Vote]
constructor(props) {
super(props);
this.state = {
url: web3.utils.toAscii(props.data.topic),
content: ''
};
}
componentDidMount(){
fetch(this.state.url)
.then((res) => {
return res.text();
})
.then((data) => {
data = data.replace(/<svg.+\/svg>/, '');
this.setState({'content': data});
});
}
render(){
let $content = $(this.state.content);
const title = $('h1.post-title', $content).text();
const summary = $('h2#summary', $content).next().text();
return (<div>
<h3>{ title }</h3>
<a href={ this.state.url } target="_blank">{ this.state.url }</a>
<p>{summary}</p>
<Button bsStyle="primary">Vote</Button>
<Button bsStyle="link">Cancel</Button>
</div>);
}
}
</div>
export default Proposal;

View File

@ -17,7 +17,7 @@ class VotingDapp extends React.Component {
render(){
return <div>
<StatusBar />
<StatusBar {...this.props} />
<ProposalContainer />
<ProposalForm />
</div>;

View File

@ -17,6 +17,7 @@
},
"homepage": "https://github.com/status-im/contracts#readme",
"dependencies": {
"jquery": "^3.3.1",
"react": "^16.3.2",
"react-blockies": "^1.3.0",
"react-bootstrap": "^0.32.1",