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

Interacted With Cart State #152

Open
dayhaysoos opened this issue Sep 25, 2020 · 1 comment
Open

Interacted With Cart State #152

dayhaysoos opened this issue Sep 25, 2020 · 1 comment
Labels
discussion Used as a discussion forum enhancement New feature or request

Comments

@dayhaysoos
Copy link
Owner

We should have a state that allows us to temporarily show something like, "Added to your cart" for a few seconds. Not sure what I would name it, maybe hasInteractedWithCart where it's false by default. It will only display for a given number of seconds, and we can pass it a string of what it should say as well.

@dayhaysoos dayhaysoos changed the title Added To Cart State Interacted With Cart State Sep 25, 2020
@andria-dev
Copy link
Collaborator

Hmm, I was thinking of a way to prototype this but I think this is the wrong way to go about something like "Added to your cart". Instead, I would recommend the developer to do this on their Product component:

They should likely be using some sort of global or global-ish state that allows them to add products to a stack when they're added to the cart. After a certain amount of time, they could be cleared off of the stack. Now that I'm writing this, we could also make this stack inside of this library.

Let me know if you want to make this stack or let the end-developers do it. For reference, if we wanted to build it we'd need to do the following:

  • Add an addedToCartTimer prop or something like that that could be passed to our redux state for future use.
  • Add an addedToCartStack or something to our redux state.
  • Add a middleware that sees when addItem is called successfully then adds that product to the addedToCartStack. After that, it starts a setTimeout timer that will do store.dispatch(actions.addedToCartTimerFinished()) which does state.addedToCartStack.shift() to remove the first element of the stack (FIFO)

@andria-dev andria-dev added discussion Used as a discussion forum enhancement New feature or request labels Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Used as a discussion forum enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants