mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-03 22:47:25 +01:00
further work
This commit is contained in:
@@ -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
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user