-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17343bf
commit f513eea
Showing
50 changed files
with
1,598 additions
and
784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {firebase, googleAuthProvider} from '../firebase/firebase'; | ||
|
||
export const login = (uid) => ({ | ||
type: 'LOGIN', | ||
uid | ||
}); | ||
|
||
export const startLogin = () => { | ||
return () => { | ||
return firebase.auth().signInWithPopup(googleAuthProvider); | ||
} | ||
}; | ||
|
||
export const logout = ()=> ({ | ||
type:'LOGOUT' | ||
}); | ||
|
||
export const startLogout = () => { | ||
return () => { | ||
return firebase.auth().signOut(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,47 @@ | ||
import React from 'react'; | ||
import {connect} from 'react-redux'; | ||
import { connect } from 'react-redux'; | ||
import ExpenseForm from './ExpenseForm'; | ||
import {startEditExpense, startRemoveExpense} from '../actions/expenses'; | ||
import { startEditExpense, startRemoveExpense } from '../actions/expenses'; | ||
|
||
export class EditExpensePage extends React.Component{ | ||
export class EditExpensePage extends React.Component { | ||
onSubmit = (expense) => { | ||
this.props.startEditExpense(this.props.expense.id,expense); | ||
this.props.startEditExpense(this.props.expense.id, expense); | ||
this.props.history.push('/'); | ||
} | ||
onRemove = ()=>{ | ||
this.props.startRemoveExpense({id: this.props.expense.id}); | ||
onRemove = () => { | ||
this.props.startRemoveExpense({ id: this.props.expense.id }); | ||
this.props.history.push('/'); | ||
} | ||
render(){ | ||
return( | ||
render() { | ||
return ( | ||
<div> | ||
<ExpenseForm | ||
expense = {this.props.expense} | ||
onSubmit = {this.onSubmit }/> | ||
|
||
<button onClick= {this.onRemove}>Remove</button> | ||
</div> | ||
<div className="page-header"> | ||
<div className="content-container"> | ||
<h1 className="page-header__title">Edit Expense</h1> | ||
</div> | ||
</div> | ||
<div className="content-container"> | ||
<ExpenseForm | ||
expense={this.props.expense} | ||
onSubmit={this.onSubmit} /> | ||
|
||
<button className="button button--secondary" onClick={this.onRemove}>Remove Expense</button> | ||
|
||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
|
||
const mapStateToProps = (state, props) => { | ||
return { | ||
expense: state.expenses.find((expense)=> expense.id === props.match.params.id) | ||
}; | ||
return { | ||
expense: state.expenses.find((expense) => expense.id === props.match.params.id) | ||
}; | ||
}; | ||
const mapDispatchToProps = (dispatch, props) => ({ | ||
startEditExpense: (id,expense) => dispatch(startEditExpense(id,expense)), | ||
startEditExpense: (id, expense) => dispatch(startEditExpense(id, expense)), | ||
startRemoveExpense: (data) => dispatch(startRemoveExpense(data)) | ||
}); | ||
|
||
export default connect(mapStateToProps,mapDispatchToProps)(EditExpensePage); | ||
export default connect(mapStateToProps, mapDispatchToProps)(EditExpensePage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.