diff --git a/app/components/voting-dapp/proposal-container.js b/app/components/voting-dapp/proposal-container.js index 74381f3..103f464 100644 --- a/app/components/voting-dapp/proposal-container.js +++ b/app/components/voting-dapp/proposal-container.js @@ -34,11 +34,7 @@ class ProposalContainer extends React.Component { // TODO: populate proposals let proposalList = [ { - description: "0x68747470733a2f2f69646561732e7374617475732e696d2f69646561732f3038382d646170702d657870657269656e6365", - approved: true - }, - { - description: "0x68747470733a2f2f69646561732e7374617475732e696d2f69646561732f3039302d6272616e63682d706572662d7374617473", + description: "QmZ4hQ5jKUqtHEXhXDVSz81JexMoDmVfiypECFQZZibyrS", approved: true } ] diff --git a/app/components/voting-dapp/proposal.js b/app/components/voting-dapp/proposal.js index 2898579..51e4b5d 100644 --- a/app/components/voting-dapp/proposal.js +++ b/app/components/voting-dapp/proposal.js @@ -1,39 +1,47 @@ import React from 'react'; import $ from 'jquery'; import {Button} from 'react-bootstrap'; +import EmbarkJS from 'Embark/EmbarkJS'; +import ProposalForm from './proposal-form'; class Proposal extends React.Component { constructor(props) { super(props); + this.state = { - url: web3.utils.toAscii(props.data.description), - content: '' + url: null, + title: null, + description: null }; } componentDidMount(){ - fetch(this.state.url) - .then((res) => { - return res.text(); - }) - .then((data) => { - data = data.replace(//, ''); - this.setState({'content': data}); - }); + __embarkContext.execWhenReady(() => { + EmbarkJS.Storage.get(this.props.data.description) + .then((content) => { + let jsonObj = JSON.parse(content); + this.setState({ + url: jsonObj.url, + title: jsonObj.title, + description: jsonObj.description + }) + }) + .catch((err) => { + if(err){ + // TODO handle error + console.log("Storage get Error => " + err.message); + } + }); + }); } render(){ - let $content = $(this.state.content); - const title = $('h1.post-title', $content).text(); - const summary = $('h2#summary', $content).next().text(); - return (
-

{ title }

+

{ this.state.title }

+

{ this.state.description }

{ this.state.url } -

{summary}

- - +
); }