Skip to content

Commit

Permalink
Merge pull request #155 from mateoclarke/mateo_bugs
Browse files Browse the repository at this point in the history
Update amount by Percent works properly
  • Loading branch information
mateoclarke authored Jun 4, 2017
2 parents f6e7df0 + fbc794a commit 8f66ded
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/src/components/Intro.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const IntroPage = (props) => {
<Link to="/dashboard" className="intro__skip">Skip Intro</Link>
<img src={introImgArray[props.params.id - 1]} className="intro__img" alt="Money Emoji" />
<div className="celebration">
<img src={introCofArray[props.params.id -1]} className="intro__cof" alt="Money Emoji" />
<img src={introCofArray[props.params.id - 1]} className="intro__cof" alt="Money Emoji" />
</div>
<p className="intro__text">{props.text}</p>
{
Expand All @@ -46,9 +46,9 @@ const IntroPage = (props) => {
}

export default class Intro extends Component {
render () {
render() {
return (
<Route path='/intro/:id' render={({match}) => <IntroPage {...match} text={introText[match.params.id - 1]} />} />
<Route path="/intro/:id" render={({ match }) => <IntroPage {...match} text={introText[match.params.id - 1]} />} />
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/PartyLevelHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const PartyLevelHeader = (props) => {
return (
<div className="PartyLevelHeader__overlay--grey">
<span className="PartyLevelHeader__change">
{sign} {dept.percentChange}% from Last Year
{sign} {Math.abs(dept.percentChange)}% from Last Year
</span>
<h2 className="PartyLevelHeader__value">
<FormattedNumber
Expand Down
4 changes: 1 addition & 3 deletions app/src/containers/Department.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ const mapDispatchToProps = (dispatch) => {
persistToFirebase(userId, departments)
},
onPercentChange: (dept, percentChange, departments, serviceIndex, services) => {
const deptPercentChange = dept.amount === null ? 0 : percentChange

dispatch(changeDepartmentPercentChange(dept.deptId, deptPercentChange))
dispatch(changeDepartmentPercentChange(dept.deptId, percentChange))
dispatch(recalculateServiceAmount(serviceIndex, departments))
dispatch(changeRemainingFundsAmout(services))
},
Expand Down
10 changes: 6 additions & 4 deletions app/src/reducers/departments.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ function departments(state = InitialState.departments, action = {}) {
switch (action.type) {
case 'CHANGE_DEPARTMENT_PERCENT_CHANGE':
newDeptState = deptState
newDeptState.percentChange = Number(
(deptState.percentChange + action.percentChange).toFixed(1),
)

const newPercentChange = Number(newDeptState.percentChange + action.percentChange)

newDeptState.percentChange = newPercentChange

newDeptState.amount =
(deptState.lastYearAmount * (newDeptState.percentChange / 100))
(deptState.lastYearAmount * (newPercentChange / 100))
+ deptState.lastYearAmount

newState = Object.assign({}, state,
Expand Down

0 comments on commit 8f66ded

Please sign in to comment.