Skip to content

Commit

Permalink
Add ability to remove selected subscriptions in order summary
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeNg93 committed Feb 25, 2019
1 parent 6e49272 commit d55bb5f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
9 changes: 8 additions & 1 deletion front-end/components/SubscriptionSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export default class SubscriptionSummary extends React.Component {
this.setState({ cancelDialogVisible: false });
};

onPressRemoveSubscription = subscriptionId => {
this.props.onPressRemoveSubscription(subscriptionId);
this.onPressCloseCancelDialogModal();
};

render() {
return (
<View style={{ width: this.props.containerWidth }}>
Expand All @@ -36,7 +41,9 @@ export default class SubscriptionSummary extends React.Component {
</TouchableOpacity>
<CancelConfirmModal
visible={this.state.cancelDialogVisible}
onPressCancelSubscription={this.onPressRemoveSubscription}
onPressCancelSubscription={() =>
this.onPressRemoveSubscription(this.props.id)
}
onPressCloseModal={this.onPressCloseCancelDialogModal}
modalTitle={this.props.modalTitle}
modalTextContent={this.props.modalTextContent}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class DeliveryScheduleCheckoutScreen extends React.Component {
};

componentDidMount() {
this.props.setDeliveryDayOfWeek('MON');
this.props.setDeliveryDayOfWeek('Mon');
this.props.setDeliveryTime('10:00-12:00');
}

Expand Down Expand Up @@ -137,7 +137,10 @@ const mapStateToProps = state => ({
deliveryTime: state.checkout.deliveryTime,
});

export default connect(mapStateToProps, {
setDeliveryDayOfWeek,
setDeliveryTime,
})(DeliveryScheduleCheckoutScreen);
export default connect(
mapStateToProps,
{
setDeliveryDayOfWeek,
setDeliveryTime,
}
)(DeliveryScheduleCheckoutScreen);
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ class OrderSummaryScreen extends React.Component {
};

onPressRemoveSubscription = subscriptionId => {
if (this.props.shoppingCart.length === 1) {
this.props.removeSubscriptionFromCart(subscriptionId);
this.props.navigation.navigate('AddSubscription');
return;
}

this.props.removeSubscriptionFromCart(subscriptionId);
};

Expand Down

0 comments on commit d55bb5f

Please sign in to comment.