Clear discount on transition

This commit is contained in:
Berkeley Martinez
2015-10-26 18:00:33 -07:00
parent 81c40ddeeb
commit 8024a5bd71
4 changed files with 23 additions and 3 deletions

View File

@ -188,11 +188,11 @@ export default contain(
</Col>
<Col
md={ 6 }>
<h4>+{ price }</h4>
<h4>+ { price }</h4>
</Col>
</Row>
{ this.renderDiscount(discountAmount) }
{ this.renderHighlightPrice(isHighlighted) }
{ this.renderDiscount(discountAmount) }
<Row>
<Col
md={ 3 }

View File

@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import { Lifecycle } from 'react-router';
import { Panel, Button, Row, Col } from 'react-bootstrap';
import { contain } from 'thundercats-react';
@ -25,6 +26,8 @@ export default contain(
jobActions: PropTypes.object
},
mixins: [Lifecycle],
componentDidMount() {
const { appActions, job } = this.props;
// redirect user in client
@ -33,6 +36,11 @@ export default contain(
}
},
routerWillLeave() {
const { jobActions } = this.props;
jobActions.clearPromo();
},
render() {
const { appActions, job, jobActions } = this.props;

View File

@ -71,6 +71,16 @@ export default Actions({
return { promoCode: value.replace(/[^\d\w\s]/, '') };
},
applyCode: null,
clearPromo(foo, undef) {
return {
price: undef,
buttonId: undef,
discountAmount: undef,
promoCode: undef,
promoApplied: false,
promoName: undef
};
},
applyPromo({
fullPrice: price,
buttonId,

View File

@ -22,7 +22,8 @@ export default Store({
setForm,
setFollowersCount,
setPromoCode,
applyPromo
applyPromo,
clearPromo
} = cat.getActions('JobActions');
const register = createRegistrar(jobsStore);
register(setter(setJobs));
@ -32,6 +33,7 @@ export default Store({
register(setter(setForm));
register(setter(setPromoCode));
register(setter(applyPromo));
register(setter(clearPromo));
register(setter(setFollowersCount));
register(transformer(findJob));