Skip to content

Commit

Permalink
Merge pull request #20 from farminf/dev
Browse files Browse the repository at this point in the history
Charts and filters
  • Loading branch information
Farmin authored Jan 22, 2018
2 parents 1e54fb5 + 40304a3 commit 827adc0
Show file tree
Hide file tree
Showing 32 changed files with 994 additions and 189 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"classnames": "^2.2.5",
"express": "^4.16.2",
"firebase": "^4.8.0",
"lodash": "^4.17.4",
"material-ui": "^1.0.0-beta.22",
"material-ui-icons": "^1.0.0-beta.17",
"moment": "^2.20.1",
Expand All @@ -19,6 +20,7 @@
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-scripts": "1.0.17",
"recharts": "^1.0.0-beta.9",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
},
Expand Down
10 changes: 10 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,14 @@

.DateInput_input {
padding : 0 !important;
}

.container {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
width: 800px;
height: 800px;
background-color: #fff;
}
1 change: 1 addition & 0 deletions src/actions/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const startSetAccounts = () => {
const user_uid = getState().auth.uid;
return database
.ref(`users/${user_uid}/accounts`)
.orderByKey()
.once('value')
.then((snapshot) => {
const accounts = [];
Expand Down
1 change: 1 addition & 0 deletions src/actions/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const startSetCategories = () => {
const user_uid = getState().auth.uid;
return database
.ref(`users/${user_uid}/categories`)
.orderByChild('name')
.once('value')
.then((snapshot) => {
const categories = [];
Expand Down
23 changes: 23 additions & 0 deletions src/actions/filters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SET_TEXT_FILTER
export const setTextFilter = (text = '') => ({type: 'SET_TEXT_FILTER', text});

// SORT_BY_DATE
export const sortByDate = () => ({type: 'SORT_BY_DATE'});

// SORT_BY_AMOUNT
export const sortByAmount = () => ({type: 'SORT_BY_AMOUNT'});

// SET_START_DATE
export const setStartDate = (startDate) => ({type: 'SET_START_DATE', startDate});

// SET_END_DATE
export const setEndDate = (endDate) => ({type: 'SET_END_DATE', endDate});

// SET_TRANSACTION_TYPE_FILTER
export const setTypeFilter = (typeFilter) => ({type: 'SET_TRANSACTION_TYPE_FILTER', typeFilter});

// SET_TRANSACTION_TYPE_DESCRIPTION
export const setDescriptionFilter = (descriptionFilter) => ({type: 'SET_TRANSACTION_DESCRIPTION_FILTER', descriptionFilter});



13 changes: 10 additions & 3 deletions src/actions/transactions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import database from '../firebase/firebase'
import database from '../firebase/firebase'
import moment from 'moment';
import _ from 'lodash';
//{storage}


export const addTransaction = (transaction) => ({type: 'ADD_TRANSACTION', transaction});

Expand Down Expand Up @@ -43,12 +47,15 @@ export const startAddTransaction = (transactionData = {}) => {

export const setTransactions = (transactions) => ({type: 'SET_TRANSACTIONS', transactions});

export const startSetTransactions = () => {
export const startSetTransactions = ( fromMoment = moment().startOf('month').valueOf() , toMoment = moment().valueOf() ) => {

return (dispatch, getState) => {
const user_uid = getState().auth.uid;
return database
.ref(`users/${user_uid}/transactions`)
.orderByChild('date')
.startAt(fromMoment)
.endAt(toMoment)
.once('value')
.then((snapshot) => {
const transactions = [];
Expand All @@ -58,7 +65,7 @@ export const startSetTransactions = () => {
...childSnapshot.val()
})
});
dispatch(setTransactions(transactions));
dispatch(setTransactions( _.orderBy(transactions , ['date'] , ['desc'])));
});
};
};
Expand Down
21 changes: 18 additions & 3 deletions src/components/AccountForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {withStyles} from 'material-ui/styles';
import TextField from 'material-ui/TextField';
import Button from 'material-ui/Button';
import {connect} from 'react-redux';
import Paper from 'material-ui/Paper';


const styles = theme => ({
textField: {
Expand All @@ -19,7 +21,19 @@ const styles = theme => ({
width: 250,
marginTop: theme.spacing.unit,
marginBottom: theme.spacing.unit
}
},
paper: theme
.mixins
.gutters({


paddingLeft: 0,
paddingRight: 0,
marginTop: theme.spacing.unit * 3,
marginLeft: 10,
marginRight: 10,
overflowX: 'auto'
})
});

class AccountForm extends React.Component {
Expand Down Expand Up @@ -79,7 +93,8 @@ class AccountForm extends React.Component {
render() {
const {classes} = this.props;
return (
<div>
<Paper className={classes.paper} elevation={4}>

{this.state.error && <p>{this.state.error}</p>}
<form onSubmit={this.onSubmit}>
<TextField
Expand All @@ -104,7 +119,7 @@ class AccountForm extends React.Component {
raised
color="primary">{this.state.submit_button_title}</Button>
</form>
</div>
</Paper>
)
}

Expand Down
22 changes: 19 additions & 3 deletions src/components/AccountList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import AccountListItem from './AccountListItem';
import {startDeleteAccount, startAddAccount} from '../actions/accounts';
import {withStyles} from 'material-ui/styles';
import Table, {TableBody, TableCell, TableHead, TableRow} from 'material-ui/Table';
import Paper from 'material-ui/Paper';


const styles = theme => ({
root: {
Expand All @@ -14,7 +16,19 @@ const styles = theme => ({
table: {
minWidth: 500,

}
},
paper: theme
.mixins
.gutters({


paddingLeft: 16,
paddingRight: 16,
marginTop: theme.spacing.unit * 3,
marginLeft: 10,
marginRight: 10,
overflowX: 'auto'
})
});

export class AccountList extends React.Component {
Expand Down Expand Up @@ -45,12 +59,14 @@ export class AccountList extends React.Component {
render() {
const {classes} = this.props;
return (
<div>
<Paper className={classes.paper} elevation={4}>

{this.props.accounts.lenght === 0 || this.props.accounts.hasOwnProperty(0) === false
? (
<p>no accounts</p>
)
: (

<Table className={classes.table}>
<TableHead>
<TableRow>
Expand All @@ -76,7 +92,7 @@ export class AccountList extends React.Component {
</Table>
)
}
</div>
</Paper>

)
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddFloatingButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const styles = theme => ({
},
dialogContent:{
textAlign: 'center',
maxWidth:300,
maxWidth:400,
},
dialogTitle:{
textAlign: 'center'
Expand Down
21 changes: 18 additions & 3 deletions src/components/CategoryForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {withStyles} from 'material-ui/styles';
import TextField from 'material-ui/TextField';
import Button from 'material-ui/Button';
import {connect} from 'react-redux';
import Paper from 'material-ui/Paper';


const styles = theme => ({
textField: {
Expand All @@ -19,7 +21,19 @@ const styles = theme => ({
width: 250,
marginTop: theme.spacing.unit,
marginBottom: theme.spacing.unit
}
},
paper: theme
.mixins
.gutters({


paddingLeft: 0,
paddingRight: 0,
marginTop: theme.spacing.unit * 3,
marginLeft: 10,
marginRight: 10,
overflowX: 'auto'
})
});

class CategoryForm extends React.Component {
Expand Down Expand Up @@ -60,7 +74,8 @@ class CategoryForm extends React.Component {
render() {
const {classes} = this.props;
return (
<div>
<Paper className={classes.paper} elevation={4}>

{this.state.error && <p>{this.state.error}</p>}
<form onSubmit={this.onSubmit}>
<TextField
Expand All @@ -77,7 +92,7 @@ class CategoryForm extends React.Component {
raised
color="primary">{this.state.submit_button_title}</Button>
</form>
</div>
</Paper>
)
}

Expand Down
22 changes: 19 additions & 3 deletions src/components/CategoryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Table, {
TableFooter,
TablePagination
} from 'material-ui/Table';
import Paper from 'material-ui/Paper';


const styles = theme => ({
root: {
Expand All @@ -20,7 +22,19 @@ const styles = theme => ({
},
table: {
minWidth: 500
}
},
paper: theme
.mixins
.gutters({


paddingLeft: 16,
paddingRight: 16,
marginTop: theme.spacing.unit * 3,
marginLeft: 10,
marginRight: 10,
overflowX: 'auto'
})
});

export class CategoryList extends React.Component {
Expand Down Expand Up @@ -67,12 +81,14 @@ export class CategoryList extends React.Component {
render() {
const {classes} = this.props;
return (
<div>
<Paper className={classes.paper} elevation={4}>

{this.props.categories.lenght === 0 || this.props.categories.hasOwnProperty(0) === false
? (
<p>no categories</p>
)
: (

<Table className={classes.table}>
<TableHead>
<TableRow>
Expand Down Expand Up @@ -108,7 +124,7 @@ export class CategoryList extends React.Component {
</Table>
)
}
</div>
</Paper>

)
}
Expand Down
Loading

0 comments on commit 827adc0

Please sign in to comment.