|
|
|
@ -1,6 +1,6 @@ |
|
|
|
import React, { Component } from "react"; |
|
|
|
import { ExpenseList, ExpenseForm, LoadingBar } from "./components/index"; |
|
|
|
import { MDCSnackbar } from "@material/snackbar/dist/mdc.snackbar.js"; |
|
|
|
import React, {Component} from "react"; |
|
|
|
import {ExpenseList, ExpenseForm, LoadingBar} from "./components/index"; |
|
|
|
import {MDCSnackbar} from "@material/snackbar/dist/mdc.snackbar.js"; |
|
|
|
|
|
|
|
import "@material/fab/dist/mdc.fab.css"; |
|
|
|
import "@material/button/dist/mdc.button.css"; |
|
|
|
@ -72,40 +72,40 @@ class App extends Component { |
|
|
|
} |
|
|
|
|
|
|
|
signedInChanged = (signedIn) => { |
|
|
|
this.setState({ signedIn: signedIn }); |
|
|
|
this.setState({signedIn: signedIn}); |
|
|
|
if (this.state.signedIn) { |
|
|
|
this.load(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
handleExpenseSubmit = () => { |
|
|
|
this.setState({ processing: true, showExpenseForm: false }); |
|
|
|
this.setState({processing: true, showExpenseForm: false}); |
|
|
|
const submitAction = (this.state.expense.id |
|
|
|
? this.update |
|
|
|
: this.append).bind(this); |
|
|
|
submitAction(this.state.expense).then( |
|
|
|
response => { |
|
|
|
this.snackbar.show({ |
|
|
|
message: `Expense ${this.state.expense.id ? "updated" : "added"}!` |
|
|
|
message: `Ausgabe ${this.state.expense.id ? "aktualisiert" : "hinzugefügt"}!` |
|
|
|
}); |
|
|
|
this.load(); |
|
|
|
}, |
|
|
|
response => { |
|
|
|
console.error("Something went wrong"); |
|
|
|
console.error("Ausgabe konnte nicht gespeichert werden!"); |
|
|
|
console.error(response); |
|
|
|
this.setState({ loading: false }); |
|
|
|
this.setState({loading: false}); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
handleExpenseChange = (attribute, value) => { |
|
|
|
this.setState({ |
|
|
|
expense: Object.assign({}, this.state.expense, { [attribute]: value }) |
|
|
|
expense: Object.assign({}, this.state.expense, {[attribute]: value}) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
handleExpenseDelete = (expense) => { |
|
|
|
this.setState({ processing: true, showExpenseForm: false }); |
|
|
|
this.setState({processing: true, showExpenseForm: false}); |
|
|
|
const expenseRow = expense.id.substring(10); |
|
|
|
window.gapi.client.sheets.spreadsheets |
|
|
|
.batchUpdate({ |
|
|
|
@ -127,23 +127,23 @@ class App extends Component { |
|
|
|
}) |
|
|
|
.then( |
|
|
|
response => { |
|
|
|
this.snackbar.show({ message: "Expense deleted!" }); |
|
|
|
this.snackbar.show({message: "Ausgabe entfernt!"}); |
|
|
|
this.load(); |
|
|
|
}, |
|
|
|
response => { |
|
|
|
console.error("Something went wrong"); |
|
|
|
console.error("Ausgabe konnte nicht entfernt werden!"); |
|
|
|
console.error(response); |
|
|
|
this.setState({ loading: false }); |
|
|
|
this.setState({loading: false}); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
handleExpenseSelect = (expense) => { |
|
|
|
this.setState({ expense: expense, showExpenseForm: true }); |
|
|
|
this.setState({expense: expense, showExpenseForm: true}); |
|
|
|
} |
|
|
|
|
|
|
|
handleExpenseCancel = () => { |
|
|
|
this.setState({ showExpenseForm: false }); |
|
|
|
this.setState({showExpenseForm: false}); |
|
|
|
} |
|
|
|
|
|
|
|
onExpenseNew() { |
|
|
|
@ -156,8 +156,8 @@ class App extends Component { |
|
|
|
date: `${now.getFullYear()}-${now.getMonth() < 9 |
|
|
|
? "0" + (now.getMonth() + 1) |
|
|
|
: now.getMonth() + 1}-${now.getDate() < 10 |
|
|
|
? "0" + now.getDate() |
|
|
|
: now.getDate()}`,
|
|
|
|
? "0" + now.getDate() |
|
|
|
: now.getDate()}`,
|
|
|
|
category: this.state.categories[0], |
|
|
|
account: this.state.accounts[0] |
|
|
|
} |
|
|
|
@ -246,7 +246,7 @@ class App extends Component { |
|
|
|
<header className="mdc-toolbar mdc-toolbar--fixed"> |
|
|
|
<div className="mdc-toolbar__row"> |
|
|
|
<section className="mdc-toolbar__section mdc-toolbar__section--align-start"> |
|
|
|
<span className="mdc-toolbar__title">Expenses</span> |
|
|
|
<span className="mdc-toolbar__title">Haushaltsrechner</span> |
|
|
|
</section> |
|
|
|
<section |
|
|
|
className="mdc-toolbar__section mdc-toolbar__section--align-end" |
|
|
|
@ -347,13 +347,13 @@ class App extends Component { |
|
|
|
<div> |
|
|
|
<div className="mdc-card"> |
|
|
|
<section className="mdc-card__primary"> |
|
|
|
<h2 className="mdc-card__subtitle">This month you've spent:</h2> |
|
|
|
<h2 className="mdc-card__subtitle">Ausgaben dieses Monat:</h2> |
|
|
|
<h1 className="mdc-card__title mdc-card__title--large center"> |
|
|
|
{this.state.currentMonth} |
|
|
|
</h1> |
|
|
|
</section> |
|
|
|
<section className="mdc-card__supporting-text"> |
|
|
|
Previous month: {this.state.previousMonth} |
|
|
|
Vorheriges Monat: {this.state.previousMonth} |
|
|
|
</section> |
|
|
|
</div> |
|
|
|
<ExpenseList |
|
|
|
|