2018-05-21 19:45:57 +00:00
|
|
|
import React from 'react';
|
2018-05-22 15:11:53 +00:00
|
|
|
import $ from 'jquery';
|
2018-05-29 20:51:59 +00:00
|
|
|
import { Button, Alert } from 'react-bootstrap';
|
2018-05-29 15:00:21 +00:00
|
|
|
import EmbarkJS from 'Embark/EmbarkJS';
|
|
|
|
import ProposalForm from './proposal-form';
|
2018-05-21 19:45:57 +00:00
|
|
|
|
2018-05-22 15:11:53 +00:00
|
|
|
class Proposal extends React.Component {
|
2018-05-21 19:45:57 +00:00
|
|
|
|
2018-05-22 15:11:53 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2018-05-29 15:00:21 +00:00
|
|
|
|
2018-05-22 15:11:53 +00:00
|
|
|
this.state = {
|
2018-05-29 15:00:21 +00:00
|
|
|
url: null,
|
|
|
|
title: null,
|
2018-05-29 20:51:59 +00:00
|
|
|
description: null,
|
|
|
|
error: null
|
2018-05-22 15:11:53 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount(){
|
2018-05-29 15:00:21 +00:00
|
|
|
__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){
|
|
|
|
console.log("Storage get Error => " + err.message);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2018-05-22 15:11:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render(){
|
|
|
|
return (<div>
|
2018-05-29 20:51:59 +00:00
|
|
|
{
|
|
|
|
this.state.error !== null ?
|
|
|
|
<Alert bsStyle="warning">
|
|
|
|
{ this.state.error }
|
|
|
|
</Alert>
|
|
|
|
: ''
|
|
|
|
}
|
2018-05-29 15:00:21 +00:00
|
|
|
<h3>{ this.state.title }</h3>
|
|
|
|
<p>{ this.state.description }</p>
|
2018-05-22 15:11:53 +00:00
|
|
|
<a href={ this.state.url } target="_blank">{ this.state.url }</a>
|
2018-05-29 15:00:21 +00:00
|
|
|
<ProposalForm />
|
2018-05-22 15:11:53 +00:00
|
|
|
</div>);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-05-21 19:45:57 +00:00
|
|
|
|
|
|
|
|
2018-05-21 20:15:46 +00:00
|
|
|
export default Proposal;
|