further work

This commit is contained in:
Thomas Ruoff
2017-02-19 23:27:53 +01:00
parent 6865a63832
commit da027191d6
8 changed files with 138 additions and 20 deletions

View File

@@ -1,8 +1,7 @@
import { Component, h } from 'preact';
import PDF from 'react-pdf';
import Input from '../components/Input';
import TextAreaInput from '../components/TextAreaInput';
import LetterOptions from '../components/LetterOptions';
import Button from '../components/Button';
import Preview from '../components/Preview';
@@ -12,35 +11,39 @@ class Home extends Component {
render(props) {
const component = this;
return (
<div>
<TextAreaInput
name="address"
text="Adresse"
onchange={this._onChange.bind(this)}
value={props.address}
/>
<Input
name="subject"
text="Betreff"
onchange={this._onChange.bind(this)}
value={props.subject}
/>
<Button onClick={this._onGenerate.bind(this)} text="Generiere"/>
<Preview pdfUrl={this.state.pdfUrl} />
<div className="home">
<div>
<LetterOptions onChange={this._onChange.bind(this)} />
<Button onClick={this._onGenerate.bind(this)} text="Generiere"/>
</div>
<div>
<Preview
pdfUrl={this.state.pdfUrl}
pdfIsLoading={this.state.pdfIsLoading}
pdfError={this.state.pdfError}
/>
</div>
</div>
);
}
_onGenerate() {
this.setState({
pdfIsLoading: true,
pdfError: null
})
generatePdf(this.state)
.then((data) => {
const {id} = data;
this.setState({
pdfIsLoading: false,
pdfUrl: `//localhost:5000/pdf/${id}`
});
})
.catch((error) => {
this.setState({
pdfIsLoading: false,
pdfError: error,
pdfUrl: null
});
});