bradtraversy / proshop-v2

ProShop ecommerce website built with MERN & Redux Toolkit
532 stars 267 forks source link

Real-time countInStock update concern #19

Closed davidd74 closed 8 months ago

davidd74 commented 10 months ago

Once we add an item to the cart using Redux Toolkit, we pass the entire product to the state, specifically the countInStock field, which has a fixed value as long as the user does not remove and re-add that item to the cart.

Suppose we added an item to the cart, closed the website, and came back later in the day. Ealier we selected to order 5 out of 5 products that were in stock. However, someone else ordered 3 of these products while we were gone. Despite this, we can still order the same amount because the countInStock data is not being updated in real-time. How can I ensure that doesn't happen in my application? Basically I want to know what is the simplest way to go about this.

HridoyHazard commented 9 months ago

did you get any solutions for this issue ? @davidd74

HridoyHazard commented 8 months ago

@bushblade hi did you fix this issue ?

bushblade commented 8 months ago

Hi @HridoyHazard No I've not looked into it. I would only resolve issues present in the course code. I would be reluctant to add in a new feature such as this as students need the code here as a reference. I think it would be a great feature to add in though and an excellent opportunity to consolidate learning. I'll close as an issue here as this would be a new feature that is not currently covered in the course.

HridoyHazard commented 8 months ago

i'm doing the course but this isn't covered yet...why so?

davidd74 commented 4 months ago

Hi @HridoyHazard No I've not looked into it. I would only resolve issues present in the course code. I would be reluctant to add in a new feature such as this as students need the code here as a reference. I think it would be a great feature to add in though and an excellent opportunity to consolidate learning. I'll close as an issue here as this would be a new feature that is not currently covered in the course.

I understand that this would be a new feature, however I believe that some sort of guidance should be provided to the students because in the course, Brad mentioned that this website can be applied for real-world usage

davidd74 commented 4 months ago

did you get any solutions for this issue ? @davidd74

I suggest using web sockets