Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clear a user's cart after placing an order, and remove MiniCart popper from order completed page. #332

Merged
merged 15 commits into from
Sep 26, 2018

Conversation

willopez
Copy link
Member

Resolves #323
Impact: minor
Type: bugfix

Summary

The MiniCart popper would occasionally be rendered on the order completed page. This PR fixes that and clears the cart cache on the client instead of querying the server.

Testing

  1. Place an order
  2. Verify cart popper is not rendered at the bottom of the page, and that the cart has been cleared.


refetchCart();
if (authStore.isAuthenticated) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contents of componentDidMount that are used to update the cart cache should be in a function in the withCart decorator, and that function should be called from componentDidMount.

@@ -63,6 +63,7 @@ export default (Component) => (
// If success
if (data && !error) {
const { placeOrderWithStripeCardPayment: { orders, token } } = data;
uiStore.closeCart();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should identify the reason cart is opening unintentionally and fix that, rather than forcing it closed for this specific instance.

@aldeed aldeed changed the base branch from master to develop September 24, 2018 20:53
@willopez
Copy link
Member Author

@mikemurray this is ready for anther review, I added a loading when placing an order for a better UX.

Copy link
Member

@mikemurray mikemurray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting the following warning when I check out

Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
    in CheckoutActions

@willopez
Copy link
Member Author

@mikemurray error fixed and ready for another review.

Copy link
Member

@mikemurray mikemurray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also seeing a flash of the checkout actions during checkout.

When I submit the order, I see the "is loading" overlay, but for a split second, it disappears then re-appears, revealing the blank credit card form.

Is it possible to move this page loading component out of the checkout actions component? Maybe we can make it part of the layout, or something and trigger it globally. That may stop it from flashing when the CheckoutActions does its render hiccup.

render() {
const { classes } = this.props;
const { delayIsDone } = this.state;

return (
<div className={classes.wrapper}>
{!!delayIsDone && this.renderSpinner()}
{!!delayIsDone && this.renderMessage()}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the !! necessary since delayIsDone is already a boolean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's necessary

@mikemurray mikemurray merged commit b1ff9af into develop Sep 26, 2018
@mikemurray mikemurray deleted the fix-clear-cart-after-order branch September 26, 2018 22:48
This was referenced Jan 15, 2019
@spencern spencern mentioned this pull request Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty cart message pops up after placing an order
2 participants