add clear button

This commit is contained in:
Thomas Ruoff
2018-02-01 22:01:15 +01:00
parent f3985c02b2
commit 5bd13ced7a
2 changed files with 30 additions and 2 deletions

View File

@@ -3,8 +3,8 @@ header h1 {
}
button {
display: block;
margin-top: 1em;
margin-top: 12px;
margin-right: 12px;
margin-bottom: 12px;
}

View File

@@ -7,6 +7,26 @@ import {generatePdf, getLatest} from './apiHelper';
import './App.css';
const DEFAULT_OPTIONS = Object.freeze({
template: 'brief-fam',
subject: '',
yourRef: '',
yourRefName: '',
yourMail: '',
myRef: '',
customer: '',
invoice: '',
date: '',
signature: '',
specialMail: '',
address: '',
opening: '',
body: '',
closing: '',
ps: '',
enclosing: '',
});
class App extends Component {
componentDidMount() {
this._getLatest();
@@ -23,6 +43,7 @@ class App extends Component {
</div>
<div>
<Button onClick={this._onGenerate.bind(this)} text="Backe PDF"/>
<Button onClick={this._onClear.bind(this)} text="Alles Löschen"/>
<Preview
pdfUrl={state.pdfUrl}
pdfIsLoading={state.pdfIsLoading}
@@ -37,6 +58,13 @@ class App extends Component {
this.setState({options: Object.assign({}, selectedOptions)});
}
_onClear() {
this.setState({
options: Object.assign({}, DEFAULT_OPTIONS),
pdfUrl: null,
});
}
_onGenerate() {
const state = this.state || {};
this.setState({